I created some input_numbers, where _01, _02, _03… indicate the month number.
input_number:
piek_afname_01:
name: Piek afname januari
min: 0
max: 10.0
step: 0.001
mode: box
unit_of_measurement: "kWh"
# also 02,03, ....
piek_afname_12:
name: Piek afname december
min: 0
max: 10.0
step: 0.001
mode: box
unit_of_measurement: "kWh"
I have an automation
- alias: Laatste piek
mode: parallel
trigger:
- platform: state
entity_id: sensor.fluvius_verbruik_energy_kwartier_gemiddelde
condition:
- condition: template
value_template: >
# XX vv
{{ states("sensor.fluvius_verbruik_energy_kwartier_gemiddelde") | float(0) > states("input_number.piek_afname_XX") | float(0)}}
action:
- service: input_number.set_value
target:
entity_id: input_number.piek_afname
data:
value: >
{{ states("sensor.fluvius_verbruik_energy_kwartier_gemiddelde") | float(0)}}
- service: input_number.set_value
target:
entity_id: 'input_number.piek_afname_{{ (as_timestamp(now()))|timestamp_custom("%m", true) }}'
data:
value: >
{{ states("sensor.fluvius_verbruik_energy_kwartier_gemiddelde") | float(0)}}
The problem is that I don’t know how to write this exactly.
I want to replace XX with the month number like I use it in the second service: input_number.set_value
: (as_timestamp(now()))|timestamp_custom("%m", true)
but I’m having problems with putting the symbols (like: {, (, …) in the correct place.
So, how do I write the line after “# XX” correctly ?
Thanks