I am trying to publish MQTT information from Node-RED to my Home Assistant setup but I am not getting it to work. Today I have a camera publishing MQTT to HA already and this works just fine.
Now I have created a flow in Node-RED that has exit to publish towards MQTT. My setup in Node-RED looks like this:
Debugging gives me updates just like I want (on the msg.payload), so the setup works. I have configured the various MQTT publish exits like follows:
I have tried some few changes like crossing āclean sessionā and āuse legacy 3.1 supportā but I get no changes. On my raspberry I find the following in my MQTT log:
1548140394: Received PUBLISH from nodered (d0, q0, r0, m0, āhomeassistant/sensor/batteri/currentā, ā¦ (5 bytes))
1548140394: Sending PUBLISH to 79f15147-3923-47ce-bdb1-ae98303d44f9 (d0, q0, r0, m0, āhomeassistant/sensor/batteri/currentā, ā¦ (5 bytes))
1548140394: Received PUBLISH from nodered (d0, q0, r0, m0, āhomeassistant/sensor/batteri/socā, ā¦ (2 bytes))
1548140394: Sending PUBLISH to 79f15147-3923-47ce-bdb1-ae98303d44f9 (d0, q0, r0, m0, āhomeassistant/sensor/batteri/socā, ā¦ (2 bytes))
1548140396: Received PUBLISH from nodered (d0, q0, r0, m0, āhomeassistant/sensor/batteri/currentā, ā¦ (5 bytes))
1548140396: Sending PUBLISH to 79f15147-3923-47ce-bdb1-ae98303d44f9 (d0, q0, r0, m0, āhomeassistant/sensor/batteri/currentā, ā¦ (5 bytes))
1548140396: Received PUBLISH from nodered (d0, q0, r0, m0, āhomeassistant/sensor/batteri/socā, ā¦ (2 bytes))
1548140396: Sending PUBLISH to 79f15147-3923-47ce-bdb1-ae98303d44f9 (d0, q0, r0, m0, āhomeassistant/sensor/batteri/socā, ā¦ (2 bytes))
1548140398: Received PUBLISH from nodered (d0, q0, r0, m0, āhomeassistant/sensor/batteri/currentā, ā¦ (5 bytes))
1548140398: Sending PUBLISH to 79f15147-3923-47ce-bdb1-ae98303d44f9 (d0, q0, r0, m0, āhomeassistant/sensor/batteri/currentā, ā¦ (5 bytes))
1548140398: Received PUBLISH from nodered (d0, q0, r0, m0, āhomeassistant/sensor/batteri/socā, ā¦ (2 bytes))
1548140398: Sending PUBLISH to 79f15147-3923-47ce-bdb1-ae98303d44f9 (d0, q0, r0, m0, āhomeassistant/sensor/batteri/socā, ā¦ (2 bytes))
1548140400: Received PUBLISH from nodered (d0, q0, r0, m0, āhomeassistant/sensor/batteri/currentā, ā¦ (5 bytes))
1548140400: Sending PUBLISH to 79f15147-3923-47ce-bdb1-ae98303d44f9 (d0, q0, r0, m0, āhomeassistant/sensor/batteri/currentā, ā¦ (5 bytes))
1548140400: Received PUBLISH from nodered (d0, q0, r0, m0, āhomeassistant/sensor/batteri/socā, ā¦ (2 bytes))
1548140400: Sending PUBLISH to 79f15147-3923-47ce-bdb1-ae98303d44f9 (d0, q0, r0, m0, āhomeassistant/sensor/batteri/socā, ā¦ (2 bytes))
1548140401: New connection from 192.168.1.100 on port 1883.
1548140401: New client connected from 192.168.1.100 as mosqpub|22608-sofia-sal (c1, k60, uāmqttuserā).
1548140401: Sending CONNACK to mosqpub|22608-sofia-sal (0, 0)
1548140401: Received PUBLISH from mosqpub|22608-sofia-sal (d0, q0, r1, m0, āsofia/salong/leds/blueā, ā¦ (2 bytes))
1548140401: Sending PUBLISH to mosqsub|269-sofia-salon (d0, q0, r0, m0, āsofia/salong/leds/blueā, ā¦ (2 bytes))
1548140401: Sending PUBLISH to 79f15147-3923-47ce-bdb1-ae98303d44f9 (d0, q0, r0, m0, āsofia/salong/leds/blueā, ā¦ (2 bytes))
1548140401: Received DISCONNECT from mosqpub|22608-sofia-sal
1548140401: Client mosqpub|22608-sofia-sal disconnected.
The ānoderedā lines does not work, but the āsofia/salongā ones work fine. I have tried the following as-well:
pi@raspberrypi:/var/log/mosquitto $ mosquitto_sub -h localhost -p 1883 -t āhomeassistant/sensor/batteri/socā
47
47
47
47
So in my simple mind it seems to work! How do I get HA to discover these sensors? Is there some kind of templating I need to do? Do I have to create these āobjectsā in MQTT? Sorry for my illiteracy around MQTT, this is not my competence at all! If someone could please point me in the right direction that would be lovely!
Things I have tried:
- with and witout username
- enable / disable āallow_anonymousā in mosquitto.conf
- delete integration in HA and recreate, also making sure discovery is checked
- tried different topics, not sure how the topic part works totally, but every try fails the same way