yes, that works!
changed and shortened to this now, working fine.
- alias: Call service event (Light)'
id: 'Call service event (Light)'
trigger:
platform: event
event_type: state_changed
condition:
- condition: template
value_template: >
{% set skip_list = ['group_for_wakeup', 'group_for_wakeup_2', 'entertainmentruimte_2', entertainmentruimte_1] %}
{{ trigger.event.data.entity_id in state_attr('group.all_lights_only','entity_id') and
trigger.event.data.entity_id.split('.')[1] not in skip_list }}
action:
- service: python_script.summary
whats even better, this automation seems to be much lighter on the system than the one in which all lights are defined separately. Enableing that one causes many timing issues, and even disconnects from the Hue hub, the biggest issue in my setup for the last few months…
hope that too can be solved by this much more elegant and robust automation. (have several rebuilds to do now, cause there are more groups being checked in the setup, that can be rewritten in this way)
thx!
btw since Light is a valid domain, see Events - Home Assistant, wouldn’t this be possible:
platform: event
event_type: call_service
event_data:
domain: light
service: ['turn_on', 'turn_off']
or some valid service_template, or even leave out the service, since any call_service to the domain light would be ok to trigger the automation
- alias: Call service event (Light)'
id: 'Call service event (Light)'
trigger:
platform: event
event_type: call_service
event_data:
domain: light
condition:
- condition: template
value_template: >
{% set skip_list = ['group_for_wakeup', 'group_for_wakeup_2', 'entertainmentruimte_2', entertainmentruimte_1] %}
{{ trigger.event.data.entity_id.split('.')[1] not in skip_list }}
action:
- service: python_script.summary
this works perfectly! letting @petro know too, since we had a previous attempt…, which at least is solved now. Cool.
hiccup: lights that are turned on by the hue motion sensors and tradfri remotes don’t trigger the automation. Apparently that is not a service call.
To keep things tidy, I might have to use the event state_changed after all. Interesting this is.
if i would like to check more than 1 group, how would i need the change the state_attr(‘group.all_lights_only’,‘entity_id’)
?
With my python script Summary I see to these groups:
groups = ['group.family',
'group.hubs_binary_pinged',
'group.critical_devices_state',
'group.media_player_media',
'group.device_tracker_media',
'group.all_lights_only',
'group.iungo_switch_switches_template',
'group.iungo_switch_appliances_template',
'group.binary_sensors_active_template']
any change in these should trigger the automation to trigger the python script. So id need something like:
condition:
- condition: template
value_template: >
{% set groups = ['group.family',
'group.hubs_binary_pinged',
'group.critical_devices_state',
'group.media_player_media',
'group.device_tracker_media',
'group.all_lights_only',
'group.iungo_switch_switches_template',
'group.iungo_switch_appliances_template',
'group.binary_sensors_active_template'] %}
{{ trigger.event.data.entity_id in state_attr('[groups]','entity_id') }}
obviously the above is incorrect, what would be the correct syntax to check for entities in more than 1 group using this setup and write the following automation in a more intelligent short-hand…
- alias: 'Call state change event (all)'
id: 'Call state change event (all)'
# hide_entity: True
# initial_state: 'on'
trigger:
platform: event
event_type: state_changed
condition:
- condition: template
value_template: >
{{ trigger.event.data.entity_id in state_attr('group.family','entity_id') or
trigger.event.data.entity_id in state_attr('group.hubs_binary_pinged','entity_id') or
trigger.event.data.entity_id in state_attr('group.critical_devices_state','entity_id') or
trigger.event.data.entity_id in state_attr('group.media_player_media','entity_id') or
trigger.event.data.entity_id in state_attr('group.device_tracker_media','entity_id') or
trigger.event.data.entity_id in state_attr('group.all_lights_only','entity_id') or
trigger.event.data.entity_id in state_attr('group.iungo_switch_switches_template','entity_id') or
trigger.event.data.entity_id in state_attr('group.iungo_switch_appliances_template','entity_id') or
trigger.event.data.entity_id in state_attr('group.binary_sensors_active_template','entity_id') }}
action:
service: python_script.summary
@pnbruckner and @petro, may I please ask to have another look at this?
thx,
Marius