MQTT State

I am still struggling to get the state of my Govee leak sensors to update properly, and would appreciate an extra set of eyes on this.

I am using rtl_433 on a RPi to send this to HA.

Listening to the topic (rtl_433/Govee-Water/56000/event), I get the following:

Message 0 received on rtl_433/Govee-Water/56000 at 2:11 PM:
{
    "time": "2022-08-14 19:11:53",
    "model": "Govee-Water",
    "id": 56000,
    "event": "Button Press",
    "code": "253f05050746",
    "mic": "PARITY"
}


My binary sensor is this:

mqtt:
  binary_sensor:
    - state_topic: rtl_433/Govee-Water/56000/event
      payload_on: Water Leak
      payload_off: Button Press
      json_attributes_topic: rtl_433/Govee-Water/56000
      device_class: moisture
      unique_id: 56000_govee_water
      name: Washing Machine Water Leak

But the state continues to show unknown:

Any thoughts?

I don’t have a Govee, but thought I would try to help.
Maybe give the following a try (note I added quotation marks in various places as well).
Also from looking at docs.

mqtt:
  binary_sensor:
    - state_topic: "rtl_433/Govee-Water/56000"
      payload_on: "Water Leak"
      payload_off: "Button Press"
      device_class: moisture
      unique_id: 56000_govee_water
      name: Washing Machine Water Leak
      value_template: "{{value_json.event}}"
2 Likes

I swear I tried that format, but must have been missing the quotes! Thank you so much!

Screen Shot 2022-08-21 at 12.13.53 PM

How did you get your additional attributes to pull in? (ie time, id, etc). I think I have mine setup just like yours (maybe a different rtl_433 config?) but it only pulls in device class and friendly name. I’m also curious if you chose to do anything to get the battery to pull in.

I largely followed the config here:
https://www.kyleniewiada.org/blog/2021/10/affordable-water-leak-and-temp-monitoring/

Here is my /etc/rtl_433/services.conf

@RTL:/etc/rtl_433 $ cat service.conf 
output json 
output mqtt://<IP>,user=<user>,pass=<pass>,retain=0,events=rtl_433[/model][/id]
report_meta time:utc

That link has some code around health checks/battery status. I have yet to implement those, but plan to spend some time on it this weekend. I will post back here if I have any success.

Appreciate the response. I checked out that blog late last night and today and finally connected the dots of all the different posts I was reading. I have now successfully got the events, battery % and battery mV pushing to HA. Thanks!

Hi, can you post your mqtt yaml? Thanks

Yep, this is what I use, replace the XXXX with your device IDs:

binary_sensor:
  - state_topic: rtl_433/Govee-Water/XXXX/event
    json_attributes_topic: rtl_433/Govee-Water/XXXX
    device_class: moisture
    unique_id: leak_XXXX_kitchensink
    name: Leak - Kitchen Sink
    payload_on: "Water Leak"
    payload_off: "Button Press"
sensor:
  - state_topic: rtl_433/Govee-Water/XXXX/battery_ok
    json_attributes_topic: rtl_433/Govee-Water/XXXX
    device_class: battery
    value_template: "{{ (value_json | float * 100) | int }}"
    unique_id: battery_leak_XXXX_kitchensink
    name: Battery - Leak - Kitchen Sink
    unit_of_measurement: "%"

  - state_topic: rtl_433/Govee-Water/XXXX/battery_mV
    json_attributes_topic: rtl_433/Govee-Water/XXXX
    device_class: voltage
    # value_template: "{{ (value_json | float / 1000) | int }}"
    unique_id: battery_mv_leak_XXXX_kitchensink
    name: Battery mV - Leak - Kitchen Sink
    unit_of_measurement: "mV"

@smoysauce This is very helpful as I have been struggling with auto_discovery and the Govee sensors. Where exactly do the binary sensor and sensor sections belong? I thought I could put them in configuration.yaml but I’m getting error messages there:

Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 100).
Invalid config for [sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 100).
Invalid config for [binary_sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 92).

MQTT Explorer shows this for the sensor:
Screenshot 2023-09-19 at 9.42.14 AM
It appears there is no voltage reading, so perhaps I have a different type of Govee sensor.

@smoysauce I realized my setup differes from yours:
Screenshot 2023-09-19 at 9.48.29 AM
So I redid the config changes to:
binary_sensor:

  • state_topic: rtl_433/raspberrypi/devices/Govee-Water/29010/event
    json_attributes_topic: rtl_433/raspberrypi/devices/Govee-Water/29010
    device_class: moisture
    unique_id: leak_29010_crawlspace
    name: Leak - Crawl Space
    payload_on: “Water Leak”
    payload_off: “Button Press”
    sensor:

  • state_topic: rtl_433/raspberrypi/devices/Govee-Water/29010/battery_ok
    json_attributes_topic: rtl_433/raspberrypi/Govee-Water/29010
    device_class: battery
    value_template: “{{ (value_json | float * 100) | int }}”
    unique_id: battery_leak_29010_crawlspace
    name: Battery - Leak - Crawl Space
    unit_of_measurement: “%”

  • state_topic: rtl_433/Govee-Water/raspberrypi/devices/29010/battery_mV
    json_attributes_topic: rtl_433/raspberrypi/devices/Govee-Water/29010
    device_class: voltage

    value_template: “{{ (value_json | float / 1000) | int }}”

    unique_id: battery_mv_leak_29010_crawlspace
    name: Battery mV - Leak - Crawl Space
    unit_of_measurement: “mV”

but I still get the same error msgs. Can you help?

Since my sensor does not seem to report battery level or voltage I took those defns out and I’m left with the binary sensor and I get this error:
Invalid config for [binary_sensor]: required key not provided @ data[‘platform’]. Got None. (See /config/configuration.yaml, line 92).

I went back to using basic 433 with my RF bridge but looking at my config I have those entries for the RTL under my mqtt.yaml file; since I parse my yaml files out. If you are putting everything in your config.yaml file, I think you’ll need to add the mqtt platform header before it.

I CHAGED CONFIGURATION.YAML TO ADD THIS:

binary_sensor:
- platform: mqtt
state_topic: rtl_433/raspberrypi/devices/Govee-Water/29010/event
json_attributes_topic: rtl_433/raspberrypi/devices/Govee-Water/29010
device_class: moisture
unique_id: leak_29010_crawlspace
name: Leak - Crawl Space
payload_on: “Water Leak”
payload_off: “Button Press”

No error but I don’t see a sensor either.