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

Add optimistic option. #4542 #4572

Merged
merged 1 commit into from
Oct 6, 2020
Merged

Add optimistic option. #4542 #4572

merged 1 commit into from
Oct 6, 2020

Conversation

Koenkk
Copy link
Owner

@Koenkk Koenkk commented Oct 6, 2020

No description provided.

@branch-switcher branch-switcher bot changed the base branch from master to dev October 6, 2020 14:27
@branch-switcher
Copy link

Hello @Koenkk. The base branch of this pull request has been updated to the dev branch. Please revisit the changes and make sure that there are no conflicts with the new base branch. Thank you for your contributions.

@@ -238,7 +239,7 @@ class EntityPublish extends Extension {
this.publishEntityState(resolvedEntity.settings.ID, msg);
}

if (result && result.membersState) {
if (result && result.membersState && optimistic) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this also true for say a group of blinds? I can't figure it out by reading more of the code around here if it is. I think so?

Copy link
Owner Author

@Koenkk Koenkk Oct 6, 2020

Choose a reason for hiding this comment

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

It depends if you setup reporting, if not you wont' get state updates.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, I'll be setting this on my groups then.
That won't fix #3461 but it will remove one of the updates.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is indeed working for groups, but the effect is weird:

with 'optimistic' set to false:

  • send /set to group
  • reporting updates bulb1 and bulb2
  • no update on the group at all

without 'optimistic' or set to true:

  • send /set to group
  • update of group
  • reportining updates bubl1
  • update of group
  • reporting updates bulb2
  • update of group

Is this the expected behavior?
I would have expected the following with optimistic set to false:

  • send /set to group
  • reporting for bulb1
  • update of group
  • reporting of bubl2
  • update of group

Copy link
Owner Author

Choose a reason for hiding this comment

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

Not expected behaviour, I expect what you mentioned last, can you provide the debug logging of this?

@Koenkk Koenkk merged commit 5d1975d into dev Oct 6, 2020
@Koenkk Koenkk deleted the optimistic branch October 6, 2020 19:50
@sjorge
Copy link
Contributor

sjorge commented Oct 7, 2020

My group config:

  '10105':
    friendly_name: livingroom/floor_light
    optimistic: false
    devices:
      - 0x00158d0003618c46/1
      - 0x00158d000361b295/1

This is when controlling the group via a remote:

Zigbee2MQTT:debug 2020-10-07 19:07:29: Received Zigbee message from 'livingroom/floor_light/remote', type 'commandOff', cluster 'genOnOff', data '{}' from endpoint 1 with groupID 10105
Zigbee2MQTT:debug 2020-10-07 19:07:29: Received Zigbee message from 'livingroom/floor_light/bulb2', type 'attributeReport', cluster 'genOnOff', data '{"onOff":0}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-10-07 19:07:29: Received Zigbee message from 'livingroom/floor_light/bulb1', type 'attributeReport', cluster 'genOnOff', data '{"onOff":0}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-10-07 19:07:31: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/remote', payload '{"action":"off","battery":60,"linkquality":60,"update":{"state":"idle"}}'
Zigbee2MQTT:info  2020-10-07 19:07:31: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb2', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":52,"state":"OFF"}'
Zigbee2MQTT:info  2020-10-07 19:07:31: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb1', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":63,"state":"OFF"}'
Zigbee2MQTT:debug 2020-10-07 19:07:37: Received Zigbee message from 'livingroom/floor_light/bulb2', type 'attributeReport', cluster 'genLevelCtrl', data '{"currentLevel":254}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-10-07 19:07:39: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb2', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":55,"state":"OFF"}'
Zigbee2MQTT:debug 2020-10-07 19:07:42: Received Zigbee message from 'livingroom/floor_light/bulb2', type 'attributeReport', cluster 'lightingColorCtrl', data '{"currentX":45783,"currentY":19625}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-10-07 19:07:44: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb2', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":55,"state":"OFF"}'
Zigbee2MQTT:debug 2020-10-07 19:07:53: Received Zigbee message from 'livingroom/floor_light/bulb2', type 'attributeReport', cluster 'lightingColorCtrl', data '{"colorTemperature":555}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-10-07 19:07:55: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb2', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":55,"state":"OFF"}'

This is when controlling via mqtt

Zigbee2MQTT:debug 2020-10-07 19:08:41: Received MQTT message on 'zigbee2mqtt/livingroom/floor_light/set/state' with data 'toggle'
Zigbee2MQTT:debug 2020-10-07 19:08:41: Publishing 'set' 'state' to 'livingroom/floor_light'
Zigbee2MQTT:debug 2020-10-07 19:08:41: Received Zigbee message from 'livingroom/floor_light/bulb1', type 'attributeReport', cluster 'genOnOff', data '{"onOff":1}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-10-07 19:08:41: Received Zigbee message from 'livingroom/floor_light/bulb2', type 'attributeReport', cluster 'genOnOff', data '{"onOff":1}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-10-07 19:08:43: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb1', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":55,"state":"ON"}'
Zigbee2MQTT:info  2020-10-07 19:08:43: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb2', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":57,"state":"ON"}'

No update of the group either way.

Koenkk added a commit that referenced this pull request Oct 8, 2020
@Koenkk
Copy link
Owner Author

Koenkk commented Oct 8, 2020

This seemed to conflict with the optimistic option which was already there for groups: https://www.zigbee2mqtt.io/information/groups.html#state-changes. This is fixed now, so the old behaviour of the optimistic for groups is in place now.

@sjorge
Copy link
Contributor

sjorge commented Oct 8, 2020

Something still seems of after that change

Zigbee2MQTT:debug 2020-10-08 18:31:46: Received Zigbee message from 'livingroom/floor_light/remote', type 'commandOn', cluster 'genOnOff', data '{}' from endpoint 1 with groupID 10105
Zigbee2MQTT:debug 2020-10-08 18:31:46: Received Zigbee message from 'livingroom/floor_light/bulb1', type 'attributeReport', cluster 'genOnOff', data '{"onOff":1}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-10-08 18:31:46: Received Zigbee message from 'livingroom/floor_light/bulb2', type 'attributeReport', cluster 'genOnOff', data '{"onOff":1}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-10-08 18:31:48: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/remote', payload '{"action":"on","battery":60,"linkquality":84,"update":{"state":"idle"}}'
Zigbee2MQTT:info  2020-10-08 18:31:48: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb1', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":57,"state":"ON"}'
Zigbee2MQTT:info  2020-10-08 18:31:48: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb2', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":65,"state":"ON"}'
Zigbee2MQTT:debug 2020-10-08 18:31:48: Received Zigbee message from 'livingroom/floor_light/bulb1', type 'attributeReport', cluster 'genLevelCtrl', data '{"currentLevel":254}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-10-08 18:31:50: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb1', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":57,"state":"ON"}'
Zigbee2MQTT:debug 2020-10-08 18:31:51: Received Zigbee message from 'livingroom/floor_light/bulb1', type 'attributeReport', cluster 'lightingColorCtrl', data '{"colorTemperature":555}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-10-08 18:31:53: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb1', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":60,"state":"ON"}'
Zigbee2MQTT:debug 2020-10-08 18:32:39: Received Zigbee message from 'livingroom/floor_light/remote', type 'commandOff', cluster 'genOnOff', data '{}' from endpoint 1 with groupID 10105
Zigbee2MQTT:debug 2020-10-08 18:32:39: Received Zigbee message from 'livingroom/floor_light/bulb1', type 'attributeReport', cluster 'genOnOff', data '{"onOff":0}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-10-08 18:32:40: Received Zigbee message from 'livingroom/floor_light/bulb2', type 'attributeReport', cluster 'genOnOff', data '{"onOff":0}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-10-08 18:32:41: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/remote', payload '{"action":"off","battery":60,"linkquality":57,"update":{"state":"idle"}}'
Zigbee2MQTT:info  2020-10-08 18:32:41: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb1', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":55,"state":"OFF"}'
Zigbee2MQTT:info  2020-10-08 18:32:42: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb2', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":42,"state":"OFF"}'

That was with a remote

Zigbee2MQTT:debug 2020-10-08 18:33:07: Received MQTT message on 'zigbee2mqtt/livingroom/floor_light/set/state' with data 'toggle'
Zigbee2MQTT:debug 2020-10-08 18:33:07: Publishing 'set' 'state' to 'livingroom/floor_light'
Zigbee2MQTT:debug 2020-10-08 18:33:07: Received Zigbee message from 'livingroom/floor_light/bulb1', type 'attributeReport', cluster 'genOnOff', data '{"onOff":1}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-10-08 18:33:07: Received Zigbee message from 'livingroom/floor_light/bulb2', type 'attributeReport', cluster 'genOnOff', data '{"onOff":1}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-10-08 18:33:07: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb1', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":42,"state":"OFF"}'
Zigbee2MQTT:info  2020-10-08 18:33:07: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"color_temp":555,"state":"OFF"}'
Zigbee2MQTT:info  2020-10-08 18:33:07: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb2', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":42,"state":"OFF"}'
Zigbee2MQTT:info  2020-10-08 18:33:09: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb1', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":42,"state":"OFF"}'
Zigbee2MQTT:info  2020-10-08 18:33:09: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb2', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":42,"state":"OFF"}'
Zigbee2MQTT:debug 2020-10-08 18:33:33: Received MQTT message on 'zigbee2mqtt/livingroom/floor_light/set/state' with data 'toggle'
Zigbee2MQTT:debug 2020-10-08 18:33:33: Publishing 'set' 'state' to 'livingroom/floor_light'
Zigbee2MQTT:debug 2020-10-08 18:33:33: Received Zigbee message from 'livingroom/floor_light/bulb1', type 'attributeReport', cluster 'genOnOff', data '{"onOff":0}' from endpoint 1 with groupID 0
Zigbee2MQTT:debug 2020-10-08 18:33:33: Received Zigbee message from 'livingroom/floor_light/bulb2', type 'attributeReport', cluster 'genOnOff', data '{"onOff":0}' from endpoint 1 with groupID 0
Zigbee2MQTT:info  2020-10-08 18:33:33: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb1', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":42,"state":"ON"}'
Zigbee2MQTT:info  2020-10-08 18:33:33: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"color_temp":555,"state":"ON"}'
Zigbee2MQTT:info  2020-10-08 18:33:33: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb2', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":42,"state":"ON"}'
Zigbee2MQTT:info  2020-10-08 18:33:35: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb1', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":42,"state":"ON"}'
Zigbee2MQTT:info  2020-10-08 18:33:35: MQTT publish: topic 'zigbee2mqtt/livingroom/floor_light/bulb2', payload '{"brightness":254,"color":{"hue":360,"saturation":100,"x":0.6986,"y":0.2995},"linkquality":42,"state":"ON"}'

