dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.9k stars 498 forks source link

Fan Module (Hampton Bay) #932

Closed mjruotolo closed 4 years ago

mjruotolo commented 5 years ago

I would like to use this module with the gateway. https://www.homedepot.com/p/Hampton-Bay-Universal-Wink-Enabled-White-Ceiling-Fan-Premier-Remote-Control-99432/206591100 This is a universal zigbee fan controller with fan and light controls. I have included a bunch of screeen shotes of the nodes as well as the device handler from smartthings. Not sure if this will help in any way. Please let me know what other info you will need.

Smartthings Device handler. https://github.com/dcoffing/KOF-CeilingFan/blob/master/devicetypes/dcoffing/kof-zigbee-fan-controller.src/kof-zigbee-fan-controller.groovy fan6 fan7 hampton-bay-ceiling-fan-remote-wall-controls-99432-64_1000 hampton-bay-ceiling-fan-remote-wall-controls-99432-c3_1000 fan1 fan2 fan3 fan4 fan5

gmitch64 commented 4 years ago

Just noticed there is an update to 77. Didn't look like there were any changes that would affect this. I've upgraded to 77, and it's still showing the same results. I can set the speed from 0 to 6, anything else gives an invalid value error.

gmitch64 commented 4 years ago

image

gmitch64 commented 4 years ago

Interesting, I'm not seeing any option in the Fan Control cluster to set the speed - only read.

gmitch64 commented 4 years ago

I'll take that back... I can change from the cluster

image

gmitch64 commented 4 years ago

I've started deCONZ with the 2 debugging options. I'm probably looking in the wrong place, but all I see are entries in syslog for..

phoscon deCONZ[883]: 12:59:36:961 Poll light node Office Fan Lights

That's the only thing I can see that mentions the fan. I've tired a couple of times setting from PostMan, and nothing else is showing up.

Am I looking in the right place, or is there some other log file that I need to check somewhere?

G

ebaauw commented 4 years ago

Am I looking in the right place, or is there some other log file that I need to check somewhere?

No, there's only one log. Could you try --dbg-info=2 --dbg-aps=2 --dbg-error=1? I'm hoping for a "write attribute" message in the log like:

write attribute of 0x0022A3000022C944 ep: 0x01 cluster: 0x0202: 0x0000
gmitch64 commented 4 years ago

OK... Just to make sure it's running correctly..

/usr/bin/deCONZ --http-port=80 --dbg-info=2 --dbg-aps=2 --dbg-error=1

Trying to set the speed to 2.... Here's Postman not complaining about it...

[ { "success": { "/lights/18/state/speed": 0 } } ]

Here's what I'm getting in syslog... the 2nd one has a bit more context around it...

ay 28 14:55:46 phoscon deCONZ[881]: 14:55:45:852 Poll APS request to 0x000D6FFFFE2DDB6B cluster: 0x0006 dropped, values are fresh enough May 28 14:55:46 phoscon deCONZ[881]: 14:55:45:878 ZclAttribute::setValue() unsupported datatype 0x30 May 28 14:55:46 phoscon deCONZ[881]: 14:55:45:878 write attribute of 0x0022A3000022C944 ep: 0x01 cluster: 0x0202: 0x0000 May 28 14:55:46 phoscon deCONZ[881]: 14:55:45:878 add task 2326 type 14 to 0x0022A3000022C944 cluster 0xFFFF req.id 160 May 28 14:55:46 phoscon deCONZ[881]: 14:55:45:878 ~Resource() /groups 0x7e86a8c8

May 28 14:57:09 phoscon deCONZ[881]: 14:57:04:912 Poll light node TRADFRI Outlet Dining Room May 28 14:57:09 phoscon deCONZ[881]: 14:57:04:965 Poll APS request to 0x000D6FFFFE2DDB6B cluster: 0x0006 dropped, values are fresh enough May 28 14:57:09 phoscon deCONZ[881]: 14:57:04:991 APS-DATA.request id: 64, addrmode: 0x03, addr: 0x00212effff017190, profile: 0x0000, cluster: 0x0031, ep: 0x00 -> 0x00 queue: 2 len: 2 tx.options 0x00 May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:035 APS-DATA.confirm id: 64, status: 0x00 SUCCESS May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:035 APS-DATA.confirm request id: 64 -> confirmed, timeout 25359560 May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:061 APS-DATA.indication srcAddr: 0x0000, srcEp: 0x00 dstAddrMode: 2, profile: 0x0000, cluster: 0x8031, lqi: 130, rssi: 0 May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:061 #011asdu: ca000a0401907101ffff2e2100815d4a02008d1500c941120000f7 May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:062 APS-DATA.indication request id: 64 -> finished May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:062 APS-DATA.request id: 64 erase from queue May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:100 ZclAttribute::setValue() unsupported datatype 0x30 May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:100 write attribute of 0x0022A3000022C944 ep: 0x01 cluster: 0x0202: 0x0000 May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:100 add task 2655 type 14 to 0x0022A3000022C944 cluster 0xFFFF req.id 67 May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:100 ~Resource() /groups 0x7e86a8c8 May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:100 APS-DATA.request id: 67, addrmode: 0x03, addr: 0x0022a3000022c944, profile: 0xFFFF, cluster: 0xFFFF, ep: 0x01 -> 0x01 queue: 2 len: 0 tx.options 0x04 May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:177 #0110x0022A3000022C944 force poll (2) May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:177 Erase task req-id: 67, type: 14 zcl seqno: 0 send time 0, profileId: 0xFFFF, clusterId: 0xFFFF May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:177 APS-DATA.confirm id: 67, status: 0x00 SUCCESS May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:177 APS-DATA.confirm request id: 67 -> erase from queue May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:232 aps request id: 67 finished, erase from queue May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:715 Daylight now: goldenHour1, status: 160, daylight: 1, dark: 0 May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:862 poll node 00:15:8d:00:02:ed:b3:76-01 May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:862 Poll light node Office Curtain South (small)

