Coder Social home page Coder Social logo

Comments (9)

home-assistant avatar home-assistant commented on June 30, 2024

mqtt_room documentation
mqtt_room source

from core.

jaburges avatar jaburges commented on June 30, 2024

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.
ESPresense/ESPresense#1142

from core.

itchensen avatar itchensen commented on June 30, 2024

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.

from core.

danielbrunt57 avatar danielbrunt57 commented on June 30, 2024

I think my issue might be different as evidenced by 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

from core.

itchensen avatar itchensen commented on June 30, 2024

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?

from core.

danielbrunt57 avatar danielbrunt57 commented on June 30, 2024

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???

image

from core.

danielbrunt57 avatar danielbrunt57 commented on June 30, 2024

The errors are emanating from here in mqtt_room/sensor,py on all config entries after the first one:

image

from core.

danielbrunt57 avatar danielbrunt57 commented on June 30, 2024

So, I hacked the code and commented out the if not await... section, restarted HA and all 5 sensors initialized!

image

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),         
            )                                                        
        ]                                                             
    ) 

Something is seriously not right in the code logic now!

This component needs to be migrated to a config_flow setup!

It's 6:25 am here and I'm going to bed...

from core.

danielbrunt57 avatar danielbrunt57 commented on June 30, 2024

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. So, after digging further I came up with this workaround instead of my edit to sensor.py:
In manifest.json, add "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:

image

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.