I have a Kasa outlet that measures energy. To prevent charging my ebike batteries while they are already full, I have attempted this automation that should notice it’s being used, send a notification to my phone, and await a response. If it receives a YES, it should wait until the current dips below a certain amount and then turn itself off. It doesn’t seem to do anything with my YES command though.
alias: ⚙️🔋Kasa Energy - Turn off when done charging
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.barbados_high_charging
to: "on"
for:
hours: 0
minutes: 0
seconds: 0
action:
- alias: Set up variables for the actions
variables:
action_yes: "{{ \"YES_\" ~ context.id }}"
action_no: "{{ \"NO_\" ~ context.id }}"
- service: notify.mobile_app_zfold3
data:
message: Is this a bike battery?
data:
actions:
- action: "{{ action_yes }}"
title: "Yes"
- action: "{{ action_no }}"
title: "No"
- alias: Wait for a response
timeout:
hours: 1
minutes: 0
seconds: 0
milliseconds: 0
continue_on_timeout: false
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_yes }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_no }}"
- alias: Perform the action
choose:
- alias: Do something on YES
conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_yes }}"
sequence:
- repeat:
until:
- condition: numeric_state
entity_id: sensor.barbados_slim_current
below: 0.2
sequence: []
- service: switch.turn_off
data: {}
target:
entity_id: switch.barbados_slim
mode: single