Smart Plug controlled by Battery Level?

Would someone please assist. What is the proper way to control a smart (zwave switch) by battery level?

i tried the following, with no luck:

id: '1632445786141'
  alias: Turn off poe switch
  description: ''
  - platform: state
    entity_id: sensor.lenovo_tb_x306f_battery_level
    from: '80'
    to: '101'
    attribute: unit_of_measurement
  - condition: state
    entity_id: sensor.lenovo_tb_x306f_battery_state
    state: charging
  - type: turn_off
    device_id: dc31e4a867330c96f542880b192a2e59
    entity_id: switch.poe_switch
    domain: switch
  mode: single

Sure that 101% is correct?

I don’t understand the from 80 to 101. I can see 99 to 100. Will you battery level ever be over 100? Does it only report in 20% increments?

sorry thats not how i started it. I began trying other examples to see if it would work.

Im trying to implement the 80/20 rule

Ok, so you want it to charge when it drops below 80% and turn off plug when at 100%…is that correct?

i want it to stop charging when the device reaches 80% battery life.

ive been using ifttt to charge when it drops below 20 (works) and tasker for over 80 (this was also unsuccessful) but i’ll move that automation over to HA once i can get this one to work

For now let’s try two different automation and then combine later once it is working the way you want.
For the ‘off’ automation remove everything from the ‘from’ and put ‘80’ in the ‘to’. You could put 80 in either the to or from if you want but not both, the difference would be it stops charging at either 79 to 80 transition or the transition of 80 to 81, your choice.
Look at dev tools and verify you want the data from the unit_of_measurement attribute, my guess is that you don’t.
Be aware this automation will not work if the computer is powered off.

1 Like

For this automation I installed this blueprint

Open your Home Assistant instance and show the blueprint import dialog with a specific blueprint pre-filled.

1 Like

you’re right, theres nothing there for unit of measurement

thank you for this. ill see if this works