RPi-Reporter-MQTT2HA-Daemon icon indicating copy to clipboard operation
RPi-Reporter-MQTT2HA-Daemon copied to clipboard

Devices not shown in home assistant

Open sfbuch opened this issue 4 years ago • 10 comments

i run hassio on a raspberry pi. on two other rpis i installed rpi-reporter (IP numbers ....67 and ....69). auto-detection at the mqtt broker is active.

everything is installed and looking fine:

● isp-rpi-reporter.service - RPi Reporter MQTT Client/Daemon Loaded: loaded (/opt/RPi-Reporter-MQTT2HA-Daemon/isp-rpi-reporter.service; enabled; v endor preset: enabled) Active: active (running) since Sat 2020-12-19 07:47:05 GMT; 11s ago Docs: https://github.com/ironsheep/RPi-Reporter-MQTT2HA-Daemon Main PID: 10184 (python3) Status: "Dec 19 07:47:04 - * MQTT connection established." Tasks: 4 (limit: 2182) CGroup: /system.slice/isp-rpi-reporter.service └─10184 /usr/bin/python3 -u /opt/RPi-Reporter-MQTT2HA-Daemon/ISP-RPi-mqtt-dae mon.py

but when i try to the rpis to home assistant, no devices are shown and thus i have no entities to add to my card. the mqtt broker shows this log:

23:41:38] INFO: Setup mosquitto configuration [23:41:38] WARNING: SSL not enabled - No valid certs found! [23:41:38] INFO: No local user available [23:41:39] INFO: Initialize Hass.io Add-on services [23:41:40] INFO: Initialize Home Assistant discovery [23:41:40] INFO: Start Mosquitto daemon 1608590500: mosquitto version 1.6.3 starting 1608590500: Config loaded from /etc/mosquitto.conf. 1608590500: Loading plugin: /usr/share/mosquitto/auth-plug.so 1608590500: ├── Username/password checking enabled. 1608590500: ├── TLS-PSK checking enabled. 1608590500: └── Extended authentication not enabled. 1608590500: |-- *** auth-plug: startup 1608590500: Opening ipv4 listen socket on port 1883. 1608590500: Opening ipv6 listen socket on port 1883. 1608590500: Opening websockets listen socket on port 1884. 1608590500: Warning: Mosquitto should not be run as root/administrator. 1608590505: New connection from 172.30.32.1 on port 1883. [INFO] found homeassistant on local database 1608590506: New client connected from 172.30.32.1 as 2cdXHPvbVerOgZL6ecpYWe (p2, c1, k60, u'homeassistant'). 1608590556: New connection from 192.168.178.67 on port 1883. 1608590556: New connection from 192.168.178.69 on port 1883. [INFO] found mqtt on Home Assistant 1608590558: New client connected from 192.168.178.67 as auto-857BAE5C-1AC9-3987-465B-36280FE6D2E7 (p2, c1, k60, u'mqtt'). 1608590558: New client connected from 192.168.178.69 as auto-A80A6673-63CF-40D0-2F0C-7661B255DE51 (p2, c1, k60, u'mqtt'). 1608590704: Socket error on client 2cdXHPvbVerOgZL6ecpYWe, disconnecting. 1608590780: New connection from 172.30.32.1 on port 1883. 1608590780: New client connected from 172.30.32.1 as 7qC1wY155CUGKGCOhi5AKK (p2, c1, k60, u'homeassistant'). 1608591134: New connection from 192.168.178.67 on port 1883. [INFO] found mqtt on Home Assistant 1608591135: New client connected from 192.168.178.67 as auto-2306B13D-AAF4-F5A0-C985-8DB8605856F6 (p2, c1, k60, u'mqtt'). 1608591145: Socket error on client auto-2306B13D-AAF4-F5A0-C985-8DB8605856F6, disconnecting. 1608591247: Socket error on client 7qC1wY155CUGKGCOhi5AKK, disconnecting. 1608591327: New connection from 172.30.32.1 on port 1883. [INFO] found homeassistant on local database 1608591328: New client connected from 172.30.32.1 as 6W9tQbCJwO5td0jPQK1NsM (p2, c1, k60, u'homeassistant').

so it looks like there is a connection, but maybe the socket error keeps the rpi-reporter from working properly. what does this error mean and how can i fix it?

could you please give me a hint how to be able to add the devices to my home assistant installation?

sfbuch avatar Dec 21 '20 23:12 sfbuch

in fact i do not believe this is a bug, but ma inability to install it properly. but i can't find a way to change the label.

sfbuch avatar Dec 21 '20 23:12 sfbuch

Have you tried to monitor the MQTT traffic? USe something like MQTTBox http://workswithweb.com/mqttbox.html or MQTT Explorer http://mqtt-explorer.com/ to see if the RPi's are constantly reporting.

Then if they are you'll know what the data is going to the HA MQTT Broker. Also if the traffic looks good then the problem is in the HA setup.

I don't have any idea about the error "Socket error on client" messages you are getting from the MQTT Broker. Have you double checked your user/password for MQTT access. If they are set you need to make sure they are set the same in the RPi Reporter config.ini file too.

ironsheep avatar Dec 22 '20 20:12 ironsheep

thanks!

i tried mqtt-explorer and as far as i understand it, it works fine. when i connect to the home assistant server i see under /homeassistant/sensor the rpis with 3 topics each and 3 messsages coming in every second.

i commented out the sensor-line in the config.ini and since then, there is no socket error anymore.

the rpis show now up under devices and entities. BUT: the entities show up as not available. do you have a solution for this problem?

sfbuch avatar Dec 22 '20 23:12 sfbuch

i commented out the sensor-line in the config.ini and since then, there is no socket error anymore.

Could you please write me example how you comment out sensor line? Cause i have same problem, all username/passwords for MQTT are correct in config .ini, but in HA integrations i still cannot see Rpi.

Thanks in advance

yarabes avatar Aug 09 '21 08:08 yarabes

@yarabes - In any configuration text file in Linux, a comment is simply a # with any text you want commented out after it. You can "comment out" old settings or make a note about what the setting is after specifying it. For example:

#this entire line is commented out technically and this would be a setting #this portion would be comment noting what the setting was or whatever

I hope that helps you.

@ironsheep I'm having a similar issue. I've install the reporting software and it connects to my broker. Using MQTT Explorer, I can see the traffic in home/nodes/sensor/(specified sensor name/hostname). I also made sure that it wasn't falsely claiming to connect to the broker before getting the MQTT Explorer installed by changing the password and forcing it to show a bad authentication. Despite it connecting to the broker, in HA under integrations, MQTT is still only show 21 devices and none are the RPi. I've not made any alterations to changes to my MQTT broker since I initially got it setup and working months ago. Yet, since then I've added and removed several new Tasmota devices, so I'm fairly certain this is more of a MQTT discovery/topic issue.

I'm pretty good at following directions while installing Linux software as I've been doing it for a long time. I haven't moved beyond the test phase of the directions given since it's not working correctly as of yet.

(Also, for what it's worth, the directions don't say how to create the user daemon with the group by the same name. probably just a small oversight, but unrelated to this issue)

hathalud avatar Aug 09 '21 09:08 hathalud

Hi

I Also had the same issue.

I use hassio on a raspi, and then I setup the reporting scrips in two additional raspis. Both raspis started to report data to HA properly, but after some time the devices dissapeared. For me It looked as some kind of conflict arising between both raspis, or how the broker interpreted the reports. If I restarted both raspis, then they showep Up again for some time, and then they dissapeared again...

After some time, one of the raspis crashed (SD card corruption). From then on, the only raspi Alive with the reporting scrips is working fine with no issue at all, and far It's ok for about 5 weeks. I did no change at all at that raspi configuration file or mqtt settings. Just removing one of the raspis solved the issue.

