Wake up alarm with music and light - Sunrise, sound

Hi guys,

I’ve made a small project by combining multiple post on this forum. I wanted to share that with you.

I made an automation that starts a script that gradually dim the light (regular light) and start a spotify on a Google Home mini.

Needed:


Google Home mini

I’ve used a script because the dimmer doesn’t support the transition option.

input_boolean :
  wakeup_enabled:
    name: "Wake-up Al"
    initial: on
    icon: mdi:theme-light-dark
  wakeup_weekend:
    name: "Enable Wake-up on weekends"
    initial: off # I disable the system on default on weekends
    icon: mdi:calendar-blank
input_datetime:
  wakeup_time:
    name: "Start lights at"
    has_time: true
    has_date: false
    initial: "06:40"
binary_sensor:
  - platform: workday
    country: CA
    province: QC
sensor:
  - platform: time_date
    display_options:
      - 'time'
- id: '1574711731719'
  alias: Timer - Wakeup Al
  description: ''
  trigger:
  - platform: template
    value_template: '{{ states(''sensor.time'') == (states.input_datetime.wakeup_time.attributes.timestamp
      | int | timestamp_custom(''%H:%M'', False)) }}'
  condition:
  - condition: state
    entity_id: binary_sensor.workday_sensor
    state: 'on'
  - condition: state
    entity_id: input_boolean.wakeup_enabled
    state: 'on'
  action:
  - alias: ''
    data:
      brightness_pct: 10
      entity_id:
      - light.dimmer_chambre_al
      transition: 30
    service: light.turn_on
  - data:
      entity_id: media_player.googlehome3451
      volume_level: 0.1
    service: media_player.volume_set
  - data:
      entity_id: media_player.googlehome3451
      random_song: true
      uri: spotify:playlist:37i9dQZF1DXcxacyAXkQDu
    service: spotcast.start
'1574782150927':
  alias: Wake up Al
  sequence:
  - data:
      brightness_pct: 10
      entity_id:
      - light.dimmer_chambre_al
    service: light.turn_on
  - data:
      entity_id: media_player.googlehome3451
      volume_level: 0.1
    service: media_player.volume_set
  - data:
      entity_id: media_player.googlehome3451
      random_song: true
      uri: spotify:playlist:37i9dQZF1DXcxacyAXkQDu
    service: spotcast.start
  - wait_template: "{{ is_state('binary_sensor.entrance', 'on') }}"
    timeout: '00:02'
    continue_on_timeout: 'true'
  - data:
      brightness_pct: 20
      entity_id:
      - light.dimmer_chambre_al
    service: light.turn_on
  - data:
      entity_id: media_player.googlehome3451
      volume_level: 0.2
    service: media_player.volume_set
  - wait_template: "{{ is_state('binary_sensor.entrance', 'on') }}"
    timeout: '00:02'
    continue_on_timeout: 'true'
  - data:
      brightness_pct: 40
      entity_id:
      - light.dimmer_chambre_al
    service: light.turn_on

Let me know that you think and if you have ideas to enhance it.

Thanks

2 Likes

I transfered my automation and script into node-red if interested!

1 Like

Ciao Godinperson…
Can you share your node-red flow?

Thanks :wink:

Here it is. Let me know what you think

