3 accurite sensors in MQTT

How did you define the sensors in Home Assistant?
This is how I did it in the configuration:

- platform: mqtt
  state_topic: "homeassistant/sensor/temperature/Acurite_tower_sensor/13839"
  name: "Acurite Tower Temp BR1"
  unit_of_measurement: '°F'
  value_template: '{{ value_json.temp }}'

I tried those 3 and got unknown as the temperature

  • platform: mqtt
    state_topic: “homeassistant/sensor/temperature/Acurite_tower_sensor/15664”
    name: “Acurite Tower Temp Outside”
    unit_of_measurement: ‘°C’
    value_template: ‘{{ value_json.temperature_C }}’
  • platform: mqtt
    state_topic: “homeassistant/sensor/temperature/Acurite_tower_sensor/15664”
    name: “Acurite Tower Temp Outside1”
    unit_of_measurement: ‘°C’
    value_template: ‘{{ value_json.temp }}’
  • platform: mqtt
    name: ‘Exterieur’
    state_topic: ‘homeassistant/sensor/temperature/Acurite_tower_sensor/15664’
    unit_of_measurement: ‘°C’

Try using an app like MQTT fx and subscribe to what you are publishing. It looks like your message has lots of single and double quotes I find confusing.

Mine message looks like this in MQTT fx:
{ “temp”: 64.4, “battery”: “OK” }

1 Like

The data being received appears to be invalid. There’s a mixed mess of single and double quotations. It’s not valid JSON format.

'{"time"' : '"2019-05-07' '08:01:55",' '"model"' : '"Acurite' tower 'sensor",' '"id"' : 13839, '"sensor_id"' : 13839, '"channel"' : '"C",' '"temperature_C"' : 25.200, '"humidity"' : 35, '"battery_low"' : '0}'

After you correct the data (transmitted by rtl_433) you will be able to extract information using any one of these value_templates:

