Make sure that there is always an update_available value for Home Assistant. https://github.com/Koenkk/zigbee2mqtt/issues/3146

This commit is contained in:
Koen Kanters committed 2020-03-20 17:50:28 +01:00
1 parent ac8a84feb2
commit a30abba973
2 files changed
+12 -2

No files matched your search

+10
View File
@@ -1424,6 +1424,16 @@ class HomeAssistant extends BaseExtension {
await this.mqtt.publish(`${data.entity.name}/${key}`, value, {});
}
/**
* Publish a value for update_available (if not there yet) to prevent Home Assistant generating warnings of
* this value not being available.
*/
if (data.entity.device && data.entity.mapped && data.entity.mapped.hasOwnProperty('ota') &&
!data.payload.hasOwnProperty('update_available')) {
logger.debug(`Mocking update_available value for Home Assistant`);
this.publishEntityState(data.entity.device.ieeeAddr, {update_available: false});
}
}
onDeviceRenamed(device) {
+2 -2
View File
@@ -564,13 +564,13 @@ describe('HomeAssistant extension', () => {
await flushPromises();
expect(MQTT.publish).toHaveBeenCalledWith(
'zigbee2mqtt/bulb',
'{"state":"ON","brightness":50,"color_temp":370,"linkquality":99}',
'{"state":"ON","brightness":50,"color_temp":370,"linkquality":99,"update_available":false}',
{ retain: true, qos: 0 },
expect.any(Function)
);
expect(MQTT.publish).toHaveBeenCalledWith(
'zigbee2mqtt/remote',
'{"brightness":255}',
'{"brightness":255,"update_available":false}',
{ retain: true, qos: 0 },
expect.any(Function)
);