stix77

HA_Eliot

Jan 14th, 2021 (edited)
169
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - platform: rest
  2.   name: Eliot
  3.   resource: https://app.visionq.cz/api/device_last_measurement.php?eui=XXXXXXXXX
  4.   username: xxxxx
  5.   password: xxxxx
  6.   authentication: basic
  7.   scan_interval: 900
  8.   value_template: '1'
  9.   json_attributes:
  10.    - low_rate_kwh
  11.     - high_rate_kwh
  12.     - timestamp
  13.     - battery_state
  14.     - network
  15.     - snr
  16.  
  17. - platform: template
  18.   sensors:
  19.     eliot_energy_low:
  20.       value_template: '{{ states.sensor.eliot.attributes["low_rate_kwh"] }}'
  21.       device_class: power
  22.       unit_of_measurement: kWh
  23.     eliot_energy_high:
  24.       value_template: '{{ states.sensor.eliot.attributes["high_rate_kwh"] }}'
  25.       device_class: power
  26.       unit_of_measurement: kWh
  27.     eliot_last_update:
  28.       value_template: '{{ states.sensor.eliot.attributes["timestamp"] }}'
  29.       device_class: timestamp
  30.     eliot_updated_ago:
  31.       value_template: >-
  32.         {% set last_updated = states.sensor.eliot.attributes["timestamp"] %}
  33.         {% set seconds = now().timestamp()-last_updated %}
  34.         {% set hours = seconds / 3600 %}
  35.         {% if seconds / ( 60 * 60 ) > 1 %}
  36.           {{ (seconds //  ( 60 * 60 ))|int }} hod
  37.         {% else %}
  38.           {{ (seconds // 60)|int }} min
  39.         {% endif %}
  40.     eliot_battery:
  41.       value_template: '{{ (states.sensor.eliot.attributes["battery_state"] | int / 254) * 100 | int }}'
  42.       device_class: battery
  43.     eliot_network:
  44.       value_template: '{{ states.sensor.eliot.attributes["network"] }} '
  45.     eliot_snr:
  46.       value_template: '{{ states.sensor.eliot.attributes["snr"] }} '
  47.       device_class: signal_strength
  48.       unit_of_measurement: dB
  49.  
  50. - platform: template
  51.   sensors:
  52.     hourly_energy:
  53.       friendly_name: Hourly Energy
  54.       unit_of_measurement: kWh
  55.       value_template: "{{ states('sensor.hourly_energy_offpeak')|float + states('sensor.hourly_energy_peak')|float }}"
  56.     daily_energy:
  57.       friendly_name: Daily Energy
  58.       unit_of_measurement: kWh
  59.       value_template: "{{ states('sensor.daily_energy_offpeak')|float + states('sensor.daily_energy_peak')|float }}"
  60.     monthly_energy:
  61.       friendly_name: Monthly Energy
  62.       unit_of_measurement: kWh
  63.       value_template: "{{ states('sensor.monthly_energy_offpeak')|float + states('sensor.monthly_energy_peak')|float }}"
RAW Paste Data