Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.71k stars 1.64k forks source link

ptvo_switch_uart value ep1 published in all messages #3320

Closed pdeprost closed 4 years ago

pdeprost commented 4 years ago

Hello,

First of all thanks for the new UART support of PTVO router.

How to adapt the converter fromZigbee.js to avoid the last UART message to be repeated in the next MQTT messages (I need it only once, when received by the CC2530 serial port)

 ptvo_switch_uart: {
     cluster: 'genMultistateValue',
     type: ['attributeReport', 'readResponse'],
     convert: (model, msg, publish, options, meta) => {
          return {'ep1': msg.data['stateText']};
     },
},

Thank you!

Regards,

Pierre.

Koenkk commented 4 years ago

@ptvoinfo could you help with this?

ptvoinfo commented 4 years ago

@pdeprost, @Koenkk I don't know how to disable saving of the last state for a single value if the "cache_state" configuration option is active in "configuration.yaml" in zigbee2mqtt.

pdeprost commented 4 years ago

@Koenkk @ptvoinfo Yes but, if ep1 is managed like an 'input' button? example "click":"bottom_left_double" appears only once in the message (when the button is fired).

ptvoinfo commented 4 years ago

@pdeprost Yes, "click" is marked as "do not cache". But it is not possible to do the same for a custom value.

pdeprost commented 4 years ago

@Koenkk @ptvoinfo Ok, Thank you. So I will add an incremental index number to the serial data to be able to distinguish a new message form the older repeated from the cache. Another question: How to send data from Z2M to CC2530 UART's output

ptvoinfo commented 4 years ago

@Koenkk Could I ask to add a feature to ignore caching for a single value for an individual device? Somehow, specify it in the returned response.

pdeprost commented 4 years ago

I find this a great idea!

Another question: How to send data from Z2M to CC2530 UART's output? mqtt topic "zigbee2mqtt/..../ep1/set" isn't working.

ptvoinfo commented 4 years ago

@pdeprost zigbee2mqtt/[FRIENDLY_NAME]/set/ep1

Koenkk commented 4 years ago

I think the code should be changed form return {'ep1': msg.data['stateText']}; to return {'action': msg.data['stateText']};. This will prevent the message from being cached.

pdeprost commented 4 years ago

Nice! It's working correctly! and to keep compatibility I changed it to : return {'ep1': msg.data['stateText'], 'action': msg.data['stateText']}; Thank you

Koenkk commented 4 years ago

@ptvoinfo what do you think, does it make sense?

ptvoinfo commented 4 years ago

@Koenkk It is applicable in this particular case. But the meaning of the value is confusing.

Koenkk commented 4 years ago

I wil close this as the pull request has been merged. Thanks!

pdeprost commented 4 years ago

Thanks !