description: ""
mode: single
trigger:
- platform: state
entity_id:
- sensor.edwards_tablet_battery_level
condition: []
action:
- choose:
- conditions:
- condition: numeric_state
entity_id: sensor.edwards_tablet_battery_level
above: 80
alias: If battery is above 80% at any time
sequence:
- service: switch.turn_off
target:
entity_id: switch.tablet_charger
alias: Turn off charger
- conditions:
- condition: and
conditions:
- condition: numeric_state
entity_id: sensor.edwards_tablet_battery_level
below: 10
alias: Battery is below 10%
- condition: time
before: "06:00:00"
after: "21:00:00"
alias: It's night time
alias: Night time
sequence:
- service: switch.turn_on
target:
entity_id: switch.tablet_charger
alias: Turn on charger
- conditions:
- condition: numeric_state
entity_id: sensor.edwards_tablet_battery_level
below: 5
alias: Turn on charger if battery is below 5% regardless the time
sequence:
- service: switch.turn_on
target:
entity_id: switch.tablet_charger
alias: Turn on charger
But shouldn’t you charge to 80% during the night anyways?
With this logic you have a risk of starting your day with 11% battery, then you will have to charge during the day time.
Thank you very much for the very efficient and clear example. I had no idea we can use multiple conditions that way. It make a lot of sense for many automation I want to put together. You taught me a great deal today
As per your comment about charging at night, yes, you are right. In a way, I could decide to charge every night up to 80%. But I want to minimize the amount of cycle to safeguard the battery as much as possible.
I’ll monitor the result to see if there is a significant number of occurrence where it reaches 5% during day time. If it does, I’ll try to tweat the conditions according to the unloading pattern of the battery.