I have a powered roller blind that i have plugged into a charger. I would like to have the charger turn on if the battery is below 20 % and turn off if the battery is above 90%.
The charger is plugged into a zigbee wall plug
I can do it with 2 separate automations but was wondering if it can be done all in one? I am not good with getting multiple things going in one.
Another option is to use a Threshold sensor with a range:
Then your automation fires when the state of the sensor changes, and it only has one action If-Then, if the sensor is on, that means turn the charger off, else turn the charger on.
In my opinion, this is an elegant solution that allows you to control the range and therefore the thresholds separately from having to edit the automation by hand.
One restart or one manual switching action is all it takes to throw your toggle actions off. It is better to use more determinative actions like switch.turn_on and switch.turn_off.
Think about how your automation will flow. Assuming it is toggling correctly, when the charge goes above 90, the binary sensor will turn off, and the switch will be toggled off… then after a bit of use, the charge will drop below 90, the binary sensor will turn back on, and the switch will be toggled on. It will never make it to you lower threshold.
Better, but still not quite there. Conditions are not Waits, they are checked immediately.
Again, think about how the automation flows… The battery charge drops below 30 triggering the automation, then the switch is turned on, next the condition is checked. The condition will always fail, because the value will always be just below 30 since it’s only been charging for maybe a second.
As I described previously, use two triggers and an If/Then action.
That one will also fail to turn off during charging.
You need to trigger on both events when the charge crosses the threshold values:
I just stick to two triggers. Simple and solid then.
alias: Turn off phone charger at 84%
description: ""
triggers:
- trigger: numeric_state
entity_id: sensor.phone_battery_level
above: 85
actions:
- action: switch.turn_off
data: {}
target:
entity_id:
- switch.charger_socket
mode: single
conditions:
- condition: state
entity_id: binary_sensor.phone_charging
state: "on"
alias: Turn on phone charger socket at 20%
description: Power up charger cable ready
triggers:
- trigger: numeric_state
entity_id: sensor.phone_battery_level
below: 20
actions:
- action: switch.turn_on
data: {}
target:
entity_id: switch.charger_socket
mode: single
conditions: []
These are two different states you are watching for, so why not have two different automations?
I like to keep things simple. In my case it is a mobile phone with the HA app giving out a charge state.
As it is a mobile I am charging I have sometimes added a “turn on light” or “make a noise” in the 20% test to remind me I need to charge the phone