Closed danielbrunt57 closed 4 months ago
Adding to this - there is a lot of confusion around mqtt_room (well from ESPresense).
ESPresense 3.X uses a different topic (which will be deprecated in v4)
espresense/devices/deviceid
as shown in the MQTT_ROOM documentation @danielbrunt57 that might help? but also the below may not?
However - MQTT explorer shows MQTT topic is being populated:
espresense/devices/deviceid/roomname
with data
{"mac":"xxxxxxxxx","id":"watchultra2","name":"WatchUltra2","idType":250,"rssi@1m":-65,"rssi":-73,"raw":1.69,"distance":2.07,"var":0.37,"int":501}
There is something (i'm not skilled enough to identify what) where MQTT_ROOM is not picking up the new MQTT Topic structure properly. https://github.com/ESPresense/ESPresense/issues/1142
The new MQTT Topic structure might not the issue behind that. From what I can observe, all devices themself are recognized accordingly, if they are the only devices in the system. Or in other words: only the first device is recognized and initialized by mqtt_room integration. In my system, I have two mqtt_room sensors, one is Pixel Watch, the other Pixel 7. Within my configuration / package structure, the pixel 7 one was the first sensor in the list, Pixel Watch the last/second. Therefore, Pixel Watch was not recognized anymore since 2024.06 Update of Home Assistant. Changing the order in the pacakge structure or simply disabling the Pixel 7 sensor will let the other one (Pixel Watch) appear. Activating again the alphabetically first sensor (Pixel 7) will let the Pixel watch disappear.
The message "Setup of sensor platform mqtt_room is taking over 10 seconds." only appears in the logs, if there are more than one sensor active configured.
So in my opinion, it's not the case, that something witihin the topic structure will cause the behaviour but somethin else.
For a workaround I also tried adding a dummy-sensor at the end of my configuration, starting with "z-..." and using a dummy beacon / device-id. But after it seems to work, it doesn't either.
I'm seeing these error messages in HA log after restart:
Logger: homeassistant.components.mqtt_room.sensor
Source: components/mqtt_room/sensor.py:85
integration: mqtt_room (documentation, issues)
First occurred: 3:54:47 AM (4 occurrences)
Last logged: 3:54:47 AM
MQTT integration is not available
2024-06-20 03:54:47.756 ERROR (MainThread) [homeassistant.components.mqtt_room.sensor] MQTT integration is not available
2024-06-20 03:54:47.757 ERROR (MainThread) [homeassistant.components.mqtt_room.sensor] MQTT integration is not available
2024-06-20 03:54:47.757 ERROR (MainThread) [homeassistant.components.mqtt_room.sensor] MQTT integration is not available
2024-06-20 03:54:47.757 ERROR (MainThread) [homeassistant.components.mqtt_room.sensor] MQTT integration is not available
I also noticed these messages. First thought that they had to do with my dummy test sensor. But as you mentioned you getting the same, I removed the dummy sensor and still seeing this message. But I got only one (because I only have 2 mqtt_room sensors in total). The behaviour might have changed within the last Core Update (2024.6.3), because I'm 100% sure, that at first, there were only the messages "taking over 10 secs".
How many mqtt_room sensors you have in total? I'm wondering, because your config example shows 4 but also you have 4 ERRORs "MQTT is not available" Therefore, I would expect you have 5 sensors in total?
When I posted, I had 4 and 3 were not working and there were 3 MQTT error messages. That was HA 2024.6.3. I restored HA 2024.6.2 during troubleshooting the alexa media player initialization issues which restored my sensors file with 5 mqtt_room sensors and now have 4 MQTT error messages. Clear as mud???
The errors are emanating from here in mqtt_room/sensor,py on all config entries after the first one:
I modified the code and commented out the if not await...
section, restarted HA and all 5 sensors initialized!
I used Portainer to go into the homeassitant container and the mqtt_room sensor.py file is here; homeassistant:/usr/src/homeassistant/homeassistant/components/mqtt_room
#
I edited sensor.py and commented out the three lines that generate the MQTT error:
async def async_setup_platform(
hass: HomeAssistant,
config: ConfigType,
async_add_entities: AddEntitiesCallback,
discovery_info: DiscoveryInfoType | None = None,
) -> None:
"""Set up MQTT room Sensor."""
# Make sure MQTT integration is enabled and the client is available
# We cannot count on dependencies as the sensor platform setup
# also will be triggered when mqtt is loading the `sensor` platform
# if not await mqtt.async_wait_for_mqtt_client(hass):
# _LOGGER.error("MQTT integration is not available")
# return
async_add_entities(
[
MQTTRoomSensor(
config.get(CONF_NAME),
config[CONF_STATE_TOPIC],
config[CONF_DEVICE_ID],
config[CONF_TIMEOUT],
config[CONF_AWAY_TIMEOUT],
config.get(CONF_UNIQUE_ID),
)
]
)
Well, that did not fix the issue, it only masked it as the mqtt_room sensors looked okay but they were totally not working as they all showed as not_home
.
After digging further I came up with this workaround instead of my edit to sensor.py
:
In manifest.json
, I added "hacs" to dependencies:
"domain": "mqtt_room",
"name": "MQTT Room Presence",
"codeowners": [],
"dependencies": ["mqtt","hacs"],
"documentation": "https://www.home-assistant.io/integrations/mqtt_room",
"iot_class": "local_push"
}
All 5 of my sensors are now working:
I'm not sure how regularly this is being maintained. It's such a cool project and with the floor plan stuff too. If the HA team took this under their wing it could very well be a staple of HA for "in house positioning" - plus it includes Apple device tracking too
I'm not sure how regularly this is being maintained.
It would be nice to see this issue looked at and fixed so I do not have to re-edit the manifest.json
after every HA update.
It would also be nice to see it migrated from YAML config setup to Config Flow UI based
I can confirm, that the workaround does the thing and brings up all the sensors again. :-) So it's a starting order thing, where beeing dependend from HACS might not be the best way. Hope anybody finds some time to identify the right dependency.
@danielbrunt57: Thanks for your investigations and sharing the workaround.
I am now on core-2024.7.0 and mqtt_room is working fine now without needing the hacs
dependency in manifest.json
.
@itchensen, @jaburges what are you seeing?
It does take its sweet time loading though...
I "sadly" had to redo the manifest manipulation. After updating I was directly prompted with a corresponding repair issue. But again, with adding the dependency, it works like a charme.
I believe HA has been playing around a lot in the last while with improving startup times, likely by parallelizing internal things and there's been strange fallout as a result that I'm seeing but that's just my S W A G! I do not know why you still need the dependency and I now do not......
I am going to have a crack at rewriting the integration but it may take me quite a while to arrive at submitting a PR to HA. I know some python but day by day I learn more and more. I'm just quite busy lately trying to earn enough money to keep my chequing account on the plus side...
This is no longer an issue as of HA 2024.7.x
HA Core 2024.7.2 and I am still seeing the same behavior where only the first sensor in yaml shows, all others are unavailable. This is with or without 'hacs" dependency added to manifest.json.
HA Core 2024.7.2 and I am still seeing the same behavior where only the first sensor in yaml shows, all others are unavailable. This is with or without 'hacs" dependency added to manifest.json.
I'm sorry as I do not have the answer. For me, the issue is no longer an issue for whatever reason, and no one from HA Dev has looked at this...
The problem
The mqtt_room integration is only loading the first entity defined in yaml.
I proved it by editing my configuration and defining another entity first and that one is now available and the remainder are either not present or show as no longer provided (and can be deleted).
What version of Home Assistant Core has the issue?
core-2024.6.3
What was the last working version of Home Assistant Core?
core-2024.6.2
What type of installation are you running?
Home Assistant OS
Integration causing the issue
mqtt_room
Link to integration documentation on our website
https://www.home-assistant.io/integrations/mqtt_room/
Diagnostics information
(n/a)
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information