Automating Tablet charging at lower tarif

Hey there.

My ADHD brain is way too complex to make things simple. I’m lost.

What I’m looking to achieve sounds simple, but I can’t find an easy way to make it.

If my tablet battery is below 10% between 9pm and 6am, it should charged until it reaches 80%.

However, if it reaches 5% between 6am and 9pm, it should charge a bit, so it doesn’t turn off before it’s 9pm…

So, who has a functioning brain to propose a reliable solution ?

That is probably what you asked for:

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 :slight_smile:

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.

1 Like