Hello! I am trying to make an ESPHome configuration where a connected light is either constantly on (when the button is not pressed) or flickering/strobing (when the button is pressed - it needs to be manually reset to become ‘unpressed’). However, I cannot figure out how to add custom light effects in a script, as I get the following error:
string value cannot be dictionary or list.
Below is my code, with the last block (-strobe
and onwards) giving me the error:
esphome:
name: esp-alarm-button-1
platform: ESP32
board: nodemcu-32s
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
domain: .XXXX
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "esp alarm button 1"
password: !secret backup_password
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret backup_password_2
encryption:
key: "XXXX"
ota:
password: !secret backup_password_2
# "The esp32_ble_tracker component creates a global hub so that you can track bluetooth low energy devices using your ESP32 node."
# https://esphome.io/components/esp32_ble_tracker.html
esp32_ble_tracker:
# Sync time with Home Assistant.
time:
- platform: homeassistant
id: homeassistant_time
switch:
# Switch to restart the device.
- platform: restart
name: esp-alarm-button-1 Restart
light:
- platform: binary
internal: yes
name: "esp alarm light 1"
id: light_green
restore_mode: ALWAYS_ON #Always initialize the light as ON on bootup.
output: light_green_output
effects:
- strobe:
name: "Emergency blink"
colors:
- state: true
duration: 250ms
- state: false
duration: 250ms
output:
- id: light_green_output
platform: gpio
pin:
number: 4 #D4
inverted: false
# Button (with automations for on and off)
binary_sensor:
- platform: gpio
id: alarm_button
name: Alarm button 1
pin:
number: 15
mode: INPUT_PULLUP
inverted: false
filters:
# Small filter, to debounce the button press.
- delayed_on: 1000ms
- delayed_off: 1000ms
# Automations (call scripts)
on_press:
- script.execute: alarm_script
on_release:
- script.execute: normal_script
#Script: 1 for emergency, 1 for normal use
script:
- id: normal_script
then:
- light.turn_on:
id: light_green
- id: alarm_script
then:
- light.turn_on:
id: light_green
effect:
- strobe:
colors:
- state: true
duration: 250ms
- state: false
duration: 250ms
Is it possible to either add the custom strobe values to the script, or to otherwise have the script call the previously defined custom strobe effect? If possible, it would be nice to do it all in the configuration, without an extra automation within Home Assistant.
Thank you in advance!