ebaauw commented 4 years ago

Trying to set the speed to 2.... Here's Postman not complaining about it...

[ { "success": { "/lights/18/state/speed": 0 } } ]

That's not good: it reports having set the speed to 0? Did you specify a body of {"speed": 2}?

May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:100 ZclAttribute::setValue() unsupported datatype 0x30

Datatype 0x30 is deCONZ::Zcl8BitEnum. Is deCONZ::ZclAttribute broken for that one as well?!

Could you please humour me, turn the fan on using the remote (or the GUI) and see of the API call turns if off?

May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:100 write attribute of 0x0022A3000022C944 ep: 0x01 cluster: 0x0202: 0x0000

This is what I wanted to see.

May 28 14:57:09 phoscon deCONZ[881]: 14:57:05:100 add task 2655 type 14 to 0x0022A3000022C944 cluster 0xFFFF req.id 67

Not good. Looks like I'm sending a half-initialised task. I'll remove that.

Would you be able to compile the REST API plugin for testing?

gmitch64 commented 4 years ago

Could you please humour me, turn the fan on using the remote (or the GUI) and see of the API call turns if off?

No, it does not. I've tried it from all different speeds, changing to different speeds, including off, and nothing happens.

Would you be able to compile the REST API plugin for testing?

That's probably beyond what I'd be able to do - I've not tried to build deCONZ from scratch before, and there's probably too much I could mess up in the interim with setting up a toolchain - unless it's a straight pull from git and compile on the Pi?

Now, if you want to send me an updated binary, I'd be happy to drop that in place on my Pi for testing if you'd like.

G

ebaauw commented 4 years ago

unless it's a straight pull from git and compile on the Pi?

Pretty much so, see README.

Now, if you want to send me an updated binary, I'd be happy to drop that in place on my Pi for testing if you'd like.

What Pi are you on? What OS?

gmitch64 commented 4 years ago

pi@phoscon:~/deCONZ $ grep Revision /proc/cpuinfo Revision : a21041

So a Pi 2 Model B

Linux phoscon 4.19.66-v7+ #1253 SMP Thu Aug 15 11:49:46 BST 2019 armv7l GNU/Linux

Originally installed from the SD card image, and have been doing apt-get updates ever since.

G

ebaauw commented 4 years ago

Is that Raspbian stretch?

gmitch64 commented 4 years ago

Is that Raspbian stretch?

Yes it is.

pi@phoscon:~/deCONZ $ sudo apt-get update Get:1 http://archive.raspberrypi.org/debian stretch InRelease [25.4 kB] Get:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease [15.0 kB] Hit:3 http://phoscon.de/apt/deconz stretch-beta InRelease Get:4 http://archive.raspberrypi.org/debian stretch/main armhf Packages [201 kB]

ebaauw commented 4 years ago

libde_rest_plugin.so.gz

Unzip with gunzip, stop deCONZ, copy to /usr/share/deCONZ/plugins, and start deCONZ.

If you want to save the current version, move it out of the plugins directory - don't rename it. deCONZ loads anything from there, irrespective of the file name.

gmitch64 commented 4 years ago

ok.. So, we're running again...

824 ? Ssl 0:04 /usr/bin/deCONZ --http-port=80 --dbg-info=2 --dbg-aps=2 --dbg-error=1

And you have a winner... :)

I've managed to change the fan speed between all 4 values (0 - 4), as well as to 6, which is the comfort-breeze according to the manual. I've also changed it to 5, but I have NO idea what that does - the fan doesn't seem to make any noticable changes.

Thank you very much for working on it.

I am presuming that we won't see a separate device entry for the fan (it'll be a light) until API v2?

G

ebaauw commented 4 years ago

I am presuming that we won't see a separate device entry for the fan

