I have been trying to get this to work for a few days now and I continue to run into issues.
I have 1 LED strip being controlled by WLED. My goal is to have it change to a preset when it detects my phone is charging. Will run for 10 secs and return to the state it was in.
I have created 1 automation and 2 scripts.
Script one: Captures the brightness, color and effect.
alias: WLED_Current_Data
sequence:
- service: input_text.set_value
data_template:
entity_id: input_text.original_brightness
value: "{{ state_attr('light.esb8266_no_strip', 'brightness') | default(255) }}"
- service: input_text.set_value
data_template:
entity_id: input_text.original_rgb_color
value: >-
{{ state_attr('light.esb8266_no_strip', 'rgb_color') | default([255,
255, 255]) | tojson }}
- service: input_text.set_value
data_template:
entity_id: input_text.original_effect
value: "{{ state_attr('light.esb8266_no_strip', 'effect') | default('') }}"
The second script is to restore the LED Stip based off what script one captures.
alias: Restore_WLED_Settings
sequence:
- service: light.turn_on
data_template:
entity_id: light.esb8266_no_strip
brightness: "{{ states('input_text.original_brightness') | default(255) | int }}"
rgb_color: >-
{{ states('input_text.original_rgb_color') | default('[255, 0, 0]') }}
# Default color
effect: "{{ states('input_text.original_effect') | default('Fade') }}"
Here is my automation
alias: Phone Charging
description: When phone is charging
trigger:
- platform: state
entity_id: sensor.le2127_battery_state_2
to: charging
condition: []
action:
- service: script.turn_on
entity_id: script.WLED_Current_Data # Corrected script entity ID
- service: light.turn_on
entity_id: light.esb8266_no_strip
data_template:
brightness: >-
{{ state_attr('light.esb8266_no_strip', 'brightness') | int(default=255) }}
rgb_color: "{{ state_attr('light.esb8266_no_strip', 'rgb_color') }}"
effect: "{{ state_attr('light.esb8266_no_strip', 'effect') }}"
- device_id: c317f52b9f515e77f8fb61265acf21e2
domain: select
entity_id: cd727352b07b272c599a57f0a402d192
type: select_option
option: Phone charging
- delay:
seconds: 10
- service: script.turn_on
entity_id: script.Restore_WLED_Settings # Corrected script entity ID
mode: single
Wondering if I am thinking of this wrong but this seems to be more of a hassle than I thought it would be lol. Ive heard some mention to use scenes but I do not have any preloaded settings I keep this strip at. I like to change to my liking lol.