In summary, I’m trying to integrate a 433mhz sensor into HA via MQTT. I’m running a PI3 with HA & mosquitto on (192.168.68.112). Another PI is running RTL_433 and sending mqtt data to the HA instance. I can’t get the data displayed in the lovelace interface.
In HA if i go into developer tools / logs i can see lots of entries like,
2020-01-28 13:35:35 DEBUG (MainThread) [homeassistant.components.mqtt] Received message on homeassistant/sensors/rtl_433/AmbientWeather-TX8300/3/temperature_C: b’22.2’
In HA if i go into developer tools / MQTT and put a ‘#’ (without quotes) in the “Listen to a topic” i get lots of details (i’m feeding lots of 433mhz devices into mosquitto). Eg.
Message 195 received on homeassistant/sensors/rtl_433/AmbientWeather-TX8300/3/temperature_C at 1:35 PM:
22.2
QoS: 0 - Retain: false
At this point i’m confident i’m feeding data into HA. I now want to visualise this in a sensor. In the configuration.yaml I’ve got the following,
If i look in developer tools / states at …
sensor.mqtt_weather_temperature I get a state of ‘unknown’.
Changing this to a value. I then see this value displayed in a sensor in the lovelace interface.
So the problem appears to be extracting the value from the MQTT message. I’ve spent the last few days reading and I can’t see what i’m doing wrong. Any hints?
according to the message you received over MQTT, there is no JSON formatting there, so it would just be {{ value }} and your topic would include the temperature_C
rtl_433 which is publishing to the MQTT server is configured to publish to channel
homeassistant/sensors/rtl_433/AmbientWeather-TX8300/3/
and it sends the json,
{“time” : “2020-01-28 14:53:35”, “model” : “AmbientWeather-TX8300”, “id” : 3, “channel” : 3, “battery” : 2, “temperature_C” : 22.300, “mic” : “CHECKSUM”}
I’ve updated as per flamingmand and now it works for the temperature and battery values - which is fabulous. After a couple of days banging my head against a desk i’m very happy…
But i’m also now confused. I don’t understand why time doesn’t work using the same code (i’m guessing its related to the fact the time is in quotes) and i don’t understand why my original code didn’t work.
Good spot with the extra ‘/’ on the previous post - although i think that is editing mistake.
The code used to generate the mqtt message is,
rtl_433 -v -a 4 -F “mqtt://192.168.68.112:1883,user=,pass=, retain=1, devices=homeassistant/sensors/rtl_433[/model][/type][/id]” -c si -M newmodel -F “json:output.json”
The key bit being the ‘-F’ command which outputs to the mqtt server and the devices= is the path it posts to. On that you’ll see it doesn’t have a final ‘/’. The json i posted earlier was from the second ‘-F’ which creates a second output which i’m currently using for debug to check what should be in home assistant…
Output in developer tools / mqtt,
Listen to a topic
Listening to
homeassistant/sensors/rtl_433/AmbientWeather-TX8300/3/#
Message 17 received on homeassistant/sensors/rtl_433/AmbientWeather-TX8300/3/mic at 3:55 PM:
CHECKSUM
QoS: 0 - Retain: false
Message 16 received on homeassistant/sensors/rtl_433/AmbientWeather-TX8300/3/temperature_C at 3:55 PM:
22
QoS: 0 - Retain: false
Message 15 received on homeassistant/sensors/rtl_433/AmbientWeather-TX8300/3/battery at 3:55 PM:
2
QoS: 0 - Retain: false
Message 14 received on homeassistant/sensors/rtl_433/AmbientWeather-TX8300/3/channel at 3:55 PM:
3
QoS: 0 - Retain: false
Message 13 received on homeassistant/sensors/rtl_433/AmbientWeather-TX8300/3/id at 3:55 PM:
3
QoS: 0 - Retain: false
Message 12 received on homeassistant/sensors/rtl_433/AmbientWeather-TX8300/3/time at 3:55 PM:
2020-01-28 15:55:33
QoS: 0 - Retain: false
I’ve been using mqtt-spy. I didn’t want to post from that as I assumed everyone would be familiar with HA interface so it would drive less ‘tool based’ questions.
Grabbed mqtt explorer - within seconds i’m thinking “this is so much better” - thank you.
In doing that I’ve also noticed why I couldn’t get the time value - i had a spelling mistake in the mqtt path
Not sure if the right post but the same type of symptom. I have a fan in my raspberry pi that I wil turn on and off when the pi reaches certain temperature, its a python script so I’ve added the mqtt python module to send the data to HA. My broker is a mosquitto one that runs on the same host.
When I do the mosquitto sub I can see the payload coming in when the fan is on/off, if I use the developer tools in HA to start a listener the same. But then on the sensor it never changes…
I’ve setup as a binary sensor.