Start charging phone when it goes to 20%

Hi. Ive been having a real problem with this. I First set up automation to start charging when it reached 20%.

alias: Hall Phone Start Charging
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.speaker_battery
    to: "20"
condition: []
action:
  - service: homeassistant.turn_on
    target:
      entity_id:
        - switch.hall_plug_speaker
    data: {}
mode: single

I can monitor the battery level and it goes down slowly but the automation is never fires.

So i figured I would set up an automation to fire if level is between 0 and 20 if the plug if off.

alias: Hall Phone Start Charging
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.speaker_battery
    to: "20"
    from: "0"
condition:
  - condition: state
    entity_id: switch.hall_plug_speaker
    state: "off"
action:
  - service: homeassistant.turn_on
    target:
      entity_id:
        - switch.hall_plug_speaker
    data: {}
mode: single

However this is when the state goes from 0 to 20, not is between 0 and 20.

Is there a way of seting up a range, or am I doing this wrong (I also tried a blueprint, Toggle switch on/off by battery (phone) level, and this never fired). I think the issue with this is maybe the battery percent is not updated often enough but watching it gores down slowly so this seems odd. I will also do another automation to turn off but can see this being more of a problem as it charges a lot faster.

Try this

alias: Hall Phone Start Charging
description: ""
trigger:
  - platform: numeric_state
    entity_id: sensor.speaker_battery
    below: 20
condition:
  - condition: state
    entity_id: switch.hall_plug_speaker
    state: "off"
action:
  - service: switch.turn_on
    target:
      entity_id:
        - switch.hall_plug_speaker
    data: {}
mode: single
1 Like