sabot105mm
(Sabot105mm)
February 17, 2021, 11:41pm
1
ive been grinding my gears trying to figure-out how to get a entity_id from an event-click for one of my automations; I’ve come-up short everytime trying every possible permutation i can think of trying to get this to work. goal is to create a reusable dimming automation for all my lights. please tell me this is possible
alias: New Automation
description: ''
trigger:
- platform: event
event_type: click
event_data:
entity_id:
- light.stairs_spot_lights
- light.bar_spot_lights
- light.den_spot_lights
- light.dining_room_spot_lights
- light.front_bedroom_chandalier
- light.front_foyer_chandelier
- light.front_foyer_spot_lights
- light.guest_room_chandalier
- light.kitchen_island_pendants
- light.kitchen_spot_lights
- light.living_room_chandelier
- light.living_room_spot_lights
action:
- service: light.turn_on
data_template:
entity_id: '{{ trigger.event.data.entity_id }}'
brightness_step_pct: '{{ 25 |float }}'
mode: single
max: 10
log errors:
Error while executing automation automation.new_automation: Error rendering data template: UndefinedError: 'trigger' is undefined
That error message suggests you’re trying to fire that automation’s action manually via the automation.trigger service (or the execute button in the UI), thus there is no trigger object for the template to resolve.
sabot105mm
(Sabot105mm)
February 18, 2021, 1:18am
3
I’ve tested only with connected Lutron light so far.
type: button
tap_action:
action: call-service
service: automation.trigger
service_data:
entity_id: automation.new_automation
entity: light.stairs_spot_lights
log error from light
Error while executing automation automation.new_automation: Error rendering data template: UndefinedError: 'trigger' is undefined
Yeah, exactly as I said, you’re using the automation.trigger service to fire the action of the automation.
Your automation isn’t being triggered, so the trigger object doesn’t exist.
You need the event to trigger the automation.
1 Like
sabot105mm
(Sabot105mm)
February 18, 2021, 1:34am
5
I’m clueless how to activate the automation - i took out the tap-action call service auto-trigger(using the click to activate the automation)
all it does is turn the light on, it should increment the brightness%
Why do you need an automation for this at all? Why not just call the service from the button itself?
type: button
tap_action:
action: call-service
service: light.turn_on
service_data:
entity_id: light.stairs_spot_lights
brightness_step_pct: 20
entity: light.stairs_spot_lights
?
sabot105mm
(Sabot105mm)
February 18, 2021, 1:43am
7
ha-floorplan entities inherit the tap-action so its not possible to create unique tap-action entity_id
type: 'custom:floorplan-card'
title: Light
config:
image: /local/images/floorplan/drawing.svg
stylesheet: /local/images/floorplan/images.css
defaults:
hover_action:
action: hover-info
tap_action:
action: more-info
rules:
- entities:
- light.den_spot_lights
- light.bar_spot_lights
- light.dining_room_spot_lights
- light.front_bedroom_chandalier
- light.front_foyer_chandelier
- light.front_foyer_spot_lights
- light.kitchen_island_pendants
- light.kitchen_spot_lights
- light.living_room_chandelier
- light.living_room_spot_lights
- light.master_bedroom_chandalier
- light.master_bedroom_spot_lights
- light.stairs_spot_lights
tap_action:
- action: call-service
service: automation.trigger
service_data:
entity_id: automation.light_increment2
double_tap_action:
- action: toggle
state_action:
- action: call-service
service: floorplan.style_set
service_data: |
fill: ${ entity.state === "on" ? "#F9D27C" : "#7CB1F9" };
transition: ${ entity.state === "off" ? "fill 5s ease" : "" };
OK. I’ve tried to explain where you’re going wrong regarding using the automation.trigger service. I’ve also explained how to do this directly with supported lovelace components. I can’t really help you any further
sabot105mm
(Sabot105mm)
February 18, 2021, 1:49am
9
that’s fine thank’s for your help