Publish a switch entity from zigbee.mqtt only if the update includes its state

This commit is contained in:
Fabio Manganiello 2022-04-12 14:41:21 +02:00
parent 20530c2b6d
commit 548d487e73
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -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,
}