zigbee2mqtt / hassio-zigbee2mqtt

Official Zigbee2MQTT Home Assistant add-on
https://www.zigbee2mqtt.io
Apache License 2.0
1.02k stars 369 forks source link

Invalid JSON sent in homeassistant.components.mqtt.discovery discovery message for Sonoff ZBMINI #527

Closed marcok closed 7 months ago

marcok commented 8 months ago

Description of the issue

If I pair ZBMINI the discovery message has an invalid JSON. It contains the key 'name' with null which then crashes in HA.

I'm using home assistant with zigbee2mqtt and MQTT.

After removing "'name': None," from the message and manually push it into topic, all worked and the device appears. After that, the error appears again on HA restart.

Addon version

1.33.1-1

Platform

Home Assistant 2023.7.2 Supervisor 2023.10.1 Operating System 10.5 Frontend 20230705.1 - latest

Logs of the issue (if applicable)

Logger: homeassistant.components.mqtt.discovery Source: components/mqtt/discovery.py:134 Integration: MQTT (documentation, issues) First occurred: 2:02:00 PM (2 occurrences) Last logged: 2:02:50 PM

Error 'string value is None for dictionary value @ data['name']' when processing MQTT discovery message topic:

'homeassistant/switch/0xe0798dfffea7c6c0/switch/config', message: '{'availability': [{'topic': 'zigbee2mqtt/bridge/state', 'value_template': '{{ value_json.state }}'}], 'command_topic': 'zigbee2mqtt/f1_switch_floor_heating/set', 'device': {'identifiers': ['zigbee2mqtt_0xe0798dfffea7c6c0'], 'manufacturer': 'SONOFF', 'model': 'Zigbee two way smart switch (ZBMINI)', 'name': 'f1_switch_floor_heating'}, 'json_attributes_topic': 'zigbee2mqtt/f1_switch_floor_heating', 'name': None, 'object_id': 'f1_switch_floor_heating', 'origin': {'name': 'Zigbee2MQTT', 'sw': '1.33.1', 'url': 'https://www.zigbee2mqtt.io'}, 'payload_off': 'OFF', 'payload_on': 'ON', 'state_topic': 'zigbee2mqtt/f1_switch_floor_heating', 'unique_id': '0xe0798dfffea7c6c0_switch_zigbee2mqtt', 'value_template': '{{ value_json.state }}', 'platform': 'mqtt'}'

ancientskyscraper commented 8 months ago

I'm getting the same issue when trying to pair a Philips Hue white ambiance E26 1600lm with Bluetooth (929002335105).

(Note: I am not using HASSIO, but I see you closed the issue on the zigbee2mqtt repo, so I figured I would reply here instead.)

Platform

Home Assistant 2023.6.2 Frontend 20230608.0 - latest

Log of the issue

2023-11-10 12:21:07.535 ERROR (MainThread) [homeassistant.util.logging] Exception in async_discover when dispatching 'mqtt_discovery_new_light_mqtt': ({'availability': [{'topic': 'zigbee2mqtt/bridge/state', 'value_template': '{{ value_json.state }}'}], 'brightness': True, 'brightness_scale': 254, 'color_mode': True, 'command_topic': 'zigbee2mqtt/Floor lamp bulb/set', 'device': {'configuration_url': 'http://<REDACTED>:8080/#/device/<REDACTED>/info', 'identifiers': ['zigbee2mqtt_<REDACTED>'], 'manufacturer': 'Philips', 'model': 'Hue white ambiance E26 1600lm with Bluetooth (929002335105)', 'name': 'Floor lamp bulb', 'sw_version': '1.104.2'}, 'effect': True, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'candle', 'finish_effect', 'stop_effect', 'stop_hue_effect'], 'max_mireds': 454, 'min_mireds': 153, 'name': None, 'object_id': 'floor_lamp_bulb', 'origin': {'name': 'Zigbee2MQTT', 'sw': '1.33.2', 'url': 'https://www.zigbee2mqtt.io'}, 'schema': 'json', 'state_topic': 'zigbee2mqtt/Floor lamp bulb', 'supported_color_modes': ['color_temp'], 'unique_id': '<REDACTED>_light_zigbee2mqtt', 'platform': 'mqtt'},)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 270, in async_discover
    config: DiscoveryInfoType = discovery_schema(discovery_payload)
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/validators.py", line 232, in __call__
    return self._exec((Schema(val) for val in self.validators), v)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/validators.py", line 355, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.11/site-packages/voluptuous/validators.py", line 351, in _exec
    v = func(v)
        ^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
    return schema(data)
           ^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/mqtt/light/__init__.py", line 41, in validate_mqtt_light_discovery
    config: ConfigType = schemas[config_value[CONF_SCHEMA]](config_value)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/validators.py", line 232, in __call__
    return self._exec((Schema(val) for val in self.validators), v)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/validators.py", line 355, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.11/site-packages/voluptuous/validators.py", line 351, in _exec
    v = func(v)
        ^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
    return schema(data)
           ^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
    return base_validate(path, iteritems(data), out)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/voluptuous/schema_builder.py", line 433, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: string value is None for dictionary value @ data['name']
marcok commented 7 months ago

after update to new version of HA and z2h all works fine