I’ve been wanting to use my Google Home to control my Haiku L-series fans for awhile now, so I decided to write a device handler with the goal of being able to send commands to my fans using voice control.
I took System48’s code (also see the original thread here) and rewrote it from the ground up as a composite device handler to achieve this. The
Haiku Fan device handler is the parent device and the
Haiku Fan Light device handler is the child device. Both are using the
Switch Level capabilities.
As a consequence of this design, SmartApps are now able to interact with both the fan and the fan’s light as independent switches!
Here’s the repo with the device handlers:
One limitation is that the commands are very much one-way – SmartThings has no way of knowing the fan’s current state. If you adjust your fan with the remote control or Haiku’s app, it will go out of sync with SmartThings. I’ve looked into addressing this and it seems like there’s no good way to do it at the moment, as the SmartThings Hub doesn’t support listening to UDP ports.
It’s my first time writing code for SmartThings, and also my first time writing Groovy (or Java for that matter), so I welcome any guidance on how to improve or make my code more idiomatic!