Advertisement
JLMoss

Linkquality forloop

Nov 10th, 2022 (edited)
1,246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.91 KB | Source Code | 0 0
  1. # in homeassistant view devices, for aqara motion sensors find the device page
  2. # in the device page enable the linkquality sensor under diagnostic
  3. # then the below should work
  4.  
  5.         {%- for state in states.sensor
  6.           | selectattr('attributes.linkquality', 'defined')
  7.           | selectattr('attributes.unit_of_measurement', 'defined')
  8.           | selectattr('attributes.state_class', 'defined')
  9.           | selectattr('attributes.linkquality', 'is_number')
  10.           | selectattr('attributes.unit_of_measurement', '==', 'lqi')
  11.           | selectattr('attributes.state_class', '==', 'measurement')
  12.           | selectattr('state', 'is_number') -%}
  13.           {%- if state.state | int <= threshold -%}
  14.             {% set ns.sensors = ns.sensors + [dict(name = state.name | replace(' linkquality', '') | replace(' Linkquality', ''), state = state.state | int)] %}
  15.           {%- endif -%}
  16.         {%- endfor -%}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement