Hi folks,
I wanted HA to set a night scene when I plug my phone in the charger at night. This is inspired by another user who is doing this by reading the power-draw of a z-wave power plug. I don’t have z-wave jet, so I chose to use what I already had - iCloud.
This is a simple little automation that activates a night scene using the battery_status attribute in the iCloud component (or specifically in my usecase changes my status to activate a night scene.)
- alias: 'Set Sleep status when battery is charging + night + home'
trigger:
platform: template
value_template: "{{ is_state_attr('device_tracker.iphone', 'battery_status', 'Charging') }}"
condition:
condition: and
conditions:
- condition: time
after: '21:00:00'
before: '05:00:00'
- condition: state
entity_id: device_tracker.iphone
state: 'Home'
action:
- service: input_select.select_option
data:
entity_id: input_select.michael_status
option: 'Sleeping'
This solution is not instant like a z-wave device would be. However my night scene is just turning off lights and powerplugs so i have no problem with a slight 10-20 min delay.