Hi, i installed Fully Kiosk on my wallet mounted tablet and I want to activate a switch (via MQTT) when battery level is under 30% and deativate it when it is above 80%.
I created the battery sensor in configuration.yaml:
Then I’ve created first automation to enable the switch (it is a shelly) when battery level is under 30 (and on each automation scripts restart / HA start).
The problem is that the automation works only on automation restart / HA start, but not when the battery change!! For example if battery is at 11% and change to 10% (or 12%), switch not trigger to ON.
Any suggest?
automation.yaml:
- id: '1713892150631'
alias: Controllo ricarica tablet muro (attiva ricarica)
description: se scende sotto la soglia di 30, si attiva la ricarica tablet
trigger:
- platform: homeassistant
event: start
- platform: event
event_type: automation_reloaded
- platform: numeric_state
entity_id:
- sensor.batteria_p20hd_tablet
below: 30
condition:
- condition: numeric_state
entity_id: sensor.batteria_p20hd_tablet
below: 30
action:
- type: turn_on
device_id: 2922070eeed47e13885b424c45f3169d
entity_id: switch.switch_ricarica_tablet_muro
domain: switch
mode: single
They are probably not expecting the battery to already be below the trigger level.
Your automation would work. It’s just that the level is already below 30. You would have to force it to change to above 30 then next time it falls below 30 your automation would trigger.
The way I have it triggers a lot more often but will catch this edge case.
Ok, so to prevent useless triggers, can i just add a condition like this? (I’ve found on community, i don’t know if there is a better way to find “on” or “off” state of switch)