Hook your alarm clock to HA. (iOS only for now) free & paid

Always wanted to have my alarm clock be an indicator to set of things in the house, during wakeup and when i start to sleep and set the alarm.

There are 2 options now.

Sleep Cycle

First you need to stop using your normal alarm clock (this can be a dealbreaker for some already) and start using Sleep Cycle once you got it you also need to buy the premium (This is your only cost part)

You also need to have a Philips Hue setup because this is hooked up to your HA system. Since i don’t have any Philips Hue i used the emulated version. It is important that you set it to port 80 otherwise it will NOT work. So do some magic if that port is already in use :wink: Also it might be wise just to expose only your lights. You end up with a simple setup like:

emulated_hue:
  listen_port: 80
  exposed_domains:
  - light

Next up is that you want to have some dummy lights that you can trigger. Ofcourse you can choose a dimmer in your room to dim the lights when you go to sleep but i just want to be notified. We can use the template for it.

light:
  - platform: template
    lights:
      erik_sleep_lights:
        friendly_name: "Erik sensor slaap"
        turn_on:
        - service: input_select.select_option
          data_template:
            entity_id: input_select.erik_status_dropdown
            option: 'Just Awake'
        turn_off:
        - service: input_select.select_option
          data_template:
            entity_id: input_select.erik_status_dropdown
            option: 'Sleeping'
      vio_sleep_lights:
        friendly_name: "Vio sensor slaap"
        turn_on:
        - service: input_select.select_option
          data_template:
            entity_id: input_select.vio_status_dropdown
            option: 'Just Awake'
        turn_off:
        - service: input_select.select_option
          data_template:
            entity_id: input_select.vio_status_dropdown
            option: 'Sleeping'

In this example the Wife & me can use the app and if someone goes to bed and set the alarm it will place it to “Sleeping” and during wake up in the morning it will be “Just awake” i have multiple options in my input dropdown to keep it simple for myself.

Then in the Sleep Cycle app under premium you need to select that light. (Erik sensor slaap)

If you click on the light it will just give you a list of all devices, just select the one you need.

That should pretty much do it, so again. You don’t need a emulated if you have Philips Hue already in your system. (But i have not tested that kind of setup, since i don’t have it)

The reason this only works for iOS is that the Android does not support this function, i presume it is in the making. This is the only working option i have found in iOS to work. For Android there are other means to get the alarm i believe but i don’t have android.

iOS Shortcuts

This was brought under attention of SalkinDK, who mentioned another solution. iOS has an app called Shortcuts. You can download that for free from the appstore and if you have the Home Asistant app it will work to trigger alarms from your alarm clock.

Setup is a bit simpler but it cannot trigger when you set your alarm. It does however allow you to trigger when you snooze. See examples below.


I have both possible options now set, when i snooze and when i wakeup. The “wake-up” alarm works for my “bedtime” alarm, but you can also select a specific alarm.

For each of these items you have to add the triggers:

And those needs some actual data:

You can add a dictionary as pointed out on the forums and docs i believe, it must be the first item and you can then link that in your service data.

End result

  1. Sleep cycle
    Costs a few bucks but gets your also some nice features and ‘better’ wake up times accorindg to their promo’s. Can not trigger on snooze, but does on wakeup and when you sleep / set your phone away.

  2. Shortcuts
    Costs nothing, easy to setup. No emulated Hue needed. Does not trigger when you set your alarm / set your phone away. But can trigger also on snooze when you wakeup.

So both have their pro’s and cons. Sadly you cannot combine them but the wakup was the most important one for me.

4 Likes

Nice setup. But maybe a stupid question, but why aren’t you using the ios shortcuts app together with the official Homeassistant ios app?
you can make a shortcut call a service, fx the input select.

2 Likes

How would you trigger the alarm to a shortcut then? Default alarm clock of iOS is completely inaccessable afaik.

I have it start a automation when i either snooze or stop my morning alarm, using the bedtime alarm and a shortcut automation.

You can choose to have a automation run when you stop or snooze the alarm.

1 Like

