Wednesday, 06 November 2019 17:00

My SwiftyHue Pull Request

Written by https://cxlabs.sap.com/2019/11/07/my-swiftyhue-pull-request/
Rate this item
(0 votes)

For the Guardian prototype, we use a Phillips Hue light strip when, for example, a person with or without a helmet is detected. The light changes from red to cyan. An

iPhone app that works like a gateway receives MQTT messages with the light values and sends them to the Hue. I use SwiftyHue, an open source project, to connect an iOS app to a Phillips Hue.

It allows you to

  • find a Phillips Hue bridge
  • connect and authenticate the bridge
  • and, of course, changing the color.

Unfortunately SwiftyHue showed an error message even if the execution of the command was successful. Seeing an error message in the logs makes me nervous and confusing in combination with “successful”. I looked at the code and simply added an if statement to check if everything was successful. In this case the method returns nil.

if let _: Any = "success" <~~ json { return nil}

This worked well. I forked the project, adapted my changes and sent a pull request. The SwiftyHue project is a bit quiet. They release a new version every half year, but to be fair, no big changes are necessary, because the library does what it should. I didn’t expect a quick response, so I was a little surprised that after a few days my pull request was accepted and merged.

It was released in the pre-release version 0.5.3 and only a few days later the “full” version 0.5.4 was available. Did I said they are quiet?
For the prototype I stayed with the old version because using a pre-release that mainly contains Swift 5 updates might not be a good idea. And the version 0.5.4 came after we showed the demo the first time. But for the next prototype using a Hue, my changes will be included. :happysmilyface:

Read 9 times

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.