Haha, nice.
I was thinking of this too, but then with a slightly different approach.
My idea was/is to store the charging time to full charge in a helper and set a āwake-up timeā, so it would start charging ājust in timeā to be fully charged at the moment I get out of bed. Off course it should always start charging when my phone hits 1%.
Is it possible to fork/change this blueprint to individual needs?
IĀ“m thinking of just notifying when threshold is reached instead of switching off the power plug - because on that power plug more than one device is charged at the same time.
Great work! I added an additional feature though. If Iām at work charging my phone, I donāt want my plug turning off since something else might be plugged in at that time. So to solve this, I added the condition that I should be home for the plug to turn off.
The code:
blueprint:
name: Turn off charging after device is charged
description: Turn off the smart plug/relay after the device is charged to a given
percent.
domain: automation
input:
switch:
name: Smart plug
description: Smart plug/relay to turn off
selector:
entity:
domain: switch
phone_battery:
name: Phone Battery
description: Battery level sensor
selector:
entity:
domain: sensor
device_class: battery
charged_percent:
name: Charge percent
description: Charge device to this percent
selector:
number:
min: 0.0
max: 100.0
unit_of_measurement: '%'
mode: box
step: 1.0
default: 100
person_home:
name: Person
description: Person that should be home for the plug to turn off
selector:
entity:
domain: person
source_url: https://community.home-assistant.io/t/turn-off-phone-charging-after-the-phone-is-charged/253939
variables:
phone_battery: !input 'phone_battery'
charged_percent: !input 'charged_percent'
person_home: !input 'person_home'
trigger:
- platform: state
entity_id: !input 'phone_battery'
condition:
condition: and
conditions:
- condition: template
value_template: '{{ (states(phone_battery)|int) >= (charged_percent|int) }}'
- condition: state
entity_id: !input 'person_home'
state: home
action:
- service: switch.turn_off
entity_id: !input 'switch'
I think I have this working pretty reliably in a blueprint/automation. However, it seems my phone, a OnePlus 6t, is going several % over and under before HA knows to turn off/on the switch/plug. Iāve read the polling for updating entities is about 30 seconds. However, this is several minutes, sometimes 10 minutes before it updates and either starts charging or stops. Any thoughts on a more frequent update of a battery level entity?
Same issue especially with my iDevices: they fall in deep sleep on WiFi and HA sensors are not updated at all or after hours. Canāt really use that automationā¦ -.-
Hi, Iām new here and just learning.
I have tried to do as you have said, but the extra option for turning on is not showing up in HA.
Can you share Full Blueprint please, just getting my head around this coding, then i can compare the 2 and see where i have gone wrong
Update: meanwhile because of this for all my charging stations I use smart plugs with power measurement and another blueprint. That way e. g. my iPhone can sleep with flight mode active during the night and the smart plug stops charging automatically. Works great for months now.
Thanks! This works for me (unfortunately only with the Shortcuts App in IOS (If I close the HA App the sensors are not updating)
But I have a question. If the iPhone is charged at 85% the power goes off, I unplugged the iPhone and then the power plug should be active again or not?!
Logger: homeassistant.components.websocket_api.http.connection
Source: components/websocket_api/connection.py:140
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 17. September 2022 um 20:44:34 (6 occurrences)
Last logged: 08:51:23