I have plenty of Insteon scenes where multiple dimmer switches control a single load (virtual 3-way switches). One switch actually controls the electrical load, and the rest act as synchronized remotes.
To keep the indicators on all the dimmers in sync when turning on/off or dimming the load, I hide the non-load-bearing switches (and the scene itself) in my HA instance, and use automations to sync up the non-load-bearing switches when the state of the load-bearing switch changes.
Recently, I realized that this was causing excessive traffic, because not only do the automations run when I change the state of the device using HA, but also when I change it using a switch on the wall.
To address this, I want to change my automation triggers to use the “event” platform, instead of the “state” platform, so it will only trigger the automations when the HA instance changes the load, reducing unnecessary and redundant insteon traffic. The problem is, I can’t figure out how to pass brightness data to the action based on the ‘event’ trigger.
My old automation looked like this:
automation
- alias: 'Dimmer Fix Kitchen Chandelier On'
trigger:
platform: state
entity_id: light.kitchen_chand_1_by_thermosta
to: 'on'
action:
service: light.turn_on
entity_id:
- light.kitchen_chand_2_by_intercom
data_template:
brightness: '{{ trigger.to_state.attributes.brightness }}'
This worked like a charm - the data_template in the action picked up the brightness from the changed state, and passed it to the secondary dimmer switch to sync its indicators.
My new automation looks like this:
automation
- alias: 'Dimmer Fix Kitchen Chandelier On'
trigger:
platform: event
event_type: call_service
event_data:
service_data:
entity_id: light.kitchen_chand_1_by_thermosta
domain: homeassistant
service: turn_on
action:
service: light.turn_on
entity_id:
- light.kitchen_chand_2_by_intercom
data_template:
brightness: '{{ trigger.event.service_data.brightness }}'
This doesn’t work so well. The triggers seem fine - it fires if I comment out the data_template lines, but I can’t figure out how to get the brightness passed to the action.
According to https://home-assistant.io/docs/automation/templating/, the available trigger data for the event platform includes trigger.event, and according to https://home-assistant.io/docs/configuration/events/, the call_service event should include service_data.brightness.
I’ve also tried: trigger.event.service_data.attributes.brightness
and changing the domain for the trigger to ‘light’ instead of ‘homeassistant’
Can anyone help me figure this out?
Thanks!