### The problem
As I installed zigbee2mqtt on another machine (not addon) I mā¦ade a mistake with the frontend url field and did not put the URL in the correct format.
I put 192.168.1.15:8099 instead of http://192.168.1.15:8099
This must go wrong and that is not the issue. The issue is that when you restart Home Assistant with zigbee2mqtt discovery messages with this error, the entire MQTT integration crashes and restarts.
I am all OK with the zigbee2mqtt devices not working but also existing MQTT items will not work and I get errors in the log that the service mqtt.publish does not exist
The purpose of this bug report is to suggest that the code that parses the MQTT discovery messages and the JSON in them treat this as user data and handles errors or missing data by ignoring the input and issuing errors or warnings in the log. It should not crash the entire integration that a single discovery data message has some wrong data in it.
### What version of Home Assistant Core has the issue?
core-2023.06.1
### What was the last working version of Home Assistant Core?
_No response_
### What type of installation are you running?
Home Assistant OS
### Integration causing the issue
mqtt
### Link to integration documentation on our website
https://www.home-assistant.io/integrations/mqtt/
### Diagnostics information
_No response_
### Example YAML snippet
_No response_
### Anything in the logs that might be useful for us?
```
2023-06-12 18:08:38.323 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 798, in _async_process_discovery_update
await discovery_update(payload)
File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 1040, in discovery_update
config: DiscoveryInfoType = self.config_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/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: invalid url for dictionary value @ data['device']['configuration_url']
2023-06-12 18:08:38.339 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 798, in _async_process_discovery_update
await discovery_update(payload)
File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 1040, in discovery_update
config: DiscoveryInfoType = self.config_schema()(discovery_payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
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: invalid url for dictionary value @ data['device']['configuration_url']
2023-06-12 18:08:38.442 ERROR (MainThread) [homeassistant.util.logging] Exception in async_discover when dispatching 'mqtt_discovery_new_sensor_mqtt': ({'availability': [{'topic': 'zigbee2mqtt/bridge/state'}], 'device': {'configuration_url': '192.168.1.15:8099/#/device/0x00158d00068bbe99/info', 'identifiers': ['zigbee2mqtt_0x00158d00068bbe99'], 'manufacturer': 'Xiaomi', 'model': 'Aqara door & window contact sensor (MCCGQ11LM)', 'name': 'Test Aqara Door Sensor', 'sw_version': '3000-0001'}, 'device_class': 'voltage', 'enabled_by_default': False, 'entity_category': 'diagnostic', 'json_attributes_topic': 'zigbee2mqtt/Test Aqara Door Sensor', 'name': 'Test Aqara Door Sensor voltage', 'state_class': 'measurement', 'state_topic': 'zigbee2mqtt/Test Aqara Door Sensor', 'unique_id': '0x00158d00068bbe99_voltage_zigbee2mqtt', 'unit_of_measurement': 'mV', 'value_template': '{{ value_json.voltage }}', '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/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: invalid url for dictionary value @ data['device']['configuration_url']
2023-06-12 18:08:38.466 ERROR (MainThread) [homeassistant.util.logging] Exception in async_discover when dispatching 'mqtt_discovery_new_sensor_mqtt': ({'availability': [{'topic': 'zigbee2mqtt/bridge/state'}], 'device': {'configuration_url': '192.168.1.15:8099/#/device/0x00158d00068bbe99/info', 'identifiers': ['zigbee2mqtt_0x00158d00068bbe99'], 'manufacturer': 'Xiaomi', 'model': 'Aqara door & window contact sensor (MCCGQ11LM)', 'name': 'Test Aqara Door Sensor', 'sw_version': '3000-0001'}, 'enabled_by_default': False, 'entity_category': 'diagnostic', 'icon': 'mdi:signal', 'json_attributes_topic': 'zigbee2mqtt/Test Aqara Door Sensor', 'name': 'Test Aqara Door Sensor linkquality', 'state_class': 'measurement', 'state_topic': 'zigbee2mqtt/Test Aqara Door Sensor', 'unique_id': '0x00158d00068bbe99_linkquality_zigbee2mqtt', 'unit_of_measurement': 'lqi', 'value_template': '{{ value_json.linkquality }}', '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/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: invalid url for dictionary value @ data['device']['configuration_url']
2023-06-12 18:08:38.491 ERROR (MainThread) [homeassistant.util.logging] Exception in async_discover when dispatching 'mqtt_discovery_new_sensor_mqtt': ({'availability': [{'topic': 'zigbee2mqtt/bridge/state'}], 'device': {'configuration_url': '192.168.1.15:8099/#/device/0x00158d000232a0c5/info', 'identifiers': ['zigbee2mqtt_0x00158d000232a0c5'], 'manufacturer': 'Xiaomi', 'model': 'Aqara door & window contact sensor (MCCGQ11LM)', 'name': 'Bedroom Window', 'sw_version': '3000-0001'}, 'device_class': 'voltage', 'enabled_by_default': False, 'entity_category': 'diagnostic', 'json_attributes_topic': 'zigbee2mqtt/Bedroom Window', 'name': 'Bedroom Window voltage', 'state_class': 'measurement', 'state_topic': 'zigbee2mqtt/Bedroom Window', 'unique_id': '0x00158d000232a0c5_voltage_zigbee2mqtt', 'unit_of_measurement': 'mV', 'value_template': '{{ value_json.voltage }}', '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/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: invalid url for dictionary value @ data['device']['configuration_url']
```
And some sniplets that repeats more than 60 times
```
2023-06-12 18:08:39.247 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 798, in _async_process_discovery_update
await discovery_update(payload)
File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 1040, in discovery_update
config: DiscoveryInfoType = self.config_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/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: invalid url for dictionary value @ data['device']['configuration_url']
```
### Additional information
To get the error
I altered the url to wrong format
Restarted HA
Restarted Zigbee2mqtt which makes it resend discovery
Errors comes right away