Hello,
I am new to HA and I am trying to migrate from Homey to HA.
I can set the value of two variables I have defined.
Now I need to substract them multiply by 3600000 and devide by value Y
Value Y needs to be calculated as the difference between 900 seconds and the remaining seconds on a countdown timer.
Also need tome help to calculate value Y.
I could set the time(now) when the first automation starts and save that in a variable and then substract that from the time(now) when this automation runs.
This is the code I already have:
description: ""
trigger:
- platform: state
entity_id:
- timer.piek_couter1
to: idle
condition: []
action:
- service: var.set
data:
entity_id: var.total_usage_lopend
value: "{{ states('sensor.p1_meter_5c2faf055da6_total_power_import') }}"
- service: timer.start
data: {}
target:
entity_id: timer.piek_couter1
- service: var.set
data:
entity_id: var.kwartierpiek_current
value: "{{ (states('var.total_usage_lopend')) - (states('var.total_usage_begin_lopend')) * 3600 / 'Y'}}
mode: single
I also could skip setting value of var.total_usage_lopend and use it directly in the calculation string
Thx!