I am attempting to create a sunrise simulation using my bedroom lamps and an input:date_time. I have the basic automation but I am looking for an efficient way to offset the time so the light is on full at the alarm time not 30 minutes after.
here is my current automation:
alias: wakeup_lights
trigger:
- platform: time
at: input_datetime.alarm_time
action:
- service: light.turn_on
data:
transition: 1800
rgb_color:
- 255
- 255
- 255
brightness_pct: 100
entity_id:
- light.bedside_light
- light.feit_bedroom1
mode: single
Any help is greatly appriciated.
1 Like
yigit.guc
(Yigit K.)
December 9, 2022, 3:29pm
2
I have finally found the same question I have, only to find that it wasnāt answered
@Greg_Pendleton Were you able to solve it?
Can anyone give a hand?
Need to trigger 30 minutes before āinput_datetimeā
Here is the template that has been working for me:
platform: template
value_template: >-
{{((state_attr('input_datetime.alarm_time', 'timestamp') - 1800) |
timestamp_custom('%H:%M', False)) == ((now().timestamp()) |
timestamp_custom('%H:%M')) }}
yigit.guc
(Yigit K.)
December 13, 2022, 4:40pm
6
For some reason, this solution didnāt work for me.
Here is what I did:
My time/date helper: input_datetime.morning_alarm
My config entry:
template:
- sensor:
unique_id: "offset_alarm"
state: "{{ states('input_datetime.morning_alarm') | as_datetime - timedelta(minutes = 30) }}"
device_class: timestamp
Automation YAML (relevant part)
alias: "Morning Lights: Bedroom"
description: "Gradually Turn on the lights "
trigger:
- platform: time
at: sensor.offset_alarm
What did I miss?
yigit.guc
(Yigit K.)
December 13, 2022, 4:44pm
7
Interesting solution, is this code directly under the ātriggerā tag inside the automation YAML?
Yes, hereās the block:
trigger:
- platform: template
value_template: >-
{{((state_attr('input_datetime.alarm_time', 'timestamp') - 1800) |
timestamp_custom('%H:%M', False)) == ((now().timestamp()) |
timestamp_custom('%H:%M')) }}
action:
1 Like
yigit.guc
(Yigit K.)
December 14, 2022, 11:02am
11
Greg_Pendleton:
Yes, hereās the block:
trigger:
- platform: template
value_template: >-
{{((state_attr('input_datetime.alarm_time', 'timestamp') - 1800) |
timestamp_custom('%H:%M', False)) == ((now().timestamp()) |
timestamp_custom('%H:%M')) }}
action:
Thanks to both of you, but this was the one that worked for me straight away.