Jokerigno
(Jokerigno)
June 20, 2022, 7:33am
1
Hi,
I want to build an automation to turn on all lights in a room, but just the ones which are dimmerable (hue, for example. My ceiling light is controlled by a shelly1 so it is not dimmerable).
If I ask google to turn on at 50% lights in my Studio it only turns on light with that specific brightness.
I want to replicate is but maybe there’s something I’m missing:
Below my test
service: light.turn_on
data:
brightness_pct: 1
target:
area_id: "{{ area_id('Studio') }}"
any advice?
Thank you
Jokerigno
(Jokerigno)
June 20, 2022, 7:05pm
2
uhm, actually it works:
But what I want to achieve is a little bit complicated based on the amazing work made by @basnijholt here .
I want to turn on only lights dimmerable in a area so I tried to change the original autmotation to the following:
alias: 'Apple Watch: Imposta Luci (Duplica)'
description: ''
trigger:
- platform: event
event_type: ios.action_fired
event_data:
actionName: Imposta Luci
condition: []
action:
- service: notify.mobile_app_iphone_di_marco
data:
message: 'Apple Watch: imposta luci'
data:
actions:
- action: SET_LIGHTS_ALL
title: Tutte
- action: SET_LIGHTS_BEDROOM
title: Camera da Letto
- action: SET_LIGHTS_LIVING_ROOM
title: Soggiorno
- action: SET_LIGHTS_BATHROOM
title: Bagno Principale
- action: SET_LIGHTS_HALL_AND_STAIRS
title: Corridoio
- action: SET_LIGHTS_TOILET
title: Bagno Secondario
- action: SET_LIGHTS_KITCHEN
title: Cucina
- action: SET_STUDIO
title: Studio
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_ALL
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_BEDROOM
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_LIVING_ROOM
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_BATHROOM
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_HALL_AND_STAIRS
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_TOILET
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_KITCHEN
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_STUDIO
timeout: '00:00:20'
continue_on_timeout: false
- service: notify.mobile_app_iphone_di_marco
data:
message: 'Apple Watch: choose option'
data:
actions:
- action: LIGHTS_OFF
title: 'Off'
- action: LIGHTS_ON
title: 'On'
- action: LIGHTS_FIFTY
title: 50%
- action: LIGHTS_HUNDRED
title: 100%
- action: LIGHTS_ONE
title: 1%
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: LIGHTS_OFF
- platform: event
event_type: mobile_app_notification_action
event_data:
action: LIGHTS_ON
- platform: event
event_type: mobile_app_notification_action
event_data:
action: LIGHTS_FIFTY
- platform: event
event_type: mobile_app_notification_action
event_data:
action: LIGHTS_HUNDRED
- platform: event
event_type: mobile_app_notification_action
event_data:
action: LIGHTS_ONE
timeout: '00:00:20'
continue_on_timeout: false
- variables:
option: '{{ wait.trigger.event.data.action }}'
area: |
{{
{'SET_LIGHTS_ALL': 'all',
'SET_LIGHTS_BEDROOM': 'Camera da letto',
'SET_LIGHTS_LIVING_ROOM': 'Soggiorno',
'SET_LIGHTS_BATHROOM': 'Bagno Principale',
'SET_LIGHTS_HALL_AND_STAIRS': 'Corridoio, Disimpegno',
'SET_LIGHTS_TOILET': 'Bagno Secondario',
'SET_LIGHTS_KITCHEN': 'Cucina',
'SET_STUDIO': 'Studio',
}[wait.trigger.event.data.action] }}
- choose:
- conditions:
- condition: template
value_template: '{{ option == ''LIGHTS_OFF'' }}'
sequence:
- service: light.turn_off
target:
area_id: '{{ area_id(''area'') }}'
- conditions:
- condition: template
value_template: '{{ option == ''LIGHTS_ON'' }}'
sequence:
- service: light.turn_on
target:
area_id: '{{ area_id(''area'') }}'
- conditions:
- condition: template
value_template: '{{ option == ''LIGHTS_FIFTY'' }}'
sequence:
- service: light.turn_on
data:
brightness_pct: 50
target:
area_id: '{{ area_id(''area'') }}'
- conditions:
- condition: template
value_template: '{{ option == ''LIGHTS_HUNDRED'' }}'
sequence:
- service: light.turn_on
data:
brightness_pct: 100
target:
area_id: '{{ area_id(''area'') }}'
- conditions:
- condition: template
value_template: '{{ option == ''LIGHTS_ONE'' }}'
sequence:
- service: light.turn_on
data:
brightness_pct: 1
target:
area_id: '{{ area_id(''area'') }}'
mode: parallel
Maybe there’s some error in definining variable for AREA.
Any advice?
Jokerigno
(Jokerigno)
July 14, 2022, 9:58am
4
Up? Can someone please help me on this?
I think it is possible. But I don’t have such skills in templates and variables (too hard for me)
Jokerigno
(Jokerigno)
July 16, 2022, 6:05pm
5
@123 sorry to bother you and to take advantage of your kindness but do you mind to look at the draft of my automation above and support me?
123
(Taras)
July 16, 2022, 6:21pm
6
Change everywhere you have this:
area_id: '{{ area_id(''area'') }}'
To this:
area_id: '{{ area_id(area) }}'
By wrapping area
in quotes, you made it into a string instead of the name of a variable.
1 Like
Jokerigno
(Jokerigno)
July 16, 2022, 9:48pm
7
I still see an error (don’t know why I cannot simply copy-paste it)
below full automation:
alias: 'Apple Watch: Imposta Luci (Duplica)'
description: ''
trigger:
- platform: event
event_type: ios.action_fired
event_data:
actionName: Imposta Luci
condition: []
action:
- service: notify.mobile_app_iphone_di_marco
data:
message: 'Apple Watch: imposta luci'
data:
actions:
- action: SET_LIGHTS_ALL
title: Tutte
- action: SET_LIGHTS_BEDROOM
title: Camera da Letto
- action: SET_LIGHTS_LIVING_ROOM
title: Soggiorno
- action: SET_LIGHTS_BATHROOM
title: Bagno Principale
- action: SET_LIGHTS_HALL_AND_STAIRS
title: Corridoio
- action: SET_LIGHTS_TOILET
title: Bagno Secondario
- action: SET_LIGHTS_KITCHEN
title: Cucina
- action: SET_STUDIO
title: Studio
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_ALL
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_BEDROOM
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_LIVING_ROOM
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_BATHROOM
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_HALL_AND_STAIRS
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_TOILET
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_LIGHTS_KITCHEN
- platform: event
event_type: mobile_app_notification_action
event_data:
action: SET_STUDIO
timeout: '00:00:20'
continue_on_timeout: false
- service: notify.mobile_app_iphone_di_marco
data:
message: 'Apple Watch: choose option'
data:
actions:
- action: LIGHTS_OFF
title: 'Off'
- action: LIGHTS_ON
title: 'On'
- action: LIGHTS_FIFTY
title: 50%
- action: LIGHTS_HUNDRED
title: 100%
- action: LIGHTS_ONE
title: 1%
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: LIGHTS_OFF
- platform: event
event_type: mobile_app_notification_action
event_data:
action: LIGHTS_ON
- platform: event
event_type: mobile_app_notification_action
event_data:
action: LIGHTS_FIFTY
- platform: event
event_type: mobile_app_notification_action
event_data:
action: LIGHTS_HUNDRED
- platform: event
event_type: mobile_app_notification_action
event_data:
action: LIGHTS_ONE
timeout: '00:00:20'
continue_on_timeout: false
- variables:
option: '{{ wait.trigger.event.data.action }}'
area: |
{{
{'SET_LIGHTS_ALL': 'all',
'SET_LIGHTS_BEDROOM': 'Camera da letto',
'SET_LIGHTS_LIVING_ROOM': 'Soggiorno',
'SET_LIGHTS_BATHROOM': 'Bagno Principale',
'SET_LIGHTS_HALL_AND_STAIRS': 'Corridoio, Disimpegno',
'SET_LIGHTS_TOILET': 'Bagno Secondario',
'SET_LIGHTS_KITCHEN': 'Cucina',
'SET_STUDIO': 'Studio',
}[wait.trigger.event.data.action] }}
- choose:
- conditions:
- condition: template
value_template: '{{ option == ''LIGHTS_OFF'' }}'
sequence:
- service: light.turn_off
target:
area_id: '{{ area_id(area) }}'
- conditions:
- condition: template
value_template: '{{ option == ''LIGHTS_ON'' }}'
sequence:
- service: light.turn_on
target:
area_id: '{{ area_id(area) }}'
- conditions:
- condition: template
value_template: '{{ option == ''LIGHTS_FIFTY'' }}'
sequence:
- service: light.turn_on
data:
brightness_pct: 50
target:
area_id: '{{ area_id(area) }}'
- conditions:
- condition: template
value_template: '{{ option == ''LIGHTS_HUNDRED'' }}'
sequence:
- service: light.turn_on
data:
brightness_pct: 100
target:
area_id: '{{ area_id(area) }}'
- conditions:
- condition: template
value_template: '{{ option == ''LIGHTS_ONE'' }}'
sequence:
- service: light.turn_on
data:
brightness_pct: 1
target:
area_id: '{{ area_id(area) }}'
mode: parallel
Just for the record I checked in multiple areas and used area name with proper name (case sensitive)