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

Library appends to payload previous messages instead of sending just what is received. #32

Closed
ciotlosm opened this issue May 10, 2018 · 5 comments

Comments

@ciotlosm
Copy link
Contributor

ciotlosm commented May 10, 2018

Messages get merged on subsequent calls from same device. This is more of a problem for example on Xiaomi Cube where you can have rotate with two parameters (action and direction) vs normal actions where you have only one.

Update: I've noticed the action was moved to rotate_left/ rotate_right which makes more sense, but I do think that messages on MQTT should match what is received from device and not combine messages unless we always send all attributes.

Actual

2018-5-7 22:57:20 INFO MQTT publish, topic: 'zigbee2mqtt/0x00158d0001fa5c9d', payload: '{"temperature":26.86}'
2018-5-7 22:57:20 INFO MQTT publish, topic: 'zigbee2mqtt/0x00158d0001fa5c9d', payload: '{"temperature":26.86,"humidity":36.63}'
2018-5-7 22:57:20 INFO MQTT publish, topic: 'zigbee2mqtt/0x00158d0001fa5c9d', payload: '{"temperature":26.86,"humidity":36.63,"pressure":970}'

Expected:

2018-5-7 22:57:20 INFO MQTT publish, topic: 'zigbee2mqtt/0x00158d0001fa5c9d', payload: '{"temperature":26.86}'
2018-5-7 22:57:20 INFO MQTT publish, topic: 'zigbee2mqtt/0x00158d0001fa5c9d', payload: '{"humidity":36.63}'
2018-5-7 22:57:20 INFO MQTT publish, topic: 'zigbee2mqtt/0x00158d0001fa5c9d', payload: '{"pressure":970}'
@ciotlosm ciotlosm changed the title [Bug] Library appends to payload previous messages instead of sending just what is received. Library appends to payload previous messages instead of sending just what is received. May 10, 2018
@Koenkk
Copy link
Owner

Koenkk commented May 11, 2018

This is done on purpose because home assistant requires all sensor values when it receives a message on a topic.

In the case of:

2018-5-7 22:57:20 INFO MQTT publish, topic: 'zigbee2mqtt/0x00158d0001fa5c9d', payload: '{"temperature":26.86}'
2018-5-7 22:57:20 INFO MQTT publish, topic: 'zigbee2mqtt/0x00158d0001fa5c9d', payload: '{"humidity":36.63}'
2018-5-7 22:57:20 INFO MQTT publish, topic: 'zigbee2mqtt/0x00158d0001fa5c9d', payload: '{"pressure":970}'

The temperature and humidity sensor value would be null.

@ciotlosm
Copy link
Contributor Author

You have different sensors defined in home assistant for temperature/ humidity and air pressure. You can define them with separate messages. I think the only advantage would have been battery.

For now this is not that big issue but will be for cube, once you have two parameters (angle number on rotate).

@Koenkk
Copy link
Owner

Koenkk commented May 11, 2018

Separate messages don't solve the problem, this can only be solved by using separate topics. (e.g. zigbee2mqtt/0x00158d0001fa5c9d/temperature, this however would be inconsistent with https://www.home-assistant.io/components/light.mqtt_json/ which is used for all lights. (this requires one topic per light).

Therefore I would prefer to set an attribute on the converter or the device to not cache this message. (e.g. cache: false)

@ciotlosm
Copy link
Contributor Author

Thank we can close this issue and raise one separate only for the cube when analog angles will be required to be sent with the action.

@Koenkk
Copy link
Owner

Koenkk commented May 11, 2018

The disableCache option has been added which disabled caching for certain converters. So in the future we can safely add the cube angles for the MFKZQ01LM

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

No branches or pull requests

2 participants