Hallo,
is it possible to easy convert this “sensor platform template” to an “template sensor”?
sensor:
- platform: template
sensors:
# time since off 'off'
pool_pump_duration_off:
friendly_name: "poolpump off"
unique_id: "pool_pump_duration_off"
device_class: "duration"
unit_of_measurement: "min"
value_template: >
{% set t = states('sensor.time') %}
{% set is_off = is_state('switch.pool_pump', 'off')| int(0) %}
{% if is_off %}
{{ (utcnow() - states.switch.pool_pump.last_changed).total_seconds() | int(0) // 60 }}
{% else %}
{{ 'no run' }}
{% endif %}
Or is this not necessary, becase the old format will be working the next years without problems?