home-assistant/core

Exception in async_discover

yolkhovyy opened this issue · 19 comments

Screenshot_2024-10-19-22-01-53-512_io homeassistant companion android-edit

The problem

All devices on zigbee2mqtt are gone, see the screenshot.

Log, when renaming a device in zigbee2mqtt (1.40.2):

2024-10-19 19:37:58.251 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'value_json' is undefined when rendering '{{ value_json.power_on_behavior }}'
2024-10-19 19:37:58.263 ERROR (MainThread) [homeassistant.helpers.template] Error parsing value: 'value_json' is undefined (value: , template: {{ value_json.power_on_behavior }})
2024-10-19 19:37:58.267 ERROR (MainThread) [homeassistant.components.mqtt.select] Invalid option for select.bedroom_ceiling_lamp_power_on_behavior: '' (valid options: ['off', 'on', 'toggle', 'previous'])
2024-10-19 19:37:58.602 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'value_json' is undefined when rendering '{{ value_json.state }}'
2024-10-19 19:37:58.606 ERROR (MainThread) [homeassistant.helpers.template] Error parsing value: 'value_json' is undefined (value: , template: {{ value_json.state }})
2024-10-19 19:38:00.656 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 }}'}, {'topic': 'zigbee2mqtt/bedroom_ceiling/availability', 'value_template': '{{ value_json.state }}'}], 'availability_mode': 'all', 'brightness': True, 'brightness_scale': 254, 'command_topic': 'zigbee2mqtt/bedroom_ceiling/set', 'device': {'identifiers': ['zigbee2mqtt_0x*************'], 'manufacturer': 'Philips', 'model': 'Hue white A60 bulb E27 bluetooth (**********)', 'name': 'bedroom_ceiling', 'sw_version': '1.116.5', 'via_device': 'zigbee2mqtt_bridge_0x***************'}, 'effect': True, 'effect_list': ['blink', 'breathe', 'okay', 'channel_change', 'candle', 'finish_effect', 'stop_effect', 'stop_hue_effect'], 'name': None, 'object_id': 'bedroom_ceiling', 'origin': {'name': 'Zigbee2MQTT', 'sw': '1.40.2', 'url': 'https://www.zigbee2mqtt.io'}, 'schema': 'json', 'state_topic': 'zigbee2mqtt/bedroom_ceiling', 'unique_id': '0x************_light_zigbee2mqtt', 'platform': 'mqtt'},)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 328, in async_discover
    config: DiscoveryInfoType = discovery_schema(discovery_payload)
  File "/usr/local/lib/python3.10/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.10/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.10/site-packages/voluptuous/validators.py", line 351, in _exec
    v = func(v)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.10/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 44, in validate_mqtt_light_discovery
    config: ConfigType = schemas[config_value[CONF_SCHEMA]](config_value)
  File "/usr/local/lib/python3.10/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.10/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.10/site-packages/voluptuous/validators.py", line 351, in _exec
    v = func(v)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
    return schema(data)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.10/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']

2024-10-19 19:38:00.724 ERROR (MainThread) [homeassistant.util.logging] Exception in async_discover when dispatching 'mqtt_discovery_new_binary_sensor_mqtt': ({'availability': [{'topic': 'zigbee2mqtt/bridge/state', 'value_template': '{{ value_json.state }}'}, {'topic': 'zigbee2mqtt/bedroom_ceiling/availability', 'value_template': '{{ value_json.state }}'}], 'availability_mode': 'all', 'device': {'identifiers': ['zigbee2mqtt_0x***********'], 'manufacturer': 'Philips', 'model': 'Hue white A60 bulb E27 bluetooth (****************)', 'name': 'bedroom_ceiling', 'sw_version': '1.116.5', 'via_device': 'zigbee2mqtt_bridge_0x*************'}, 'device_class': 'update', 'enabled_by_default': False, 'entity_category': 'diagnostic', 'name': None, 'object_id': 'bedroom_ceiling_update_available', 'origin': {'name': 'Zigbee2MQTT', 'sw': '1.40.2', 'url': 'https://www.zigbee2mqtt.io'}, 'payload_off': False, 'payload_on': True, 'state_topic': 'zigbee2mqtt/bedroom_ceiling', 'unique_id': '0x************_update_available_zigbee2mqtt', 'value_template': '{{ value_json[\'update\'][\'state\'] == "available" }}', 'platform': 'mqtt'},)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 328, in async_discover
    config: DiscoveryInfoType = discovery_schema(discovery_payload)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.10/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']

2024-10-19 19:38:00.753 ERROR (MainThread) [homeassistant.util.logging] Exception in async_discover when dispatching 'mqtt_discovery_new_update_mqtt': ({'availability': [{'topic': 'zigbee2mqtt/bridge/state', 'value_template': '{{ value_json.state }}'}, {'topic': 'zigbee2mqtt/bedroom_ceiling/availability', 'value_template': '{{ value_json.state }}'}], 'availability_mode': 'all', 'command_topic': 'zigbee2mqtt/bridge/request/device/ota_update/update', 'device': {'identifiers': ['zigbee2mqtt_0x************'], 'manufacturer': 'Philips', 'model': 'Hue white A60 bulb E27 bluetooth (***********)', 'name': 'bedroom_ceiling', 'sw_version': '1.116.5', 'via_device': 'zigbee2mqtt_bridge_0x************'}, 'device_class': 'firmware', 'entity_category': 'config', 'entity_picture': 'https://github.com/Koenkk/zigbee2mqtt/raw/master/images/logo.png', 'json_attributes_template': '{"in_progress": {{ iif(value_json[\'update\'][\'state\'] == \'updating\', \'true\', \'false\') }} }', 'json_attributes_topic': 'zigbee2mqtt/bedroom_ceiling', 'latest_version_template': "{{ value_json['update']['latest_version'] }}", 'latest_version_topic': 'zigbee2mqtt/bedroom_ceiling', 'name': None, 'object_id': 'bedroom_ceiling', 'origin': {'name': 'Zigbee2MQTT', 'sw': '1.40.2', 'url': 'https://www.zigbee2mqtt.io'}, 'payload_install': '{"id": "0x**************"}', 'state_topic': 'zigbee2mqtt/bedroom_ceiling', 'unique_id': '0x**************_update_zigbee2mqtt', 'value_template': "{{ value_json['update']['installed_version'] }}", 'platform': 'mqtt'},)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 328, in async_discover
    config: DiscoveryInfoType = discovery_schema(discovery_payload)
  File "/usr/local/lib/python3.10/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.10/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.10/site-packages/voluptuous/validators.py", line 351, in _exec
    v = func(v)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable
    return schema(data)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in __call__
    return self._compiled([], data)
  File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict
    return base_validate(path, iteritems(data), out)
  File "/usr/local/lib/python3.10/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']

What version of Home Assistant Core has the issue?

core-2024.10.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

MQTT

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

All devices on zigbee2mqtt are gone, reinstalling MQTT integration did not help

Hi @yolkhovyy
zigbee2mqtt is a custom component, which is not maintained by the HA core project. Please report your issue to the maintainer or in the source repository of this custom component.
Thx 👍

All devices on zigbee2mqtt are gone, see the screenshot.

What version of Home Assistant Core has the issue?
core-2024.10.3

What was the last working version of Home Assistant Core?
No response

based on this, i've to guess that you did not have updated HA right before the issue happens, therefore it is most likely an issue elsewhere, which causes these issues.

It was 2022-something

do you really mean an 2 years older release?

If I try 2022 again - the same exception

so maybe the issue is not home-assistant caused?

Sure, this is an exception, which is raised by HA, but you are using a custom component zigbee2mqtt which sends data trough the mqtt integration into HA - so if these data has changed or are malformed or what else, it might cause HA to raise this exceptions. Based on the error message string value is None for dictionary value @ data['name'] i strongly guess, these send data are malformed or incomplete.
Since we still did not finally clarify, if this behavior is directly related to any HA core update or an update of this custom component, everything here is just guessing, which is not conducive.

I tried older versions of zigbee2mqtt, all the way to 1.30.2 - the same exception

ok, so the issue is not related to an HA core update?

hings broke when I enabled one of hidden entities in a ZigBee device.

please elaborate this much more detailed - what device exactly?

at the moment, i'm still on the point as already stated in #128802 (comment) - you've to report this issue to the maintainers/project/repository of zigbee2mqtt

also observing the messages in the HA log:

2024-10-19 23:40:46.391 DEBUG (MainThread)
[homeassistant.components.mqtt.client] Received message on
zigbee2mqtt/bedroom_ceiling:
b'{"brightness":140,"linkquality":112,"power_on_behavior":null,"state":"ON","update":{"installed_version":16786438,"latest_version":16786438,"state":"idle"},"update_available":null}'
2024-10-19 23:40:46.391 DEBUG (MainThread)
[homeassistant.components.mqtt.models] Rendering incoming payload
'{"brightness":140,"linkquality":112,"power_on_behavior":null,"state":"ON","update":{"installed_version":16786438,"latest_version":16786438,"state":"idle"},"update_available":null}'
with variables {'entity_id': 'select.bedroom_ceiling_power_on_behavior',
'name': 'Power-on behavior', 'this': <template
TemplateStateFromEntityId(select.bedroom_ceiling_power_on_behavior)>} and
Template("{{ value_json.power_on_behavior }}")

On Sun, Oct 20, 2024 at 1:35 AM Yuriy Olkhovyy @.***>
wrote:

sorry, I do not see anything that could be reported to zigbee2mqtt, do you
see anything?

$ mosquitto_sub -h x.x.x.x -p 1883 -t zigbee2mqtt/bedroom_ceiling

{"brightness":140,"linkquality":109,"power_on_behavior":null,"state":"OFF","update":{"installed_version":16786438,"latest_version":16786438,"state":"idle"},"update_available":null}

On Sun, Oct 20, 2024 at 12:48 AM Yuriy Olkhovyy @.***>
wrote:

If this helps, please see attachment

On Sun, Oct 20, 2024, 00:41 Yuriy Olkhovyy @.***>
wrote:

could you please elaborate what issue is supposed to be reported to
zigbee2mqtt?

On Sun, Oct 20, 2024, 00:28 Michael @.***> wrote:

at the moment, i'm still on the point as already stated in #128802
(comment)
#128802 (comment)

  • you've to report this issue to the maintainers/project/repository of
    zigbee2mqtt


Reply to this email directly, view it on GitHub
#128802 (comment),
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACHUR5CWOSP62HRT5X5UJ4TZ4LMHBAVCNFSM6AAAAABQHYSJTSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIMRUGI2DONZYHA
.
You are receiving this because you were mentioned.Message ID:
@.***>

There ist no error.