And using mqtt...

Neither seem to be correct? The one only coming in via reporting still don't update the group topic, while they should (there is nothing optimistic or oportunistic about it)

Using mqtt... now gets an update... but the state is wrong? it is ON when it should be off and off when it should be on!

@Koenkk
Copy link
Owner Author

Koenkk commented Oct 8, 2020

Neither seem to be correct? The one only coming in via reporting still don't update the group topic, while they should (there is nothing optimistic or oportunistic about it)

When optimistic is used for groups, an attribute report won't update the group state (it's documented here: https://www.zigbee2mqtt.io/information/groups.html#state-changes). This was implemented because of #764 (comment) (I agree optimistic might be a confusing name for this option).

@sjorge
Copy link
Contributor

sjorge commented Oct 8, 2020

So there is no way to skip the update on set and only take reporting updates for groups?

@Koenkk
Copy link
Owner Author

Koenkk commented Oct 8, 2020

Currently not indeed and the existing optimistic option makes this a bit harder to add. This should be fixed in Zigbee2MQTT 2.0.0 for sure (making optimistic for devices and groups the same).

@sjorge
Copy link
Contributor

sjorge commented Oct 8, 2020

When this is revisited we should also fix debounce for groups, there is an issue for that too.

Do we have a list tracking these thing somewhere?

@Koenkk
Copy link
Owner Author

Koenkk commented Oct 8, 2020

We don't, but should do and tag this with 'breaking change'. About the debounce for groups, I don't think this is breaking, so this can be implemented in Zigbee2MQTT 1.x?

@sjorge
Copy link
Contributor

sjorge commented Oct 8, 2020

Yes, a tag would be nice... can we then also have the stalebot leave those alone? I assume those will be long lived.

#3461 is the debounce one, I had a brief looked but got super confused on how it works for devices.

@Koenkk
Copy link
Owner Author

Koenkk commented Oct 8, 2020

Done

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.

2 participants