Hi there,
Please allow me to pick your brains. It should be easy, but I currently cannot get my head around it… I am controlling the charger of my electric car such way that I only use excess solar power; it works great and I love it!
But I am not satisfied yet with my logic to switch between one and three phased charging. It works quite well already but coming closer to autumn I would like to avoid too many switches between one- and three-phased charging in order to reduce wear on the electronics.
Basically, I have an input_select helper with three states (“too low”, “1-phase”, “3-phase”) and I would like to change between these states if (and only if) a statistical sensor constantly stays above (or below) a thresholds for a minimum duration of 10 minutes.
This is part where I cannot get my head around: Currently I have an automation which runs on a time pattern and decides on the preferred state. But I would like to add the condition about the duration. The only solution I see is to split it up in 4 separate automations and to use for: minutes: 10
as a trigger or conditions to fire it off, but shouldn’t it be possible to write this simple logic a bit smarter? For example as a template in the config file?
Currently it looks like this:
choose:
- conditions:
- condition: numeric_state
entity_id: sensor.solar_to_ingolf_available_power_lowpass_filtered
above: 1380
for: {# this doesn't work in the 'action' part of my automation, maybe in a template? #}
hours: 0 {# this doesn't work in the 'action' part of my automation, maybe in a template? #}
minutes: 10 {# this doesn't work in the 'action' part of my automation, maybe in a template? #}
seconds: 0 {# this doesn't work in the 'action' part of my automation, maybe in a template? #}
- condition: state
entity_id: input_select.solar_to_ingolf_charging_mode
state: too low
for:
hours: 0
minutes: 10
seconds: 0
sequence:
- service: input_select.select_option
data:
option: one phase
target:
entity_id: input_select.solar_to_ingolf_charging_mode
# etc. etc. ...
If of interest, here’s how I would set it up with 4 separate automations:
-
(a) change the state form “too low” to “1-phase” if the power surplus sensor constantly is above 1380 for 10 minutes AND the current state is “too low”.
-
(b) change the state from “1-phase” to “3-phase” if the power surplus sensor constantly is above 3680 W for 10 minutes AND the current state is “1-phase”
-
(c) change the state from “3-phase” to “1-phase” if the power surplus sensor constantly stays below 3680 W for 10 minutes AND the current state is “3-phase”
-
(d) change the state from “1-phase” to “too low” if the power surplus sensor constantly stays below 1380 W for 10 minutes AND the current state is “1-phase”
Most likely the solution is terribly easy… And sorry for the noise, by the way