Advertisement
arushear

Poprawka dwa

Oct 22nd, 2024
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.36 KB | None | 0 0
  1. - platform: rest
  2.   name: szambo
  3.   resource: http://mojdomek.eu/api/api2.php?id=TUTAJ_ID
  4.   method: GET
  5.   value_template: >
  6.    {% set data = value_json.locations[0].measurement %}
  7.     {{ {
  8.         'percent': data.percent,
  9.         'batt_level': data.batt_level,
  10.         'cm': data.cm,
  11.         'nextfull': data.nextfull,
  12.         'lastempty': data.lastempty
  13.     } | tojson }}
  14.   json_attributes:
  15.    - percent
  16.     - batt_level
  17.     - cm
  18.     - nextfull
  19.     - lastempty
  20.   scan_interval: 1800
  21.  
  22. - platform: template
  23.   sensors:
  24.     szambo_poziom:
  25.       friendly_name: "Poziom szamba"
  26.       value_template: "{{ state_attr('sensor.szambo', 'percent') | float(default=0) }}"
  27.       unit_of_measurement: '%'
  28.  
  29.     szambo_bateria:
  30.       friendly_name: "Stan baterii"
  31.       value_template: "{{ state_attr('sensor.szambo', 'batt_level') | float(default=0) }}"
  32.       unit_of_measurement: '%'
  33.  
  34.     szambo_cm:
  35.       friendly_name: "Poziom szamba w cm"
  36.       value_template: "{{ state_attr('sensor.szambo', 'cm') | float(default=0) }}"
  37.       unit_of_measurement: 'cm'
  38.  
  39.     szambo_nastepne_oproznienie:
  40.       friendly_name: "Następne opróżnienie"
  41.       value_template: "{{ state_attr('sensor.szambo', 'nextfull') }}"
  42.  
  43.     szambo_ostatnie_oproznienie:
  44.       friendly_name: "Ostatnie opróżnienie"
  45.       value_template: "{{ state_attr('sensor.szambo', 'lastempty') }}"
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement