Turn on off smart plug based on bluetti battery states

Im trying to make an automation based on the battery state of my ac200 max solar generator. I can get it to turn on when it falls below a certain threshold but I cant get the smart plug to turn off at the higher percentage. Basically trying to get it to turn on below 15% and turn off at 30% but im not smart enough to figure the second part out.

alias: test1
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.ac200m2210001048370_total_battery_percent
    for:
      hours: 0
      minutes: 1
      seconds: 0
    below: 15
condition: []
action:
  - type: turn_on
    device_id: 43e0db42fd27b7be4693107cc2f5b5a3
    entity_id: 14a5c879969f4d7f81f971df63225022
    domain: switch
  - if:
      - condition: numeric_state
        entity_id: sensor.ac200m2210001048370_total_battery_percent
        above: 30
    then:
      - type: turn_off
        device_id: 43e0db42fd27b7be4693107cc2f5b5a3
        entity_id: 14a5c879969f4d7f81f971df63225022
        domain: switch
mode: single

This is only going to trigger when your sensor is below 15. Your “if above 30” will never occur.

Add another trigger (above 30) or put that in a separate automation. Honestly sometimes two automations is simpler.

Also: please consider this:

Here’s one solution:

alias: test1
description: ""
trigger:
  - platform: numeric_state
    entity_id:
      - sensor.ac200m2210001048370_total_battery_percent
    for:
      hours: 0
      minutes: 1
      seconds: 0
    below: 15
  - platform: numeric_state
    entity_id:
      - sensor.ac200m2210001048370_total_battery_percent
    above: 30
condition: []
action:
  - if:
      - condition: numeric_state
        entity_id: sensor.ac200m2210001048370_total_battery_percent
        below: 15
    then:
      - service: switch.turn_on
        target:
          entity_id: 14a5c879969f4d7f81f971df63225022
  - if:
      - condition: numeric_state
        entity_id: sensor.ac200m2210001048370_total_battery_percent
        above: 30
    then:
      - service: switch.turn_off
        target:
          entity_id: 14a5c879969f4d7f81f971df63225022
mode: single

Also you should really consider changing your entity_ids to something meaningful rather than a random string of digits.

Thank you, I assume it would be super simple to do 2 automations I was just trying to combine them into one. I dont have enough experience using automations yet.

Yeah I don’t get why people always want to do that if two is simpler :man_shrugging:

Just yesterday I was trying to automate my bathroom fans if the heating lamps are on (fan must run to keep them cool) or excess humidity or manually calling for the fan to turn on or off. It got complicated as heck until I split it into two automations, one for on and one for off.