Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95925

Best way to template definitions of MQTT 433MHz temp/humid sensors?

$
0
0

@PieBru wrote:

Hi all,
Inside and outside my home I have more than a dozen of cheap 433 MHz temperature/humidity sensors like this:

I’m structuring my configuration.yaml much like Frenck and others did, so I’m grouping those RF sensors in a rtl_433 directory containing one yaml file for each sensor. I welcome better solutions.

All those RF sensors all working well, but spanning any configuration patch/innovation/update on every sensor .yaml file is asking for troubles.
So I’m looking for a better way to define them, some alternative to copy/paste 50 yaml lines each.

In my dreams, the only difference could be something like assigning the unique “id” to a “parameter” like ${rtl433_temp_humid_id} (“190” in the example below) and then including a templated file.

My actual definition(s):

  ## Analog sensors: https://www.home-assistant.io/integrations/sensor.mqtt/

  # rtl_433/Nexus-TH/190/2 {"time":"2020-02-04 11:42:39","model":"Nexus-TH","id":190,"channel":2,"battery_ok":1,"temperature_C":20.4,"humidity":54}
  - platform: mqtt
    state_topic: "rtl_433/Nexus-TH/190/+"
    name: "rtl433_NexusTH_190_rawtemp"
    device_class: temperature         # https://www.home-assistant.io/integrations/sensor/#device-class
    unit_of_measurement: "°C"
    expire_after: 180                 # Defines the number of seconds after the value expires if it’s not updated.
    force_update: true                # Sends update events even if the value hasn’t changed. Useful if you want to have meaningful value graphs in history.
    value_template: "{{ value_json.temperature_C }}"    # https://www.home-assistant.io/docs/mqtt/processing_json/
  - platform: filter                  # https://www.home-assistant.io/integrations/filter
    entity_id: sensor.rtl433_NexusTH_190_rawtemp
    name: "rtl433_NexusTH_190_temperature"
    filters:
      - filter: outlier
        window_size: 4
        radius: 2.0
      - filter: lowpass
        time_constant: 10
        precision: 1
      - filter: time_simple_moving_average
        window_size: 00:20            # HH:MM
        precision: 1

  - platform: mqtt
    state_topic: "rtl_433/Nexus-TH/190/+"
    name: "rtl433_NexusTH_190_rawhumid" 
    device_class: humidity
    unit_of_measurement: "%"
    expire_after: 180
    force_update: true
    value_template: "{{ value_json['humidity'] }}" 
  - platform: filter
    entity_id: sensor.rtl433_NexusTH_190_umidity
    name: "rtl433_NexusTH_190_umidity"
    filters:
      - filter: outlier
        window_size: 4
        radius: 2.0
      - filter: lowpass
        time_constant: 10
        precision: 1
      - filter: time_simple_moving_average
        window_size: 00:20            # HH:MM
        precision: 1

BTW I’m open also to more efficient filtering tricks :wink: to smooth the graphing and reduce value changes, as each one generates a DB update.

Any hint?
Thanks,
Piero

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 95925

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>