Hi, hope someone has the time to help. I'm trying to set an action for an automation I want to do, but I think it needs a template which I'm no good at
I would like, depending on the Agile price, to use the current battery SoC value to set the same value for min SoC on grid, so my battery stops discharging during that period.
This is how far I've got (not very far!) but it doesn't input the value for min SoC on grid. I've spent hours looking at the code here & trying various ways, but can't work it out due to my lack of knowledge with templates
service: input_number.set_value
data_template:
value: "{{states('sensor.battery_soc')}}"
target:
entity_id: number.min_soc_on_grid
Thanks, Chris
Help Needed
-
- Posts: 1295
- Joined: Thu Oct 13, 2022 7:21 pm
Hi Chris,
I think this should do what you need -
You have to use number.set_value not input_number.set_value,.
I’ve done it in 2 steps first to load battery_soc into the variable BSoC, set as an integer with a default value of 10 (just in case it’s unavailable) then write it out via the {{ templates }}
I think this should do what you need -
You have to use number.set_value not input_number.set_value,.
I’ve done it in 2 steps first to load battery_soc into the variable BSoC, set as an integer with a default value of 10 (just in case it’s unavailable) then write it out via the {{ templates }}
Code: Select all
service: number.set_value
data:
value: >-
{% set BSoC = states('sensor.battery_soc')|int(10) %}
{{ BSoC }}
target:
entity_id: number.min_soc_on_grid
-
- Posts: 15
- Joined: Sun Nov 06, 2022 8:34 am
Hi Dave, many thanks for that, it worked a treatDave Foster wrote: ↑Sat Mar 23, 2024 6:26 pm Hi Chris,
I think this should do what you need -
You have to use number.set_value not input_number.set_value,.
I’ve done it in 2 steps first to load battery_soc into the variable BSoC, set as an integer with a default value of 10 (just in case it’s unavailable) then write it out via the {{ templates }}
Code: Select all
service: number.set_value data: value: >- {% set BSoC = states('sensor.battery_soc')|int(10) %} {{ BSoC }} target: entity_id: number.min_soc_on_grid