ironsheep / RPi-Reporter-MQTT2HA-Daemon

Linux service to collect and transfer Raspberry Pi data via MQTT to Home Assistant (for RPi Monitoring)
GNU General Public License v3.0
460 stars 64 forks source link

MQTT auto discovery not working #16

Closed realjax closed 4 years ago

realjax commented 4 years ago

Checklist:

Release with the issue: latest

Last working release (if known):

Hardware, Operating System, Python version:

MQTT auto discovery not working. Messages are posted without problems to the MQTT server allright. A topic withe the name

homeassistant/sensor/rpi-mqtt-hole

is created but Home Assistant does not pick this up and there is no sensor.rpi-mqtt-hole available for the reporter card. When the 'Listen to a topic' functionality is used of the MQTT integration, and when listening to homeassistant/# the messages are received just fine.

Run our report script 'genBugInfo' on your failing device and include the output here:

Python errors shown in the logs (if applicable):

There are no errors thrown anywhere.

ironsheep commented 4 years ago

From your comment, I can't really tell what's not working. As you indicate it sort of is working?

Can you please clarify? I'll be glad to help/fix things when I better understand!

realjax commented 4 years ago

As you indicate it sort of is working?

:)

Well, yes. That is, HA is able to communicate fine with my MQTT server, but HA's MQTT autodiscovery for the script is not working. it is not picking up 'homeassistant/sensor/rpi-mqtt-hole' and listing it as a sensor.

realjax commented 4 years ago

ok, got a little further I think.
here is (the relevant part of) my config.ini

# by default Home Assistant listens to the /homeassistant but it can be changed for a given installation
#  likewise, by default this script advertises on the same default topic. If you use a different
#  discovery prefix then specify yours here.  [default: homeassistant]
discovery_prefix = homeassistant

# NOTE: The MQTT topic used for this device is constructed as:
#  {base_topic}/{sensor_name}
#
# The MQTT base topic under which to publish the Raspberry Pi sensor data topics.
base_topic = stat/system

# The MQTT name for this Raspberry Pi as a sensor
sensor_name = rpi-mqtt-hole

But in Home Assistant I end up seeing these sensors:

Screenshot 2020-09-03 at 09 55 09

None of which the (full)rpi monitor card wants, right?

realjax commented 4 years ago

Yes! Got it to work.

It's initial problem of not showing up in HA was due to a broken supervisor install ( I think). Fixed this and HA picked things as expected. And then I had to mess around with some - and _ that I had mixed up. Working fine now!