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

Mqtt sensor working with json and variables

$
0
0

@Juergen wrote:

I do get only one value from my mqtt topic.
I am using the rtl2mqtt to seperate the values. Let’s imagin from mqtt I do get on topic
sensor/rtl_433/Fine Offset Electronics WH1080/WH3080 Weather Station/101/direction_deg

the special value of an angle.
112

now I created a sensor:

- platform: mqtt
  state_topic: 'sensor/rtl_433/Fine Offset Electronics WH1080/WH3080 Weather Station/101/direction_deg'
  name: 'Wind Direction'
  unit_of_measurement: ''

this is showing me the value. Now I wanna do a campare

value_template: >-
      {% set wd = value_json | int %}
      {% if wd <= 11 or wd > 348 %}North
      {% elif wd >11 and wd <=34 %}North North East
      {% elif wd >34 and wd <=56 %}North East
      {% elif wd >56 and wd <=79 %}East North East
      {% elif wd >79 and wd <=101 %}East
      {% elif wd >101 and wd <=124 %}East South East
      {% elif wd >124 and wd <=146 %}South East
      {% elif wd >146 and wd <=169 %}South South East
      {% elif wd >169 and wd <=191 %}South
      {% elif wd >191 and wd <=214 %}South South West
      {% elif wd >214 and wd <=236 %}South West
      {% elif wd >236 and wd <=259 %}West South West
      {% elif wd >259 and wd <=281 %}West
      {% elif wd >281 and wd <=304 %}West North West
      {% elif wd >304 and wd <=326 %}West North West
      {% elif wd >326 and wd <=348 %}North North West

what I do see is a "unknown"state. I know how to work with attributes, but here I do not hav one. How can I get this value

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 101913

Trending Articles



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