Can you share/show a screenshot. If i understand you correctly, if you set your alarm the shortcut will see that and will initiate a call to HA right? (https://support.apple.com/guide/shortcuts/events-triggers-apd932ff833f/ios a bit further)

Found it, Shortcuts -> Automations -> Personal Automations. I’ll go play with it now.

Does sleep cycle require you to have the app open to work?
Another option is AutoWake, if you also have an Apple Watch. https://autowake.tantsissa.com/homekit
I have not tried this myself yet though.

The app stays open, you keep your device powered because it also uses the microphone (screen is off though) it records even when you snore :wink: but the idea of this post was to share, only to find out more options. Was also a hard one to search for.

1 Like

Yes exactly you fond it yourself, it wont run the automation when you set the alarm.
But you can have another shortcut that triggers Homeassistant and prompts you to set the alarm.

Prompt for the alarm is not the mosst friendly, also since the wife has shifts. Hard to automate hence why te sleep cycle is a good call. But for snoozing is something i could not get with sleep cycle so it is a nice addition too. I’ll look into it a bit more, and add it to the topic above.

It was not a way to say you setup wasn’t nice. it indeed is.
Just to chip in on another way to achieve the same setup.

Yes the set alarm prompt isn’t always showing the bedtime alarm, but just the “normal” alarms.
Hopefully this is a bug that will be fixed.

Added your solution to the first post too, to make it more complete. Suggestions/mistakes just let me know.

Is any trick to get bedtime wake up alarm info to input in HA?

This would be so nice. But I cannot get it to work reliably in any way unfortunately. :frowning:

I have two Harmony Hubs which can use the emulated_hue without any issues at all. My description.xml and /api/lights reports properly.

Issue seems to be when announcing/pairing with Sleep Cycle. Totally random. Sometimes it pairs while in app and flicking the buttons, sometimes it won’t pair, I leave the app and come back and it’s paired. If I restart HA it dissapears.

I’ve tried unjacking my regular Philips Hue Bridge, specifying host_ip, advertise_ip, port, upnp_bind_multicast, only exposing 1 entity etc. Doesn’t seem to matter what I do really.

emulated_hue:
  #host_ip: 192.168.4.11
  listen_port: 80
  #advertise_ip: 192.168.4.11
  #advertise_port: 80
  #upnp_bind_multicast: false
  expose_by_default: false
  entities:
    switch.film:
      name: Film
      hidden: false
config cat home-assistant.log| grep emulated_hue
2020-04-09 14:04:13 DEBUG (MainThread) [homeassistant.bootstrap] Setting up {'sun', 'hacs', 'config', 'binary_sensor', 'vacuum', 'group', 'asuswrt', 'spotify', 'switch', 'icloud', 'sensor', 'plex', 'conversation', 'mqtt', 'websocket_api', 'http', 'persistent_notification', 'script', 'tradfri', 'python_script', 'media_player', 'rest_command', 'lovelace', 'spotcast', 'hue', 'input_number', 'onboarding', 'webhook', 'api                   ', 'map', 'homekit', 'wake_on_lan', 'harmony', 'device_automation', 'remote', 'discovery', 'frontend', 'input_boolean', 'variable', 'history', 'updater', 'timer', 'light', 'emulated_hue', 'system_health'}
2020-04-09 14:04:44 INFO (MainThread) [homeassistant.setup] Setting up emulated_hue
2020-04-09 14:04:44 INFO (MainThread) [homeassistant.components.emulated_hue] Listen IP address not specified, auto-detected address is 192.168.4.11
2020-04-09 14:04:44 INFO (MainThread) [homeassistant.setup] Setup of domain emulated_hue took 0.0 seconds.
2020-04-09 14:04:44 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Eventcomponent_loaded[L]: component=emulated_hue>
2020-04-09 14:05:07 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.140470576469456] Sending {'id': 12, 'type': 'result', 'success': True, 'result': {'latitude': , 'longitude': , 'elevation': , 'unit_system': {'length': 'km', 'mass':'g', 'pressure': 'Pa', 'temperature': '°C', 'volume': 'L'}, 'location_name': 'Home', 'time_zone': '', 'components': {'sensor.mobile_app', 'binary_sensor', 'group', 'automation', 'switch', 'websocket_api', 'http', 'script', 'rest_command', 'spotcast', 'logbook', 'input_number', 'sensor.plex', 'cover','remote.harmony', 'wake_on_lan', 'device_tracker.mobile_app', 'sensor.hacs', 'mobile_app', 'kodi', 'notify', 'input_boolean', 'timer', 'updater', 'light', 'camera.synology', 'hassio', 'sun', 'switch.wake_on_lan', 'media_player.spotify', 'spotify', 'sensor.asuswrt', 'sensor.template', 'device_tracker.icloud', 'media_player', 'google_assistant', 'api', 'homeassistant', 'harmony', '                                                                                       device_automation', 'switch.flux', 'frontend', 'sensor.radarr', 'sensor.sl', 'system_health', 'hacs', 'config', 'cast', 'device_tracker', 'binary_sensor.mqtt', 'search', 'icloud', 'plex', 'camera', 'tradfri', 'logger', 'binary_sensor.mobile_app', 'lovelace', 'hue', 'onboarding', 'webhook', 'map', 'homekit', 'media_player.cast', 'switch.command_line', 'cover.tradfri', 'switch.template', 'tts', 'discovery', 'light.hype                                                                                       rion', 'person', 'variable', 'zone', 'recorder', 'auth', 'media_player.androidtv', 'system_log', 'vacuum', 'asuswrt', 'sensor.time_date', 'sensor', 'conversation', 'mqtt', 'persistent_notification', 'light.mqtt', 'media_player.plex', 'binary_sensor.workday', 'python_script', 'notify.mobile_app', 'media_player.kodi', 'binary_sensor.updater', 'switch.tradfri', 'remote', 'sensor.discord_game', 'switch.mqtt', 'sensor.icl                                                                                       oud', 'history', 'vacuum.xiaomi_miio', 'light.tradfri', 'sensor.tradfri', 'emulated_hue', 'sensor.yr'}, 'config_dir': '/config', 'whitelist_external_dirs': {'/config/www'}, 'version': '0.108.1', 'config_source': 'yaml', 'safe_mode': False}}
2020-04-09 14:05:08 DEBUG (SyncWorker_9) [homeassistant.util.json] JSON file not found: /usr/src/homeassistant/homeassistant/components/emulated_hue/.translations/sv.json
2020-04-09 14:05:09 DEBUG (SyncWorker_13) [homeassistant.util.json] JSON file not found: /usr/src/homeassistant/homeassistant/components/emulated_hue/.translations/en.json