I've been struggling how best to deal with the fan function. It's on the same Zigbee endpoint as the light function, which supports groups. I don't know if the fan state is also saved and restored to Zigbee scenes, but might very well be. That means we want to expose the fan function as a /lights resource, for (future) group (and scene) support. Since both the light function ( On/Off and Level Control clusters) as well as the fan function (Fan Control cluster) are on the same endpoint, they share the Groups cluster. Meaning both functions share group membership. Exposing both functions as separate /lights resources would be very complex (to make sure both are listed under the same /groups resources) and confusing to the user (I add one "light" to the group, but another is added as well?). I see no other option than to combine both functions in a single /lights resource.

I've also changed it to 5, but I have NO idea what that does - the fan doesn't seem to make any noticable changes.

Speed 5 is "Auto" according to the ZCL spec (see also the dropdown values in the GUI). I don't think the Hampton Bay supports it.

gmitch64 commented 4 years ago

Speed 5 is "Auto" according to the ZCL spec (see also the dropdown values in the GUI). I don't think the Hampton Bay supports it.

Should the API return an invalid value when it's set to 5 then?

I've been struggling how best to deal with the fan function.

I noticed that on another thread, and commented there.. As I said there, the fan is the main thing - there's always going to be a fan. The lights are the optional device here, depending on whether the user fits, or doesn't fit, the light kit. I suspect that the remote controller won't know, or care, and will presume that the lights always exist.

G

ebaauw commented 4 years ago

Should the API return an invalid value when it's set to 5 then?

Could be, but would need another whitelist (assuming we will eventually support other fans that do support this). More interesting: do we want to continue to use these number values, or should the API expose string values?

I suspect that the remote controller won't know, or care, and will presume that the lights always exist.

The wired dimmer to control the lights is integral part of the module. Whether you wired one or more lights to it is a different question. In theory, the module could measure current and check whether a light is connected, but I doubt it does. It's not exposed over Zigbee, as far as I can tell.

As I said there, the fan is the main thing - there's always going to be a fan. The lights are the optional device here, depending on whether the user fits, or doesn't fit, the light kit.

So it's gonna be interesting how to expose the module to HomeKit in Homebridge Hue. The logical mapping would be a single accessory with a Lightbulb and a Fan v2 service, which should show as two tiles in Home. Since it's the same /lights resource, I wouldn't know how to indicate that the Lightbulb should be suppressed in case no light has been connected.

gmitch64 commented 4 years ago

More interesting: do we want to continue to use these number values, or should the API expose string values?

I'm a computer guy, so I like numbers :) But it should probably be consistent with what the majority of other devices in the API return/use for settings.

The wired dimmer to control the lights is integral part of the module

I agree, and as you say, I doubt the current draw etc is even measured. What I was just pointing out, is that this is a fan unit, with optional lights, rather than a lighting unit, with a fan. If you're going to start a new "class" of device, then I'd suggest making it a fan. If you're going to overload the lights, then what you're saying makes sense - and I suspect you're going to have to overload the lights class, at least in v1 of the API.

I wouldn't know how to indicate that the Lightbulb should be suppressed in case no light has been connected.

In HomeSeer speak, what would make logical sense to me (and I don't have to maintain the code), would be to have a root device which would be the whole unit, with 2 child devices, one for the fan, and one for the lights. I think (but I'm not 100% sure), that you could put some configuration in the root device to enable/disable the light unit.

I'm not sure how Wim is going to expose it in Homeseer - we'll see when he does a beta release :)

G

ebaauw commented 4 years ago

I've managed to change the fan speed between all 4 values (0 - 4), as well as to 6, which is the comfort-breeze according to the manual.

@gmitch64 for Homebridge Hue I need to map the speed to HomeKit's Rotation Speed, which is in %. So something like 0 => 0%, 1 => 25%, 2 => 50%, 3 => 75%, 4 => 100%. Not sure what to do with speed 6, can you please advice me? Is speed 6 equal to one of the other speeds, or is it a separate speed. In that case: where would I position that?

gmitch64 commented 4 years ago

That's going to be a tricky one, since it's a variable speed. According to the install guide, "comfort mode" (speed 6)

Randomly alternates fan speeds to create an organic breeze effect.

I wouldn't quite have worded it that way, but it does somewhat randomly alternate the fan speeds. I haven't used that long enough to pay attention to whether it's a straight up and down, or a random speed change.

G

ebaauw commented 4 years ago

Thanks, I'll ignore it for now, until finding a proper way to support it.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

gmitch64 commented 4 years ago

I'm good with the way it's been added at the moment - seems to work well. I'm not the original issue opener, but I am good with this being closed.

BBru62 commented 4 years ago

How would I go about adding this fan to home assistant?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

avboy72 commented 3 years ago

Reading through the comments, it appears that this device at least mostly works. Is there something special I need to do to use it?