[{"id":"79d158e1.942dd8","type":"tab","label":"Wake up Al","disabled":false,"info":""},{"id":"7dc4bf4a.429bd","type":"function","z":"79d158e1.942dd8","name":"Get day of week","func":"var day = new Date().getDay();\n\nvar isWeekend = (day === 6) || (day === 0); \n\nreturn {\n payload: isWeekend,\n};","outputs":1,"noerr":0,"x":260,"y":340,"wires":[["7a7eac5f.649bc4"]]},{"id":"7a7eac5f.649bc4","type":"switch","z":"79d158e1.942dd8","name":"Is it weekend?","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":260,"y":380,"wires":[["812bcd0d.a28fe"],["12fa43d4.4bc3cc"]]},{"id":"812bcd0d.a28fe","type":"api-current-state","z":"79d158e1.942dd8","name":"Enabled on weekends?","server":"19028f05.bad0d1","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.wakeup_weekend","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":530,"y":340,"wires":[[],["12fa43d4.4bc3cc"]]},{"id":"12fa43d4.4bc3cc","type":"api-current-state","z":"79d158e1.942dd8","name":"Enabled?","server":"19028f05.bad0d1","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":true,"entity_id":"input_boolean.wakeup_enabled","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":480,"y":400,"wires":[[],["1a134114.6af8ff","c39319a3.dbcb98"]]},{"id":"1a134114.6af8ff","type":"api-call-service","z":"79d158e1.942dd8","name":"10%","server":"19028f05.bad0d1","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.dimmer_chambre_al","data":"{\"brightness_pct\":10}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":230,"y":520,"wires":[[]]},{"id":"a1846d75.2a1a8","type":"server-state-changed","z":"79d158e1.942dd8","name":"Wake up time input","server":"19028f05.bad0d1","version":1,"entityidfilter":"input_datetime.wakeup_time","entityidfiltertype":"substring","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"entity","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"x":230,"y":120,"wires":[["dd93510f.901d8"]]},{"id":"dd93510f.901d8","type":"function","z":"79d158e1.942dd8","name":"Parse time","func":"new_msg = {\n payload: {\n ontime: msg.payload.substr(0,5),\n offtime: msg.payload.substr(0,5)\n }\n}\nreturn new_msg;","outputs":1,"noerr":0,"x":250,"y":200,"wires":[["2e492ea5.8e1092"]]},{"id":"2e492ea5.8e1092","type":"schedex","z":"79d158e1.942dd8","name":"Trigger at time","suspended":false,"lat":"","lon":"","ontime":"7:30","ontopic":"","onpayload":"on","onoffset":0,"onrandomoffset":0,"offtime":"12:00","offtopic":"","offpayload":"off","offoffset":"60","offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":440,"y":200,"wires":[["d3674441.a71cc8"]]},{"id":"d3674441.a71cc8","type":"switch","z":"79d158e1.942dd8","name":"is on","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":590,"y":200,"wires":[["7dc4bf4a.429bd"]]},{"id":"2f7403a5.84bbbc","type":"comment","z":"79d158e1.942dd8","name":"Time setting input","info":"","x":220,"y":60,"wires":[]},{"id":"3339559f.219f9a","type":"comment","z":"79d158e1.942dd8","name":"Trigger at the configured time","info":"","x":480,"y":160,"wires":[]},{"id":"90014d19.0828c","type":"comment","z":"79d158e1.942dd8","name":"Check if the wake-up light should be enabled on this day of the week","info":"","x":390,"y":280,"wires":[]},{"id":"88229656.ad9c38","type":"comment","z":"79d158e1.942dd8","name":"Run the wake-up sequence","info":"","x":260,"y":440,"wires":[]},{"id":"c39319a3.dbcb98","type":"api-call-service","z":"79d158e1.942dd8","name":"Google Home","server":"19028f05.bad0d1","version":1,"debugenabled":true,"service_domain":"media_player","service":"volume_set","entityId":"media_player.googlehome3451","data":"{\"volume_level\":0.1}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":560,"y":500,"wires":[["fe1db674.ace938"]]},{"id":"fe1db674.ace938","type":"api-call-service","z":"79d158e1.942dd8","name":"SpotCast","server":"19028f05.bad0d1","version":1,"debugenabled":true,"service_domain":"spotcast","service":"start","entityId":"media_player.googlehome3451","data":"{\"random_song\":true,\"uri\":\"spotify:playlist:37i9dQZF1DXcxacyAXkQDu\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":640,"y":560,"wires":[["d1ea6d87.5eab6"]]},{"id":"d1ea6d87.5eab6","type":"stoptimer","z":"79d158e1.942dd8","duration":"1","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":700,"y":620,"wires":[["e4eb5fa6.7bf46"],[]]},{"id":"e4eb5fa6.7bf46","type":"api-call-service","z":"79d158e1.942dd8","name":"Google Home","server":"19028f05.bad0d1","version":1,"debugenabled":true,"service_domain":"media_player","service":"volume_set","entityId":"media_player.googlehome3451","data":"{\"volume_level\":0.2}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":740,"y":680,"wires":[[]]},{"id":"7b8b94db.bd8e0c","type":"stoptimer","z":"79d158e1.942dd8","duration":"1","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":280,"y":580,"wires":[["cee134a1.adb778"],[]]},{"id":"1970c860.622598","type":"stoptimer","z":"79d158e1.942dd8","duration":"1","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":320,"y":680,"wires":[["d5781732.3b8508"],[]]},{"id":"82917b0e.dd6968","type":"stoptimer","z":"79d158e1.942dd8","duration":"1","units":"Minute","payloadtype":"num","payloadval":"0","name":"","x":360,"y":780,"wires":[["6c3704ef.f01dfc"],[]]},{"id":"cee134a1.adb778","type":"api-call-service","z":"79d158e1.942dd8","name":"20%","server":"19028f05.bad0d1","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.dimmer_chambre_al","data":"{\"brightness_pct\":20}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":270,"y":620,"wires":[["1970c860.622598"]]},{"id":"d5781732.3b8508","type":"api-call-service","z":"79d158e1.942dd8","name":"30%","server":"19028f05.bad0d1","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.dimmer_chambre_al","data":"{\"brightness_pct\":30}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":290,"y":720,"wires":[["82917b0e.dd6968"]]},{"id":"6c3704ef.f01dfc","type":"api-call-service","z":"79d158e1.942dd8","name":"50%","server":"19028f05.bad0d1","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.dimmer_chambre_al","data":"{\"brightness_pct\":50}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":330,"y":820,"wires":[[]]},{"id":"19028f05.bad0d1","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

1 Like

Nice automation. Thanks for sharing. I’m looking for a dimmable smart plug. Does this one work with the Leviton decora WiFi Integration?