need to set daystart sensors based on power (_actueel
) and usage (_totaal
) sensors. Way I think I need to do that is setting an input_number netwerk_library_power_daystart:
at day change to the value of the sensor.netwerk_libary_actueel
. This in its place will be used by a template sensor
netwerk_library_power_daystart:
friendly_name: Netwerk library power daystart
value_template: >
{{states('input_number.netwerk_library_power_daystart')|float}}
and which I will record and be able to create graphs etc etc.
the same goes for usage_daystart based on sensor.netwerk_library_totaal
, creating a template sensor:
netwerk_library_usage_daystart:
friendly_name: Netwerk library usage daystart
value_template: >
{{states('input_number.netwerk_library_usage_daystart')|float}}
I have 12 sensor/number sets like this, so would love to template the automation…
automation:
- alias: Set daystart sensors
trigger:
platform: state
entity_id: sensor.date
condition: []
action:
- service: input_number.set_value
data:
entity_id: input_number.afzuigkap_zolder_power_daystart
value: >
{{states('sensor.afzuigkap_zolder_actueel')}}
- service: input_number.set_value
data:
entity_id: input_number.afzuigkap_zolder_usage_daystart
value: >
{{states('sensor.afzuigkap_zolder_totaal')}}
and then…automatically loop all of the sensors, for which I need some assistance…
I’ve created 2 groups for the daystart power, and daystart usage input_numbers, hoping this could facilitate iterating the group and for each sensor.xxx_actueel, set the input_number.xxx_power_daystart, and for each sensor.xxx_totaal, set the input_number.xxx_usage_daystart.
coming to think of that, I might be better of grouping the sensors…?
Hope this makes sense, at least to a level you could help me build this further…
for all ids in expand(‘group.daystart_power’), do:
- service: input_number.set_value
variables:
id : >
{{entity_id.object_id.split('_power_daystart')[0] }}
data:
entity_id: >
input_number.{{id}}_power_daystart
value: >
{{states('sensor.' ~ id ~ '_actueel')}}
to give you the idea…
these templates create the correct entity_id’s for the input_number:
{%- for s in expand('group.daystart_power') %}
{% set id = s.object_id.split('_power_daystart')[0] %}
input_number.{{id}}_power_daystart
{%- endfor %}
and sensors:
{%- for s in expand('group.daystart_power') %}
{% set id = s.object_id.split('_power_daystart')[0] %}
sensor.{{id}}_actueel
{%- endfor %}
or even the value:
{%- for s in expand('group.daystart_power') %}
{% set id = s.object_id.split('_power_daystart')[0] %}
{{states('sensor.' ~ id ~ '_actueel')}}
{%- endfor %}
now I need the automation to set those for each of those.
thanks if you would
please let me tag you @123 @petro, and please don’t feel pushed…