{{value_json.time}}
{{value_json.model}
{{value_json.id}}
{{value_json.sensor_id}}
{{value_json.channel}}
{{value_json.temperature_C}}
{{value_json.humidity}}
{{value_json.battery_low}}

ok, and what i should check to correct the data ? I am a beginier in that :wink:

How are you instructing rtl_433 to transmit its data?

The information in your first post is very difficult to read. It appears you are using a script to generate the data received by rtl_433. The script seems to be reading from a log file and then attempts to combine it with information you have provided to produce its output. My feeling is the output may not be valid JSON. Honestly, it’s hard to tell because the example is not formatted for easy reading.

I would begin by following cyn’s suggestion. Use an MQTT client (MQTT.fx or MQTT Explorer) to subscribe to homeassistant/sensor/temperature/Acurite_tower_sensor/13839 and examine its payload. MQTT Explorer has a built-in JSON validator so it will report if the payload is valid JSON or not.

In addition, it may not even be necessary to use a script file (or such a complicated script file) to publish the output from rtl_433. It recently added a new option to publish its data directly to an MQTT broker.

From rtl_433’s documentation, the -F option now includes the ability to publish to MQTT.

[-F kv | json | csv | mqtt | syslog | null | help] Produce decoded output in given format.
Append output to file with : (e.g. -F csv:log.csv), defaults to stdout.

Option -F:
[-F kv|json|csv|mqtt|syslog|null] Produce decoded output in given format.
Without this option the default is KV output. Use “-F null” to remove the default.
Append output to file with : (e.g. -F csv:log.csv), defaults to stdout.
Specify MQTT server with e.g. -F mqtt://localhost:1883
Add MQTT options with e.g. -F “mqtt://host:1883,opt=arg”
MQTT options are: user=foo, pass=bar, retain[=0|1],
usechannel=replaceid|afterid|beforeid|no, [=topic]
Supported MQTT formats: (default is all)
events: posts JSON event data
states: posts JSON state data
devices: posts device and sensor info in nested topics
E.g. -F “mqtt://localhost:1883,user=USERNAME,pass=PASSWORD,retain=0,devices=/rtl_433”
Specify host/port for syslog with e.g. -F syslog:127.0.0.1:1514

1 Like

Ohh wow, thanks a lot for this “howto”, i’ll take a look at that !

i’m using this command:

rtl_433 -F json -M utc | mosquitto_pub -t homeassistant/sensor/temperature -l -h 192.168.88.10 -u test -P test

I think this is the new improved way @123 is pointing out in the above post.

Try this command instead
-F “mqtt://192.168.88.10:1883,user=test,pass=test,retain=0,devices=homeassistant/sensor/temperature”

Then subscribe to # (everything) in MQTT fx/EXPLORER to see what it’s outputting.

Correct. The new mqtt option means you no longer have to pipe the output of rtl_433 to mosquitto_pub. rtl_433 can now publish directly to MQTT.

1 Like

here is what i have, but i have this error and nothing in MQTT browser

mqtt://192.168.88.10:1883,user=test,pass=test,retain=0,devices=homeassistant/sensor/temperature: No such file or directory

rtl_433 -F json -M utc | mosquitto_pub -t homeassistant/sensor/temperature -l -h 192.168.88.10 -u test -P test
root@inferno:/# mqtt://192.168.88.10:1883,user=test,pass=test,retain=0,devices=homeassistant/sensor/temperature
bash: mqtt://192.168.88.10:1883,user=test,pass=test,retain=0,devices=homeassistant/sensor/temperature: No such file or directory
root@inferno:/# rtl_433 -F mqtt://192.168.88.10:1883,user=test,pass=test,retain=0,devices=homeassistant/sensor/temperature
rtl_433 version 18.12-203-ge47b62d branch master at 201904291632 inputs file rtl_tcp RTL-SDR
Trying conf file at “rtl_433.conf”…
Trying conf file at “/root/.config/rtl_433/rtl_433.conf”…
Trying conf file at “/usr/local/etc/rtl_433/rtl_433.conf”…
Trying conf file at “/etc/rtl_433/rtl_433.conf”…
Publishing MQTT UDP datagrams to 192.168.88.10 port 1883

    Consider using "-M newmodel" to transition to new model keys. This will become the default someday.
    A table of changes and discussion is at https://github.com/merbanan/rtl_433/pull/986.

Registered 98 out of 125 device decoding protocols [ 1-4 8 11-12 15-17 19-21 23 25-26 29-36 38-60 62-63 67-71 73-100 102-103 108-116 119 121 124-125 ]
Found Rafael Micro R820T tuner
Exact sample rate is: 250000.000414 Hz
[R82XX] PLL not locked!
Sample rate set to 250000 S/s.
Tuner gain set to Auto.
Tuned to 433.920MHz.
Allocating 15 zero-copy buffers
MQTT Connected…
MQTT Connection established.

Thanks a lot for your help guys, i really appreciate !

I learned something new about how to use rtl_433/mqtt more efficiently. The way I have it coded is so much more complicated (supervisor & python scripts) so I am happy to help and also interested in getting it right.

Did you delete the rtl_433 -F json -M utc | mosquitto_pub -t homeassistant/sensor/temperature -l -h 192.168.88.10 -u test -P test line with the line I typed earlier? You still need the rtl_433 then what I typed above.

I removed the first line, i’ll try that, for your information, I use MQTT Server & Web client, i think there is something wrong with my MQTT install, i have tried 3 MQTT servers and still have the same problem,

In MQTT fx, try subscribing to your topic then publish a message. See if the subscribe screen displays it.

ok i got it now like you said, i’m testing in MQtt client to see

I have no errors, but still nothing in the MQTT :frowning:

here is what i have:

root@inferno:/# rtl_433 -F mqtt://192.168.88.10:1883,user=test,pass=test,retain=0,devices=homeassistant/sensor/temperature
rtl_433 version 18.12-203-ge47b62d branch master at 201904291632 inputs file rtl_tcp RTL-SDR
Trying conf file at “rtl_433.conf”…
Trying conf file at “/root/.config/rtl_433/rtl_433.conf”…
Trying conf file at “/usr/local/etc/rtl_433/rtl_433.conf”…
Trying conf file at “/etc/rtl_433/rtl_433.conf”…
Publishing MQTT UDP datagrams to 192.168.88.10 port 1883

    Consider using "-M newmodel" to transition to new model keys. This will become the default someday.
    A table of changes and discussion is at https://github.com/merbanan/rtl_433/pull/986.

Registered 98 out of 125 device decoding protocols [ 1-4 8 11-12 15-17 19-21 23 25-26 29-36 38-60 62-63 67-71 73-100 102-103 108-116 119 121 124-125 ]
Found Rafael Micro R820T tuner
Exact sample rate is: 250000.000414 Hz
[R82XX] PLL not locked!
Sample rate set to 250000 S/s.
Tuner gain set to Auto.
Tuned to 433.920MHz.
Allocating 15 zero-copy buffers
MQTT Connected…
MQTT Connection established.

Great that’s progress.

try changing devices to devices=/rtl_433
I might have misread what they are saying in the doc

I need to upgrade my rtl_433 to get the new version so I can run this, lol

The log information looks good, no reported errors, and it claims to have connected to the MQTT broker.

Nothing will be published to MQTT until rtl_433 receives data from your Acurite device. I don’t know its reporting interval. Wait at least a minute or two.

If you have still received nothing in Home Assistant, connect to the MQTT broker with MQTT Explorer and wait another minute or two for the topic to appear with its message. If nothing appears then something is wrong with the configuration of rtl_433.

Still nothing :frowning:
In the MQTT server i have : 1557250749: New connection from 192.168.88.8 on port 1883.
1557250749: New client connected from 192.168.88.8 as lens_kdPeb1IxwTz5CUMCiKyPPvOe9iH (c1, k120, u’test’).

But when i check in the MQTT browser and subscribe i have nothing

When you subscribe to # are you seeing anything?

devices=/rtl433 was suppose to be on your rtl_433 command