When I had the two raspis, I set a different name for them try avoiding conflicts, with no success. I Also hace many other devs integranted with mqtt with no issue at all for a couple years.

fgsalvador avatar Aug 09 '21 21:08 fgsalvador

@fgsalvador how are you configuring the hostnames for your RPIs?

In my RPI Daemon config.ini's I have:

[Daemon]
fallback_domain = {domain}
[MQTT]
hostname = {mqtthostname}.{domain}
base_topic = {mybaseTopic}
username = {mymqttuser}
password = {mymqttpw}

(Where values in {...} are replaced with my own values)

each of my RPi's has a formal {hostname} set. That is /etc/hostname contains the hostname for the given RPi.

I make sure all of my hostnames are unique on my network.

I do not have any conflicts on my network and all RPi's report in as expected.

The discovery path seen by HA for each of my RPis is: /homeassistant/sensor/rpi-{hostname}/

my RPi's report in on the path: /{mybaseTopic}/sensor/rpi-{hostname}/

And each RPi shows up in my HA instance as sensor.rpi_monitor_{hostname}

Please review your config.ini's (one on each of your RPIs and let's see what's different...

ironsheep avatar Aug 09 '21 22:08 ironsheep

@hathalud I welcome reports on needing to clean up my doc's!

Can you please clarify what you think is missing based on what you had to do?

Also, please check your RPi Reporter config.ini files (see my comment above.) to see if this helps your situation...

ironsheep avatar Aug 09 '21 22:08 ironsheep

@ironsheep

I went and double checked, apparently the daemon:daemon user and group were already created on my RPi. I assume that this was part of my particular RPi's setup, but I would hazard a guess that this might not be the case for all distros on RPi's. ​I'd add in a step to check if the daemon user does exist and if it doesn't, how to create it just to be on the safe side and cut down on that being a stumbling block for some.

And to be clear, I was reading ahead some and had assumed that the step to create the deamon user from scratch had been overlooked. Most of my work on my RPi thusfar has been via scripts that installed... UGh... thinking about that and the purpose for the RPi, I think I just solved my own problem. lol Yup. I was pointing to what use to be my MQTT broker with my still running container on it, not thinking about the fact that I had gotten the RPI for redundancy because of negative WAF (or GF in this case) any time the lights stopped working for her while the main server was rebooting or otherwise offline for any reason.

😅😅😅 Sorry for wasting your time on something so dumb on my part. 😅😅😅

hathalud avatar Aug 10 '21 04:08 hathalud

@fgsalvador how are you configuring the hostnames for your RPIs?

In my RPI Daemon config.ini's I have:

[Daemon]
fallback_domain = {domain}
[MQTT]
hostname = {mqtthostname}.{domain}
base_topic = {mybaseTopic}
username = {mymqttuser}
password = {mymqttpw}

(Where values in {...} are replaced with my own values)

each of my RPi's has a formal {hostname} set. That is /etc/hostname contains the hostname for the given RPi.

I make sure all of my hostnames are unique on my network.

I do not have any conflicts on my network and all RPi's report in as expected.

The discovery path seen by HA for each of my RPis is: /homeassistant/sensor/rpi-{hostname}/

my RPi's report in on the path: /{mybaseTopic}/sensor/rpi-{hostname}/

And each RPi shows up in my HA instance as sensor.rpi_monitor_{hostname}

Please review your config.ini's (one on each of your RPIs and let's see what's different...

Hi @ironsheep ,

these are my config values for the currently alive raspi:

[Daemon] enabled = true interval_in_minutes = 2 fallback_domain = controller

[MQTT]

hostname = 192.168.1.xx port = 1883 keepalive = 60 discovery_prefix = homeassistant base_topic = home/nodes sensor_name = rpi-unificontroller username = xxxxxxxx password = xxxxxxxx

Unfortunatelly, I cannot send the ini values for the ther raspi, as its SD-Card crashed...:-(

fgsalvador avatar Aug 10 '21 20:08 fgsalvador