Anyone else has similar experience? Suspecting either Sleep Cycle changed something or the implementation for it in emulated_hue might be a bit dodgy.

Im running HASS.IO in Hyper-V. See HA version above. Supervisor version is 215.

Not that i am aware off, you can only trigger actions. For ios (which i use) its closed. I asked a few developers if it was possible to get the alarm clock times into HA but your not allowed to get that information as a developer for an app.

1 Like

Sadly no, have not had issues with it as i had to emulate it without having one hue at all too. So milage may vary.

Did some more diggin’ and it seems like Sleep Cycle uses ‘discovey.meethue.com’ to determine your hub ip as first measures. Which might explain my random success (DNS cache?). After blocking that in my DNS and unplugging my real Hue bridge it discovers the emulated_hue properly.

Now I will try and see if it’s persistant when I have my Hue bridge connected as well.
Otherwise I will put my Sleep Cycle dedicated iPhone on a separate subnet and block it from accessing my Hue bridge.

I don’t have a hue bridge so I created a hue emulator. It seems to be working since I can hit /description.xml and /api/pi/lights. In the pi/lights json, I do see the fake light template as suggested as well. ie.

/description.xml

<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<URLBase>http://192.168.20.27:80/</URLBase>
<device>
<deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>
<friendlyName>Home Assistant Bridge (192.168.20.27)</friendlyName>
<manufacturer>Royal Philips Electronics</manufacturer>
<manufacturerURL>http://www.philips.com</manufacturerURL>
<modelDescription>Philips hue Personal Wireless Lighting</modelDescription>
<modelName>Philips hue bridge 2015</modelName>
<modelNumber>BSB002</modelNumber>
<modelURL>http://www.meethue.com</modelURL>
<serialNumber>1234</serialNumber>
<UDN>uuid:2f402f80-da50-11e1-9b23-001788255acc</UDN>
</device>
</root>

/api/pi/lights

{
  "29": {
    "manufacturername": "Home Assistant",
    "modelid": "HASS123",
    "name": "My sensor slaap",
    "state": {
      "bri": 254,
      "mode": "homeautomation",
      "on": false,
      "reachable": true
    },
    "swversion": "123",
    "type": "Dimmable light",
    "uniqueid": "00:4a:e0:b4:f2:2f:a0:55-b9"
  }
}

However, when I go to sleep cycle and turn on Philips Hue it does not load any of the lights. Does anyone else have this problem?

I was able to resolve this a while ago so hopefully this update is useful for others if they face this issue.

I have two separate VLANs configured, where HA is on my IoT vlan while my phone was on main vlan. I haven’t been able to get discoverability to work across the vlans, so for now I am keeping my phone in the IoT vlan. This allows the emulated hue to be discovered.

Thanks for sharing.
Unfortunately the premium feature is now a abo, which costs 30€ per year… I’m sorry, but then I have to go for the 2nd option.

I switched to a non payed option too. Rather spend that on nabu casa.