hatarez
December 22, 2022, 2:51pm
27
Thanks for the info. I just find out that I have this automation on the Philips Hue app so yesterday it did overlap and it is not going to be a valid test.
I will try testing with the dev tools as you guided me later today, but I guess the next few days will tell.
Happy Holidays guys and thank you so much for the help.
1 Like
hatarez
December 24, 2022, 5:29pm
28
Hey @123 , I have another entity to add to the automation that goes on at the same time but off at 9 PM. How can I add it?
I did like this but the id: âoff2â does seem to be a thing. Itâs seems more to be a status id.
- id: "1671664177077"
alias: "Lights: Exterior Automation"
description: ""
trigger:
- platform: numeric_state
entity_id: sun.sun
attribute: elevation
below: 1.8
- platform: numeric_state
entity_id: sun.sun
attribute: elevation
above: -3.1
- platform: time
id: "off"
at: "00:00:00"
- platform: time
id: "off2"
at: "21:00:00"
- platform: homeassistant
event: start
condition: []
action:
- variables:
e: "{{ state_attr('sun.sun', 'elevation') | float }}"
- choose:
- conditions:
- condition: template
value_template: "{{ e <= 1.8 }}"
- condition: template
value_template: "{{ is_state('light.exterior', 'off') }}"
- condition: template
value_template: "{{ is_state('light.exteriorspecial', 'off') }}"
- condition: template
value_template: "{{ is_state('switch.light_plug_1_switch', 'off') }}"
sequence:
- service: light.turn_on
data: {}
target:
entity_id:
- light.exterior
- light.exteriorspecial
- switch.light_plug_1_switch
- conditions:
- condition: template
value_template: "{{ e >= -3.1 }}"
- condition: template
value_template: "{{ is_state('light.exterior', 'on') }}"
sequence:
- service: light.turn_off
target:
entity_id: light.exterior
data: {}
- conditions:
- condition: trigger
id: "off"
sequence:
- service: light.turn_off
data: {}
target:
entity_id:
- light.exteriorspecial
- switch.light_plug_1_switch
- conditions:
- condition: trigger
id: "off2"
sequence:
- service: light.turn_off
data: {}
target:
entity_id:
- light.on_off_plug_1_2
mode: single
hatarez
December 24, 2022, 6:36pm
30
@123 So I applied your automation, that ended up my solution , end when I needed to add another identity I followed along with what it is.
Oh man, you are right, I pasted the wrong one into my automation. Let me fix it.
hatarez
December 24, 2022, 6:43pm
31
What about this? Does it look right?
- alias: 'Scheduled Exterior'
trigger:
- platform: numeric_state
entity_id: sun.sun
attribute: elevation
below: 1.8
- platform: numeric_state
entity_id: sun.sun
attribute: elevation
above: -3.1
- platform: time
at: '00:00:00'
- platform: homeassistant
event: start
action:
- variables:
e: "{{ state_attr('sun.sun', 'elevation') | float }}"
- choose:
- conditions:
- "{{ e <= 1.8 }}"
- "{{ is_state('light.exterior', 'off') or is_state('light.exteriorspecial', 'off') or is_state('switch.light_plug_1_switch', 'off')}}"
sequence:
- service: light.turn_on
target:
entity_id:
- light.exterior
- light.exteriorspecial
- switch.light_plug_1_switch
- conditions:
- "{{ e >= -3.1 }}"
- "{{ is_state('light.exterior', 'on') }}"
sequence:
- service: light.turn_off
target:
entity_id: light.exterior
- conditions:
- "{{ 0 <= now().hour < 16 }}"
- "{{ is_state('light.exteriorspecial', 'on') }}"
sequence:
- service: light.turn_off
target:
entity_id: light.exteriorspecial
- conditions:
- "{{ 0 <= now().hour < 13 }}"
- "{{ is_state('switch.light_plug_1_switch', 'on') }}"
sequence:
- service: light.turn_off
target:
entity_id: switch.light_plug_1_switch
default: []
mode: single
hatarez
December 24, 2022, 7:17pm
32
hatarez:
0 <= now().hour < 16
Would you also explain this, I canât understand how this matches 24:00 hour.
hatarez
December 24, 2022, 10:59pm
34
What about the additional entity I added?
hatarez
December 26, 2022, 6:24pm
35
I think I got it, but something is wrong with the last lines. I am getting this error Invalid config for [automation]: Expected a dictionary @ data['action'][1]['choose'][3]['conditions'][1]. Got None. (See /config/configuration.yaml, line 4)
and when I remove the last piece it goes away. Any thoughts?
- alias: Scheduled Exterior
trigger:
- platform: numeric_state
entity_id: sun.sun
attribute: elevation
below: 1.8
- platform: numeric_state
entity_id: sun.sun
attribute: elevation
above: -3.1
- platform: time
at: 00:00:00
- platform: time
at: "21:00:00"
- platform: homeassistant
event: start
action:
- variables:
e: "{{ state_attr('sun.sun', 'elevation') | float }}"
- choose:
- conditions:
- "{{ e <= 1.8 }}"
- "{{ is_state('light.exterior', 'off') or is_state('light.exteriorspecial',
'off') or is_state('light.on_off_plug_1_5', 'off')}}"
sequence:
- service: light.turn_on
target:
entity_id:
- light.exterior
- light.exteriorspecial
- light.on_off_plug_1_5
- conditions:
- "{{ e >= -3.1 }}"
- "{{ is_state('light.exterior', 'on') }}"
sequence:
- service: light.turn_off
target:
entity_id: light.exterior
- conditions:
- "{{ 0 <= now().hour < 16 }}"
- "{{ is_state('light.exteriorspecial', 'on') }}"
sequence:
- service: light.turn_off
target:
entity_id: light.exteriorspecial
- conditions:
- "{{ 21 <= now().hour < 16 }}"
- "{{ is_state('light.on_off_plug_1_5', 'on')"
sequence:
- service: light.turn_off
target:
entity_id: light.on_off_plug_1_5
default: []
mode: single
hatarez
December 26, 2022, 6:35pm
38
Do you mean this one?
- conditions:
- "{{ 0 <= now().hour < 16 }}"
- "{{ is_state('light.exteriorspecial', 'on') }}"
sequence:
- service: light.turn_off
target:
entity_id: light.exteriorspecial
default: []
mode: single
I believe is the one you posted to me, triggered at midnight to turn off these lights. Isnât going to work?
hatarez
December 26, 2022, 7:53pm
40
Oh so you mean the last one. How would I achieve it then? I want to trigger the event at 21 to turn off that light and I couldnât figure out the range I should specify there.
- conditions:
- "{{ 21 <= now().hour < 16 }}"
- "{{ is_state('light.on_off_plug_1_5', 'on') }}"
sequence:
- service: light.turn_off
target:
entity_id: light.on_off_plug_1_5
- conditions:
- "{{ now().hour >= 21 }}"
- "{{ is_state('light.on_off_plug_1_5', 'on') }}"
sequence:
- service: light.turn_off
target:
entity_id: light.on_off_plug_1_5
1 Like