I managed to make the setup work as I reingeniertd the post mentioned above. Instead setting everything up in HA i used tasker for the Alarm time and if it should go off or not.
In my setup it looks like this
alarm time and status comes from tasker.
Tasker creates 3 different sensors. I also used the autoalarm plugin to get the hour and the minute of the Alarm set.
- loads the needed variables from autoalarm
- sets up the sensor for the hour
- sets up the sensor for the minutes
4 and 5 basically set a sensor to either on or off for the status. if there is no alarm set within the next 24 hours it will switch the wakeup light to off.
6 to 8 is not important for this automation is just additional stuff i put into tasker.
6 and 7 give me an acustic feedback on my phone about if an alarm is set and when an alarm is set
8. activates an automation to switch everything off and is not
that you can see how i set up the sensors i made you screenshots of the settings as well.
you basically create a sensor with the http-post and then on Server:Port add https://yourdomain.duckdns.org:8123/api/states/sensor.name_of_sensor?api_password=your_HA_password
then in the data/file you add the Json data as you can see in my screenshots below. for a more detailed desciption of the process i recommend the following video: https://www.youtube.com/watch?v=CvSYZnKS0es
fist the status of the alarm and how i used if in tasker.
second the hour and the minute i used.
I did the following entried in the config file:
sensor:
- platform: time_date
display_options:
- 'time'
- platform: template
sensors:
wakeup_alarm_time:
friendly_name: 'Alarm time'
value_template: '{% if states.sensor.wakeup_hour.state|length == 3 %}0{% endif %}{{ states.sensor.wakeup_hour.state | int }}:{% if states.sensor.wakeup_minutes.state|length == 3 %}0{% endif %}{{ states.sensor.wakeup_minutes.state | int }}'
- platform: template
sensors:
wakeup_start_time_lights:
friendly_name: 'Fade-in start time'
value_template: >
{% if states.sensor.wakeup_alarm_time and states.input_number.wakeup_duration %}
{% set alarmtime = states.sensor.wakeup_alarm_time.state %}
{% set alarm_hour = alarmtime.split(":")[0] | int %}
{% set alarm_min = alarmtime.split(":")[1] | int %}
{% set light_dur = states.input_number.wakeup_duration.state | int %}
{% set alarm_min_light = alarm_min - light_dur %}
{% if alarm_min_light < 0 %}
{% set alarm_min_light = alarm_min_light + 60 %}
{% set alarm_hour_light = alarm_hour - 1 %}
{% if alarm_hour_light < 0 %}{% set alarm_hour_light = 23 %}{% endif %}
{% if alarm_hour_light < 10 %}0{% endif %}{{ alarm_hour_light}}:{% if alarm_min_light < 10 %}0{% endif %}{{ alarm_min_light }}
{% else %}
{% if alarm_hour < 10 %}0{% endif %}{{ alarm_hour }}:{% if alarm_min_light < 10 %}0{% endif %}{{ alarm_min_light }}
{% endif %}
{% endif %}
- platform: template
sensors:
wakeup_fadein_duration:
friendly_name: 'Fade-in duration'
value_template: '{{ states.input_number.wakeup_duration.state | int }}'
unit_of_measurement: 'min'
input_number:
wakeup_duration:
name: Light fade-in duration
icon: mdi:clock-in
initial: 10
min: 5
max: 60
step: 5
the automation looks like this:
- action:
- data:
entity_id: script.wakeup_bedroom
service: script.turn_on
alias: Alarm
condition:
- condition: state
entity_id: sensor.alarm_status
state: 'on'
id: '1515744066606'
trigger:
- platform: template
value_template: '{{ states.sensor.time.state == states.sensor.wakeup_start_time_lights.state
}}'
With the script i’m not a 100% happy as I cant manage it like this in hassio environment but it works for now.
wakeup_bedroom:
alias: Wakeup lighting, smooth transition
sequence:
- service: light.turn_on
data_template:
entity_id: light.bedroom
brightness: 1
xy_color:
- 0.3698
- 0.3723
- delay:
seconds: 1
- service: light.turn_on
data_template:
entity_id: light.bedroom
brightness: 255
transition: '{{ states.sensor.wakeup_fadein_duration.state | multiply(60) |
int }}'
I’m really fascinated by Home Assistant. I’m not a programmer at all and inspires me how I was able to set up such an automation within 3 weeks with the help of the community.