Page MenuHomeSealhub

Charging_Light_Automation

Authored By
cichy1173
Jan 27 2026, 21:25
Size
6 KB
Referenced Files
None
Subscribers
None

Charging_Light_Automation

blueprint:
name: Phone Charging Battery Light
description: >
Changes a light's color based on your phone's battery level while charging.
- Red: Battery below 50%
- Orange: Battery between 50-89%
- Green: Battery 90% or above
When the phone stops charging, the light returns to a customizable "idle" color (default: blue).
domain: automation
input:
phone_battery_sensor:
name: Phone Battery Level Sensor
description: The battery level sensor of your phone (e.g., sensor.pixel_8_pro_battery_level)
selector:
entity:
filter:
- domain: sensor
device_class: battery
phone_charging_sensor:
name: Phone Charging Sensor
description: The binary sensor that indicates if the phone is charging (e.g., binary_sensor.pixel_8_pro_is_charging)
selector:
entity:
domain: binary_sensor
target_light:
name: Target Light
description: The light to change color based on battery level
selector:
entity:
filter:
- domain: light
low_battery_threshold:
name: Low Battery Threshold
description: Battery percentage below which the light turns red
default: 50
selector:
number:
min: 10
max: 100
unit_of_measurement: "%"
mode: slider
high_battery_threshold:
name: High Battery Threshold
description: Battery percentage at or above which the light turns green
default: 90
selector:
number:
min: 10
max: 100
unit_of_measurement: "%"
mode: slider
low_battery_color:
name: Low Battery Color
description: Color when battery is low (default red)
default: [255, 0, 0]
selector:
color_rgb:
medium_battery_color:
name: Medium Battery Color
description: Color when battery is medium (default orange)
default: [255, 102, 0]
selector:
color_rgb:
high_battery_color:
name: High Battery Color
description: Color when battery is high (default green)
default: [0, 255, 4]
selector:
color_rgb:
idle_color:
name: Idle Color (Not Charging)
description: Color when the phone stops charging (default blue)
default: [0, 0, 255]
selector:
color_rgb:
brightness:
name: Light Brightness
description: Brightness of the light (percentage)
default: 100
selector:
number:
min: 1
max: 100
unit_of_measurement: "%"
mode: slider
only_when_light_on:
name: Only When Light Is Already On
description: Only change colors if the light is already on (won't turn on the light if it's off)
default: true
selector:
boolean:
variables:
low_threshold: !input low_battery_threshold
high_threshold: !input high_battery_threshold
low_color: !input low_battery_color
medium_color: !input medium_battery_color
high_color: !input high_battery_color
idle_color: !input idle_color
brightness_pct: !input brightness
only_if_on: !input only_when_light_on
light_entity: !input target_light
battery_sensor: !input phone_battery_sensor
triggers:
# Trigger when phone starts charging
- trigger: state
entity_id: !input phone_charging_sensor
to: "on"
id: started_charging
# Trigger when phone stops charging
- trigger: state
entity_id: !input phone_charging_sensor
to: "off"
id: stopped_charging
# Trigger when battery level changes while charging
- trigger: state
entity_id: !input phone_battery_sensor
id: battery_changed
conditions: []
actions:
- choose:
# When phone stops charging, return to idle color
- conditions:
- condition: trigger
id: stopped_charging
sequence:
- if:
- condition: template
value_template: "{{ not only_if_on or is_state(light_entity, 'on') }}"
then:
- action: light.turn_on
target:
entity_id: !input target_light
data:
rgb_color: "{{ idle_color }}"
brightness_pct: "{{ brightness_pct }}"
# When charging starts or battery level changes
- conditions:
- condition: or
conditions:
- condition: trigger
id: started_charging
- condition: trigger
id: battery_changed
sequence:
# Only proceed if phone is charging
- condition: state
entity_id: !input phone_charging_sensor
state: "on"
# Check if light should be updated (only_when_light_on setting)
- if:
- condition: template
value_template: "{{ not only_if_on or is_state(light_entity, 'on') }}"
then:
- choose:
# Low battery (below threshold)
- conditions:
- condition: template
value_template: "{{ states(battery_sensor) | int < low_threshold }}"
sequence:
- action: light.turn_on
target:
entity_id: !input target_light
data:
rgb_color: "{{ low_color }}"
brightness_pct: "{{ brightness_pct }}"
# Medium battery (between thresholds)
- conditions:
- condition: template
value_template: "{{ states(battery_sensor) | int >= low_threshold and states(battery_sensor) | int < high_threshold }}"
sequence:
- action: light.turn_on
target:
entity_id: !input target_light
data:
rgb_color: "{{ medium_color }}"
brightness_pct: "{{ brightness_pct }}"
# High battery (at or above threshold)
- conditions:
- condition: template
value_template: "{{ states(battery_sensor) | int >= high_threshold }}"
sequence:
- action: light.turn_on
target:
entity_id: !input target_light
data:
rgb_color: "{{ high_color }}"
brightness_pct: "{{ brightness_pct }}"
mode: single

File Metadata

Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1106141
Default Alt Text
Charging_Light_Automation (6 KB)

Event Timeline