#show me the event and I ll have a
1 messages · Page 1 of 1 (latest)
alias: Kitchen lights on
description: Turn on all kitchen lights on any double-click
trigger:
- platform: event
event_type: esphome.sink-light
event_data:
title: double_click
condition: []
action: - type: turn_on
device_id: 5a013d358105abd7320bbb06c1185eea
entity_id: switch.sink_light
domain: switch - type: turn_on
device_id: c9eca387cf227551364f7bbd29238fca
entity_id: switch.kitchen_lights
domain: switch - type: turn_on
device_id: a061adf75762b096af46381fe7cd96c2
entity_id: switch.counter_lights
domain: switch - type: turn_on
device_id: 75e6c41527a87e1f17ba6ad5aa1ea362
entity_id: switch.kitchen_cabinets
domain: switch
mode: single
That's the automation that works right now
I need the event data
go to developer tools -> events. Register for the esphome.sink-light and send me an example output
because that current automation doesn't really show what the source of the event is
event_type: esphome.sink-light
data:
device_id: 5a013d358105abd7320bbb06c1185eea
title: double_click
origin: LOCAL
time_fired: "2023-06-21T18:36:58.060354+00:00"
context:
id: 01H3FKXPAC1G7S53QKBVGYHQZE
parent_id: null
user_id: null
so esphome.sink-light is the source?
^^ This is malleable, coding ESPHome wasn't all that difficult to me.
then there's no automated way to do this without adding a 'configuration'.
Yes. Or at least a representative source.
is your area 'Kitchen'?
well because your events are unique to the device, all you can do is make an automation that has a trigger id that matches your area. Then turn on/off the area.
HA thing
here's your automation
trigger:
- id: Kitchen
platform: event
event_type: esphome.sink-light
event_data:
title: double_click
action:
- service: home_assistant.turn_on
target:
area: "{{ trigger.id }}"
just add triggers with the appropriate id
keep in mind, it will turn on all devices in that area.
yeah, was just thinking about how to filter.
Not bad in my kitchen, but in some other areas it looks like it would e.g. turn on the TV
right, and you'd need to create a template to filter out the entities in that case
and then you'd use
target:
entity_id: "{{ ... template here }}"
instead of just a blanket area
You'll also want to make the automation run in mode: parallel
Is there a way to pick up the event as an object that can be accessed within the action?
trigger.event is the object
look at the automation templating documentation, also view the trace. It will show you the entire object
specifically look at the variables tab
with a trigger selected
OK, I'll read here: https://www.home-assistant.io/docs/configuration/templating/
thats the templating docs that covers functions
Where would I view the trace? (Or where would I find docs about that?)
you want the automation templating docs that describe the trigger objects
every automation has a trace button when you go into the automation
i think it's called view traces
or trace
OK, found that
upper right corner
if the automation has been triggered, there will be a path it took, just click on the changed variables lower tab
but you have to make sure the trigger node is selected (which will be selected by default)
Here's what I settled on:
description: Turn on all kitchen lights on any double-click
trigger:
- platform: event
event_type:
- esphome.sink-light
- esphome.counter-light
- esphome.kitchen-light
- esphome.kitchen-cabinets
event_data:
title: double_click
condition: []
action:
- service: switch.turn_on
target:
entity_id:
- switch.sink_light
- switch.counter_lights
- switch.kitchen_lights
- switch.kitchen_cabinets
data: {}
mode: single```
yep, but that will only work with that one set
I know. Doing something with a naming convention (like giving the trigger an id that matches the area) struck me as too brittle. Parsing the event so the trigger part could be generalized was getting nowhere, and if that wouldn't generalize it would render moot the value of generalizing the action part. This at least reduces the automation to 1/area, which isn't quite what I want, but not onerous. It also gives some flexibility if I decide later to refine which entities are controlled.