sean9keenan / homebridge-bigAssFans

A Homebridge plugin for Big Ass Fans
MIT License
28 stars 15 forks source link

Expose Haiku wall controller #11

Open pponce opened 7 years ago

pponce commented 7 years ago

Would love it if this plugin could expose the haiku wall controller so i can trigger other homekit products to turn on or off based on button press of controller. https://www.haikuhome.com/wall-control-wifi-module

I recently installed the homberidge-hue app and it can expose the philips switches. It's been great to use those switch button presses as trigger events.

pedroserano commented 7 years ago

@pponce I like the idea, but when I telnet into the wall controller, I don't get a response for any button press. Do you know if it's supported by the Haiku API?

pponce commented 7 years ago

Would it be possible to emulate a haiku fan and have the wall controller pair with the emulated fan instead of the actual fan? Then homebridge could relay the wall control button presses to the fan as well as a homekit trigger event for other devices to react to a button press?

sean9keenan commented 7 years ago

You'd probably have to figure out how the Wall Controller and the Haiku fan talk to each and in particular how they pair.

One way you can do this is by setting up wireshark on your network (the way I did this was by setting up my mac to act as an AP and connected my fan to my mac's AP) and figuring out what packets are sent over the network. (there are tutorials online on how to do this)

The fan's seem to rely pretty heavily on just broadcasting their status to everyone, so it's possible (if we're really lucky) that the wall controller does the same. In which case you can just listen to UDP packets and see what comes up.

The easiest thing you can try as a first test (to see if it is indeed broadcasting to everyone on the same port) is running my BigAssAPI.js and turning on the logging. Once you do that then this line should print out every message that is broadcast to the network.

Although my guess is that you won't pick it up on there if @pedroserano isn't getting any response from the wall controller when he telnets into it 😞

pedroserano commented 7 years ago

I do get a broadcast update from the wall controller on an open telnet connection when occupancy status changes (same as I get from an open telnet with the fan - even though the Sensor is in the wall controller - the wall controller must be relaying this info to the fan to broadcast since I associated them for the same room), but so far that's the only broadcast update I've gotten from the wall controller, nothing when I push any of the buttons on it.

sean9keenan commented 7 years ago

Hmm, that's interesting - what do the other buttons do? Maybe those aren't broadcast updates, and it only sends it to the particular IP address of that fan (it would make sense that occupancy would be a broadcast - incase multiple fans needed to listen to the broadcast)

pponce commented 7 years ago

It has 6 buttons:
Three above the sensor for fan speed control. One for fan speed up and one for fan speed down. One for on/off of fan. Three buttons below for light control. Same deal. One for brighter one for lowering brightness and one for on/off. I can try to play with wireshark. I'm a bit of a hack though so i'll be slow going.

pponce commented 7 years ago

So I have wire shark running on my mac. With wall controller, fan and mac all connected to the same wifi network. I set up a filter to see any packets coming from my wall controller or fan based on IP address. I see a bunch of udp packets being sent from both controller and fan. I can't really tell what button presses are doing in the capture file. That is i can't tell if any of the packets correspond to button presses. When just sitting idle I see many udp packets of various lengths coming from fan and wall controller. The other interesting thing is that i have 2 fans. And when i set the filter in wireshark for capture to include the wall controller and the two fans i only see UDP activity from the the one fan controlled by the wall controller and the wall controller. The other fan shows no activity whatsoever as far as i can see.

sean9keenan commented 7 years ago

Just to confirm - this is with the app closed?

It looks like it's possible that BigAssFans changed the firmware in a minor way - I'm no longer seeing any broadcasts from the fan - it seems to only talks back to the IP address that addressed it. And the app seems to constantly ask all fans on the network what their status is, this change is a bit annoying and would require a change to the BigAssAPI to act more like the app.

RE: the controller and the fan, it's possible that it's also constantly polling - but I would be surprised by that design decision, but maybe it's reasonable since it's UDP. If it's constantly sending messages, it would be harder to pick out what message was from the button press. I think that there is a way so that you can try to interpret the UDP packets as text in Wireshark - that's how I was originally able to see the responses like <Sean's Room;SNSROCC;STATUS;OCCUPIED>. You can also send me the Wireshark capture and I can try and take a look at it. (My email is on my github profile I think)

pponce commented 7 years ago

Yup. That was with the app closed. I'll run another trace later today and play around with the options for viewing in wireshark. Will also send you the captured output.

pponce commented 7 years ago

just sent packet capture to your email....

pponce commented 7 years ago

Let me know if the packet capture proved helpful. I can test or get more captured data as needed.

sean9keenan commented 7 years ago

Sounds good - sorry, I haven't had a chance to look at it yet. Should have a chance in the next few days. Sorry!

pponce commented 7 years ago

No worries at all. Thanks for making BigAssFans homekit compatible.

davidvanvo commented 7 years ago

I know this is ongoing but thought I'd provide feedback on what i'm seeing.

I have 6 total fans with lights, but only 4 are tied to a wall remote. i am getting the motion trigger option for all 6, when it should only be 4.