Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Poll device when device does not support reporting. #2122

Merged
merged 5 commits into from
Oct 24, 2019

Conversation

sjorge
Copy link
Contributor

@sjorge sjorge commented Oct 12, 2019

Some device do not support attReport for some keys, this will emulate
it.

You can configure which keys that should be read when another device
send a message and the configured device a bind target or in a group the
message was send to.

devices:
  '0x0017880104259333':
    friendly_name: bedroom/desk_lamp
    retain: true
    debounce: 0.5
    report_emulate:
      - brightness
      - color

Will have the brightness and color queried for example when a hue dimmer
sends commands to the bulb.

@sjorge
Copy link
Contributor Author

sjorge commented Oct 12, 2019

@Koenkk as promised on #2108, here is the code I have now.

It is working pretty well, although I think this probably more work. I have not written tests (not sure how?) and I think the code can be optimize some more by someone who has a better understanding of zigbee2mqtt and zigbee-herdsman.

Edit: rebased because conflict with last commit in dev

@sjorge sjorge force-pushed the report_emulate branch 2 times, most recently from 3e835b5 to 4011fca Compare October 12, 2019 21:08
@Koenkk
Copy link
Owner

Koenkk commented Oct 12, 2019

nice pr! However I'm wondering for how many cases this feature can be used. For know the only use case I see is the combination of a hue dimmer with a hue bulb. If that is indeed the case we could try a much simpler and local solution (inside zigbee-shepherd-converters) which works without any additional configuration. Did you have any other use cases in mind for this?

@sjorge
Copy link
Contributor Author

sjorge commented Oct 12, 2019

@Koenkk well it's not just the hue dimmer. Same for the tradfri remote.

So I guess it is tied to the bulb, rather than the remote used? But yes, a sort of work around that applies to all hue bulbs without reporting, might be better.

I only own hue and tradfri bulbs, so I am not sure there are other bulbs that do not support attReport for brightness/color. So it currently catching a lot of messages, as we work backwards. From whatever that triggers a change via group or binding to the bulb that is lacking attReport.

Edit: maybe something is possible though to hook into the bind/group add+remove to keep the relation in the database? And then somehow mark the bulb(s) in zigbee-herdman-converters so they can request a sort of callback? I'm not familiar enough yet with zigbee-herdman/converters

@Koenkk
Copy link
Owner

Koenkk commented Oct 14, 2019

AFAIK the current code won't work for the TRADFRI remote control as it addresses groupID and not device ID.

I think this code should be moved to deviceBind.js.

