core: MQTT integration reload fails for entities with new syntax.
The problem
Upon homeassistant start all my manually configured mqtt entities work properly. Both old syntax and new. However if I reload mqtt integration the frontend throws an error. The entities I converted to the new syntax disappear, but the rest of the manually configured mqtt entities with the old syntax reload.
I doesn’t matter if I reload the MQTT service via Developer Tools->YAML or manually via a service call the results are the same.
The MQTT sensors created with the old syntax (approximately 80 of them) are loaded via the package system. One entity with the new syntax is in configuration.yaml
, the other is placed in a package file.
MQTT device auto discovery is disabled in the integration configuration.
What version of Home Assistant Core has the issue?
core-2022.6.1
What was the last working version of Home Assistant Core?
core-2022.5.6
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
homeassistant:
name: Home
legacy_templates: false
latitude: #REDACTED
longitude: #REDACTED
elevation: 187
unit_system: imperial
time_zone: #REDACTED
auth_providers:
- type: homeassistant
customize: !include customize.yaml
packages: !include_dir_named packages.d/
mqtt:
camera:
- topic: camera/livingroom/jpeg
name: Living Room
A mqtt sensor with new syntax in a package.
mqtt:
sensor:
- state_topic: "nws/avgtemp"
name: Outdoor Average Temperature
value_template: "{{value_json.nws_temp.average|round(0,default='unavailable')}}"
unit_of_measurement: "°F"
json_attributes_topic: "nws/avgtemp"
json_attributes_template: '{{ value_json.nws_temp | tojson}}'
Anything in the logs that might be useful for us?
2022-06-04 09:00:05 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139722587399216] async_setup needs to be called first
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 193, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1704, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1741, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 750, in admin_handler
await result
File "/usr/src/homeassistant/homeassistant/helpers/reload.py", line 175, in _reload_config
await async_reload_integration_platforms(hass, domain, platforms)
File "/usr/src/homeassistant/homeassistant/helpers/reload.py", line 52, in async_reload_integration_platforms
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/reload.py", line 105, in _resetup_platform
await _async_setup_platform(
File "/usr/src/homeassistant/homeassistant/helpers/reload.py", line 128, in _async_setup_platform
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 218, in async_setup_platform
raise RuntimeError("async_setup needs to be called first")
RuntimeError: async_setup needs to be called first
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 29 (9 by maintainers)
I think I this is related to my issue. Some of my MQTT entities do not work when using the new syntax but do work with the old. Example code (all the problem entities are similar to this):
This works
This doesn’t work
I only have 2 types of sensor using MQTT: Shelly H&T don’t work with new syntax, Shelly Motion do work with new syntax.
I am trying to change the device trackers to the new format.
And guess what. That creates new duplicate device trackers, And there is no UI possibility to delete an entity that once has been defined in the mqtt integration. I have to hack the files in .storage once again to delete items from Home Assistant. The UI disables anything including deletion if there is no unique ID and you cannot add a unique ID to something that is not there. It is hopeless