From 548d487e73c7f1054f42f744d225ed7cc6eb4742 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Tue, 12 Apr 2022 14:41:21 +0200 Subject: [PATCH] Publish a switch entity from zigbee.mqtt only if the update includes its state --- platypush/plugins/zigbee/mqtt/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platypush/plugins/zigbee/mqtt/__init__.py b/platypush/plugins/zigbee/mqtt/__init__.py index 9b5636aaa..0aa8f2af5 100644 --- a/platypush/plugins/zigbee/mqtt/__init__.py +++ b/platypush/plugins/zigbee/mqtt/__init__.py @@ -182,7 +182,7 @@ class ZigbeeMqttPlugin(MqttPlugin, SwitchPlugin): # lgtm [py/missing-call-to-in } switch_info = self._get_switch_meta(dev) - if switch_info: + if switch_info and dev.get('state', {}).get('state') is not None: converted_entity = Switch( id=dev['ieee_address'], name=dev.get('friendly_name'), @@ -722,9 +722,9 @@ class ZigbeeMqttPlugin(MqttPlugin, SwitchPlugin): # lgtm [py/missing-call-to-in ).output if device_info: - self.publish_entities( + self.publish_entities( # type: ignore [ - { # type: ignore + { **device_info, 'state': device_state, }