The latest zigbee-herdsman keeps track of binds (https://github.com/Koenkk/zigbee-herdsman/blob/master/src/controller/model/endpoint.ts#L53).

In pseudo code we need to do something like

onStageChange(endpoint) {
    for binds in endpoint.binds
          if (typeof bind.target === group)  
               // Update all children of group with new state
         else if (typeof bind.target === endpoint) 
             // update endpoint with new state
}

@sjorge
Copy link
Contributor Author

sjorge commented Oct 14, 2019

I did test it with the trådfri remote and it was working fine? (As I also loop all group members if the message was directed at a group.)

@Koenkk
Copy link
Owner

Koenkk commented Oct 18, 2019

OK, I will try to experiment and review the code this weekend.

@sjorge
Copy link
Contributor Author

sjorge commented Oct 18, 2019

I haven’t look at the hook suggestion directly in herdsman yet, got super sick this week so haven’t been doing much at all.

There is definitely room for improvement

@Koenkk
Copy link
Owner

Koenkk commented Oct 18, 2019

don't worry, get well soon!

@LukeHandle
Copy link

LukeHandle commented Oct 21, 2019

However I'm wondering for how many cases this feature can be used

Just started to try and use the groups feature and found that Hue bulbs aren't updating their state after a set (thus Hass thinks the individual room lights are still on/off vs. what they are).

My current workaround is from the suggestion you gave #2108 (comment) where I query after the group update. I think the get sometimes causes issues with 1+ second transitions where it gets the brightness value before it reaches its final state.

Will also be an issue with Scenes I suspect as well? Interesting how Hue solves this themselves, whether proactively querying every X, or proprietary status response back.

@sjorge
Copy link
Contributor Author

sjorge commented Oct 21, 2019

I did notice the occasional 3-8% off in brightness because the bulb was bit slow to transition. Multiple clicks vs hold on the brightness buttons. But overal after a ~1 sec delay they seem to be mostly up to date.

I guess for the hue remote in particular you could use the reported brightness from the remote instead of querying the bulb. But I’d rather see a more generic query after a bound device or a message to a group the bulb is a member trigger the get of the brightness and color attributes.

Still not 100% so haven’t revisited this at all.

@Koenkk
Copy link
Owner

Koenkk commented Oct 23, 2019

I've checked again, but the brightness value will never be correct using this method. The brightness value of the hue dimmer is actually calculated by zigbee2mqtt and not by the dimmer itself. E.g. the brightness up command will result in a 32 increase (https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/converters/fromZigbee.js#L1582) however the bulb itself might use another value.

I think we should go another direction by querying the brightness from the bulb itself. (basically #2122 (comment)).

@sjorge what do you think? I can implement this fairly easily.

@sjorge
Copy link
Contributor Author

sjorge commented Oct 23, 2019

The current hacky code in this Pr queries the bulb directly, it is... mostly up to date.
I think 1/10 changes (usually the press and hold kind) are off by a few %. But with a correct wait after a bind changes the bulb, we should be good I think.

Some device do not support attReport for some keys, this will emulate
it.

You can configure which keys that should be read when another device
send a message and the configured device a bind target or in a group the
message was send to.

```yaml
devices:
  '0x0017880104259333':
    friendly_name: bedroom/desk_lamp
    retain: true
    debounce: 0.5
    report_emulate:
      - brightness
      - color
```

Will have the brightness and color queried for example when a hue dimmer
sends commands to the bulb.
// Read the following attributes
read: {cluster: 'genLevelCtrl', attributes: ['currentLevel']},
// When the bound devices have the following manufacturerID
manufacturerID: ZigbeeHerdsman.Zcl.ManufacturerCode.Philips,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want Geldopto too? IIRC some of them also lack or have not working attReporting?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we can easily add that later.

@Koenkk Koenkk changed the title Support emulation of attReport Poll device when device does not support reporting. Oct 23, 2019
@Koenkk
Copy link
Owner

Koenkk commented Oct 23, 2019

This PR is ready for merge, @sjorge can you do some final tests? It works nice in my setup.

@sjorge
Copy link
Contributor Author

sjorge commented Oct 23, 2019

I'll give it some testing tomorrow once I get home from work.

@sjorge
Copy link
Contributor Author

sjorge commented Oct 23, 2019

Oops, looks like the udev changes broke zigbee2mqtt on non linux systems!

zigbee2mqtt:info  2019-10-23T20:21:51: Logging to directory: '/opt/zigbee2mqtt/data/log/2019-10-23.20-21-51'
zigbee2mqtt:info  2019-10-23T20:21:51: Starting zigbee2mqtt version 1.6.0 (commit #c18e9fb)
zigbee2mqtt:info  2019-10-23T20:21:51: Starting zigbee-herdsman...
zigbee2mqtt:error 2019-10-23T20:21:51: Error while starting zigbee-herdsman
zigbee2mqtt:error 2019-10-23T20:21:51: Failed to start zigbee
zigbee2mqtt:error 2019-10-23T20:21:51: Exiting...
zigbee2mqtt:error 2019-10-23T20:21:51: Error: spawn udevadm ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:232:19)
    at onErrorNT (internal/child_process.js:407:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! zigbee2mqtt@1.6.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the zigbee2mqtt@1.6.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /opt/zigbee2mqtt/data/.npm/_logs/2019-10-23T20_21_51_861Z-debug.log

Error makes sense, as there is no udevadm on illumos. Same error if I try a raspberrypi running FreeBSD, which also makes sense as there is no udevadm there either.

Error is comming from herdsman actually, looks like SerialPort.list() is linux only :(
Koenkk/zigbee-herdsman@bd7dfff#diff-6a0d1c944f1b9bef00762159e8c91524R11

It's probably fine to fallback to the user configure value if SerialPort.list() fails, if one is specified. That seems to be what zwave2mqtt does, OpenZWave/Zwave2Mqtt@7e247b2

Koenkk added a commit to Koenkk/zigbee-herdsman that referenced this pull request Oct 24, 2019
@Koenkk
Copy link
Owner

Koenkk commented Oct 24, 2019

@sjorge fixed. please try again.

@sjorge
Copy link
Contributor Author

sjorge commented Oct 24, 2019

All looks good:

Hue Dimmer:

zigbee2mqtt:info  2019-10-24T17:22:18: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":1,"linkquality":86,"brightness":223,"battery":100,"action":"down-press","duration":0}'
zigbee2mqtt:info  2019-10-24T17:22:20: MQTT publish: topic 'zigbee2mqtt/bedroom/desk_lamp', payload '{"state":"ON","linkquality":86,"brightness":224,"color":{"x":0.6915,"y":0.3083},"color_temp":153}'
zigbee2mqtt:info  2019-10-24T17:22:23: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":1,"linkquality":86,"brightness":191,"battery":100,"action":"down-press","duration":0}'
zigbee2mqtt:info  2019-10-24T17:22:24: MQTT publish: topic 'zigbee2mqtt/bedroom/desk_lamp', payload '{"state":"ON","linkquality":86,"brightness":194,"color":{"x":0.6915,"y":0.3083},"color_temp":153}'
zigbee2mqtt:info  2019-10-24T17:22:30: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":1,"linkquality":86,"brightness":159,"battery":100,"action":"down-press","duration":0}'
zigbee2mqtt:info  2019-10-24T17:22:32: MQTT publish: topic 'zigbee2mqtt/bedroom/desk_lamp', payload '{"state":"ON","linkquality":84,"brightness":164,"color":{"x":0.6915,"y":0.3083},"color_temp":153}'
zigbee2mqtt:info  2019-10-24T17:22:34: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":1,"linkquality":86,"brightness":127,"battery":100,"action":"down-hold","duration":0.801}'
zigbee2mqtt:info  2019-10-24T17:22:35: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":1,"linkquality":86,"brightness":47,"battery":100,"action":"down-hold","duration":1.602}'
zigbee2mqtt:info  2019-10-24T17:22:35: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":1,"linkquality":86,"brightness":47,"battery":100,"action":"down-hold-release","duration":2.161}'
zigbee2mqtt:info  2019-10-24T17:22:37: MQTT publish: topic 'zigbee2mqtt/bedroom/desk_lamp', payload '{"state":"ON","linkquality":86,"brightness":53,"color":{"x":0.6915,"y":0.3083},"color_temp":153}'
zigbee2mqtt:info  2019-10-24T17:22:42: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":1,"linkquality":86,"brightness":15,"battery":100,"action":"down-hold","duration":0.798}'
zigbee2mqtt:info  2019-10-24T17:22:42: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":1,"linkquality":86,"brightness":1,"battery":100,"action":"down-hold","duration":1.596}'
zigbee2mqtt:info  2019-10-24T17:22:43: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":1,"linkquality":86,"brightness":1,"battery":100,"action":"down-hold","duration":2.401}'
zigbee2mqtt:info  2019-10-24T17:22:44: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":1,"linkquality":86,"brightness":1,"battery":100,"action":"down-hold-release","duration":3.158}'
zigbee2mqtt:info  2019-10-24T17:22:45: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":2,"linkquality":86,"brightness":1,"battery":100,"action":"down-press","duration":0}'
zigbee2mqtt:info  2019-10-24T17:22:47: MQTT publish: topic 'zigbee2mqtt/bedroom/desk_lamp', payload '{"state":"ON","linkquality":86,"brightness":1,"color":{"x":0.6915,"y":0.3083},"color_temp":153}'
zigbee2mqtt:info  2019-10-24T17:22:47: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":2,"linkquality":86,"brightness":33,"battery":100,"action":"up-hold","duration":0.802}'
zigbee2mqtt:info  2019-10-24T17:22:48: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":2,"linkquality":86,"brightness":112.7,"battery":100,"action":"up-hold","duration":1.599}'
zigbee2mqtt:info  2019-10-24T17:22:49: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":2,"linkquality":86,"brightness":192.9,"battery":100,"action":"up-hold","duration":2.401}'
zigbee2mqtt:info  2019-10-24T17:22:50: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":2,"linkquality":86,"brightness":255,"battery":100,"action":"up-hold","duration":3.202}'
zigbee2mqtt:info  2019-10-24T17:22:51: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":2,"linkquality":86,"brightness":255,"battery":100,"action":"up-hold","duration":3.991}'
zigbee2mqtt:info  2019-10-24T17:22:51: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":2,"linkquality":86,"brightness":255,"battery":100,"action":"up-hold","duration":4.8}'
zigbee2mqtt:info  2019-10-24T17:22:52: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":2,"linkquality":86,"brightness":255,"battery":100,"action":"up-hold","duration":5.601}'
zigbee2mqtt:info  2019-10-24T17:22:53: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":2,"linkquality":86,"brightness":255,"battery":100,"action":"up-hold-release","duration":6.23}'
zigbee2mqtt:info  2019-10-24T17:22:54: MQTT publish: topic 'zigbee2mqtt/bedroom/desk_lamp', payload '{"state":"ON","linkquality":86,"brightness":254,"color":{"x":0.6915,"y":0.3083},"color_temp":153}'

IKEA Remote
(Having some issues adding my hue bulb to my group... )

{"topic":"zigbee2mqtt/bridge/group/bedroom/group_night_light_remote/add","payload":"bedroom/desk_lamp","_msgid":"a75513fb.bcfdc","_event":"node:bfcef621.a616f8"}

Doesn't seem to do anything... so maybe a bug somewhere

@sjorge
Copy link
Contributor Author

sjorge commented Oct 24, 2019

Also works fine with an IKEA remote via a group:

zigbee2mqtt:info  2019-10-24T17:29:27: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_night_light', payload '{"linkquality":86,"action":"brightness_down_hold"}'
zigbee2mqtt:info  2019-10-24T17:29:28: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_night_light', payload '{"linkquality":86,"action":"brightness_down_release"}'
zigbee2mqtt:info  2019-10-24T17:29:28: MQTT publish: topic 'zigbee2mqtt/bedroom/sensor', payload '{"battery":74,"voltage":2955,"temperature":21.4,"humidity":71.53,"pressure":1006,"linkquality":60}'
zigbee2mqtt:info  2019-10-24T17:29:29: MQTT publish: topic 'zigbee2mqtt/bedroom_group_night_light_remote', payload '{"color":{"x":0.6915,"y":0.3083},"state":"ON","brightness":205,"color_temp":153}'
zigbee2mqtt:info  2019-10-24T17:29:29: MQTT publish: topic 'zigbee2mqtt/bedroom_desk_lamp', payload '{"state":"ON","linkquality":0,"brightness":205,"color":{"x":0.6915,"y":0.3083},"color_temp":153}'
zigbee2mqtt:info  2019-10-24T17:29:37: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_night_light', payload '{"linkquality":86,"action":"brightness_down_release"}'
zigbee2mqtt:info  2019-10-24T17:29:39: MQTT publish: topic 'zigbee2mqtt/bedroom_group_night_light_remote', payload '{"color":{"x":0.6915,"y":0.3083},"state":"ON","brightness":201,"color_temp":153}'
zigbee2mqtt:info  2019-10-24T17:29:39: MQTT publish: topic 'zigbee2mqtt/bedroom_desk_lamp', payload '{"state":"ON","linkquality":0,"brightness":201,"color":{"x":0.6915,"y":0.3083},"color_temp":153}'
zigbee2mqtt:info  2019-10-24T17:29:44: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_night_light', payload '{"linkquality":86,"action":"brightness_down_hold"}'
zigbee2mqtt:info  2019-10-24T17:29:45: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_night_light', payload '{"linkquality":86,"action":"brightness_down_release"}'
zigbee2mqtt:info  2019-10-24T17:29:46: MQTT publish: topic 'zigbee2mqtt/bedroom_group_night_light_remote', payload '{"color":{"x":0.6915,"y":0.3083},"state":"ON","brightness":113,"color_temp":153}'
zigbee2mqtt:info  2019-10-24T17:29:46: MQTT publish: topic 'zigbee2mqtt/bedroom_desk_lamp', payload '{"state":"ON","linkquality":0,"brightness":113,"color":{"x":0.6915,"y":0.3083},"color_temp":153}'
zigbee2mqtt:info  2019-10-24T17:29:46: MQTT publish: topic 'zigbee2mqtt/bedroom_group_night_light_remote', payload '{"color":{"x":0.7006,"y":0.2993},"state":"ON","brightness":91,"color_temp":153}'
zigbee2mqtt:info  2019-10-24T17:29:46: MQTT publish: topic 'zigbee2mqtt/bedroom/night_light', payload '{"state":"ON","linkquality":86,"brightness":91,"color":{"x":0.7006,"y":0.2993}}'
zigbee2mqtt:info  2019-10-24T17:29:47: MQTT publish: topic 'zigbee2mqtt/bedroom_group_night_light_remote', payload '{"color":{"x":0.6915,"y":0.3083},"state":"ON","brightness":85,"color_temp":153}'
zigbee2mqtt:info  2019-10-24T17:29:47: MQTT publish: topic 'zigbee2mqtt/bedroom_desk_lamp', payload '{"state":"ON","linkquality":0,"brightness":85,"color":{"x":0.6915,"y":0.3083},"color_temp":153}'

Apparently groupnames with a '/' cause issues again, it worked fine for a while, it's only the group, devices are fine and don't have to be renamed... I'll file a follow up issues for this after dinner, if I don't forget.

zigbee2mqtt:info  2019-10-24T17:31:11: Removing 'bedroom/desk_lamp' from 'bedroom_group_night_light_remote'
zigbee2mqtt:info  2019-10-24T17:31:11: MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"type":"device_group_remove","message":{"friendly_name":"bedroom/desk_lamp","group":"bedroom_group_night_light_remote"}}'
zigbee2mqtt:info  2019-10-24T17:31:16: MQTT publish: topic 'zigbee2mqtt/bridge/log', payload '{"type":"groups","message":[{"optimistic":true,"devices":["0x90fd9ffffee77fcf/1"],"friendly_name":"bedroom_group_night_light_remote","retain":false,"ID":20861}]}'

But your update is working fine with both the Hue Dimmer and IKEA remotes.

@Koenkk
Copy link
Owner

Koenkk commented Oct 24, 2019

Great! thanks for everything!

@Koenkk Koenkk merged commit a813663 into Koenkk:dev Oct 24, 2019
@sjorge sjorge deleted the report_emulate branch October 24, 2019 20:25
@sjorge
Copy link
Contributor Author

sjorge commented Oct 24, 2019

After updating to dev, turning off my lamps before heading to bed... I did noticed this.

zigbee2mqtt:info  2019-10-24T20:33:03: MQTT publish: topic 'zigbee2mqtt/bedroom/remote_desk_lamp', payload '{"counter":1,"linkquality":84,"brightness":255,"battery":100,"action":"on-press","duration":0}'
zigbee2mqtt:info  2019-10-24T20:33:03: MQTT publish: topic 'zigbee2mqtt/bedroom/desk_lamp', payload '{"state":"ON","linkquality":84,"brightness":254,"color":{"x":0.6915,"y":0.3083},"color_temp":153}'
zigbee2mqtt:info  2019-10-24T20:33:04: MQTT publish: topic 'zigbee2mqtt/bedroom/desk_lamp', payload '{"state":"ON","linkquality":84,"brightness":254,"color":{"x":0.6915,"y":0.3083},"color_temp":153}'

It looks like the off/on press also triggers the poll of brightness, but we do get on/off state via attReporting for those bulbs. Maybe we should only check when the Hue Dimmer does the brightness up/down buttons? For now I will bumb my debounce to 2 seconds, as a work around

@Koenkk
Copy link
Owner

Koenkk commented Oct 25, 2019

@sjorge added, will only poll when pressing brightness up or down.

@sjorge
Copy link
Contributor Author

sjorge commented Oct 25, 2019

Thanks, seems to work fine now. 👍

@Kryzek
Copy link

Kryzek commented Nov 4, 2019

@sjorge / @Koenkk - Could polling similiar to this be used to poll Hue bulbs also when they are powered on?

Only thing that appears I can see when Hue bulb (https://www.zigbee2mqtt.io/devices/9290012573A.html) is turned on from mains is Device '0x001788010278b40a' announced itself.

@sjorge
Copy link
Contributor Author

sjorge commented Nov 4, 2019

IIRC the few hue bulbs I tested did announce state off/on without any sort of polling.

It was just brightless and color that is missing, although it would be cool to query color too I guess... as after a power outage the color of the bulb and what zigbee2mqtt retained are different :(

@Kryzek
Copy link

Kryzek commented Nov 4, 2019

I mean state update after total power loss (=power off from mains). I do have some bulbs that are getting switched off from physical switch every now and then and it would be nice to have current info of their state when they are powered back on. Sometimes bulbs are on even though Z2M and HA thinks that they are off after being turned off/on again.

Only thing I see when I switch on mains is forementioned Device '0x001788010278b40a' announced itself and I was thinking if this could be sign to trigger state polling to get real state of the bulb updated.

This is the entry for bulb in question from .db
{"id":21,"type":"Router","ieeeAddr":"0x001788010278b40a","nwkAddr":45230,"manufId":4107,"manufName":"Philips","powerSource":"Mains (single phase)","modelId":"LCT010","epList":[11,242],"endpoints":{"11":{"profId":49246,"epId":11,"devId":528,"inClusterList":[0,3,4,5,6,8,4096,768,64513],"outClusterList":[25],"clusters":{"genBasic":{"attributes":{"modelId":"LCT010","manufacturerName":"Philips","powerSource":1,"zclVersion":1,"appVersion":2,"stackVersion":1,"hwVersion":1,"dateCode":"20181115","swBuildId":"1.46.13_r26312"}},"genOnOff":{"attributes":{"onOff":1}}},"binds":[{"cluster":6,"type":"endpoint","deviceIeeeAddress":"0x00124b001ca16964","endpointID":1}]},"242":{"profId":41440,"epId":242,"devId":97,"inClusterList":[33],"outClusterList":[33],"clusters":{},"binds":[]}},"appVersion":2,"stackVersion":1,"hwVersion":1,"dateCode":"20181115","swBuildId":"1.46.13_r26312","zclVersion":1,"interviewCompleted":true,"meta":{}}

@sjorge
Copy link
Contributor Author

sjorge commented Nov 4, 2019

Ah yeah, might be worth fetching state, brightness and color when the device comes online from a cold power off.

I just checked, from a cold off -> on it indeed doesn't report the state.

@Kryzek
Copy link

Kryzek commented Nov 4, 2019

Would be nice if it is possible to get state queried when device announcement is received. Sorry for my terrible explanation of the issue :) I thought that this issue somewhat would fit in here since it it's near "not reporting" -category which this PR was addressing.

@Koenkk
Copy link
Owner

Koenkk commented Nov 5, 2019

I think that will already be done when using the availability feature, can you check?

@Kryzek
Copy link

Kryzek commented Nov 8, 2019

@Koenkk I updated to latest and enabled availability (#775) after got it running. Hue bulbs are indeed checked out when they are powered to mains with availability enabled.

expect(zigbeeHerdsman.devices.bulb_color_2.getEndpoint(1).read).toHaveBeenCalledTimes(2);

// Should only call Hue bulb, not e.g. tradfri
expect(zigbeeHerdsman.devices.bulb.getEndpoint(1).read).toHaveBeenCalledTimes(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sjorge shouldn't this be devices.bulb_2 instead of devices.bulb?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's been a long time, but yes... looking at the code, it should be bulb_2 I think. It just happens to work as is because bulb is never involved so it doesn't get called either.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I can fix this as part of my PR!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: #5139

pedrolamas added a commit to pedrolamas/zigbee2mqtt that referenced this pull request Nov 30, 2020
Koenkk pushed a commit that referenced this pull request Nov 30, 2020
…codes (#5139)

* Poll lamps with Philips or Atmel manufacturer code

* Fixes incorrect test

Following up on #2122 (comment)

* Adds GLEDOPTO_CO_LTD and MUELLER_LICHT_INT to lamp polling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants