Alarm Clock with Sonos & Philips Hue

I also struggled to get my Alarm IDs. It is very easy to do with the soco library:

import soco as s
import soco.alarms as a

device = s.SoCo("192.168.1.XXX") # change to your sonos ip
a.get_alarms()

which will give you a list containing the alarms with their ids

{<Alarm id:684@09:30:00 at 0x7f184b95bac8>, <Alarm id:643@08:30:00 at 0x7f184b964a20>, <Alarm id:485@07:00:00 at 0x7f184b964748>, <Alarm id:50@06:15:00 at 0x7f184b964cf8>}

Hello all

I can figure out how to update the alarm, according to the directions described above, but I cant figure out, how to read the current state and time from a specific alarm ID from within HA. Anyone got a clue to that ?

What I’d like to achieve is on my Lovelace card, to display the current alarm time setting and state.

Regards

Michael.

I’m stugeing to get this working. If I run the automation with

“time”: “{{ states.sensor.alarm_clock_time.state }}“

to activate a alarm it failes to process the time variable. If I manually set

“time”: “10:00”

it workes as intended.

If I put

{{ states.sensor.alarm_clock_time.state }}

To the dev console it actually returned the correct time.

Would be great if someone could help me out

OK managed to get it working. Also I’m not using the “transition” Instead I’m using rest commands to actually program the routine on my hue hub. this works brilliantly now!

Hi, congratulation for you project. Thank’s for sharing!

One question: I would like to insert an automation that activates my Volumio media player at the alarm clock. and I would like to include in the group the possibility to choose the playlist that will wake me up the next day.
Can you help me!!!
Thank’s in advance!!!

Hi, I have the exact same issue, how did you fix it? And how do you use the rest command? Tks!

I used a custom rest command for adjusting the fade in time and the on/off state of the automation::

rest_command:
  set_time_light_fade_in_wd:
    url: curl -X PUT -d '{"status":"enabled"}' "BRIDGE-IP/api/API_KEY/schedules/1
    method: PUT
    headers:
      accept: 'application/json, text/html'
    payload: '{"localtime":"W124/T{{states("sensor.alarm_clock_wd_start_light")}}:00"}'
    content_type:  'application/json; charset=utf-8'

The W124 codes the days where the automation is active. 124 in binary is 1111100 so Monday to friday

For switching the automation on/off I used this a command line switch:

  - platform: command_line
    switches:
      hue_schedule_we_switch:
        friendly_name: "Fade Light In"
        command_on: curl -X PUT -d '{"status":"enabled"}' "BRIDGE-IP/api/API_KEY/schedules/3"
        command_off: curl -X PUT -d '{"status":"disabled"}' "BRIDGE-IP/api/API_KEY/schedules/3"
        value_template: "{{ is_state('sensor.arbeitszimmer_motion_sensor', 'on') }}"
1 Like

nice work… i think i going to give this a shot, but i do use Sonos, i whant to use my google hub, do u know how?

thank you for this post!
I just want to add that I recently wrote a custom component that exposes switches for SONOS Alarms: https://github.com/AaronDavidSchneider/SonosAlarm

4 Likes

Hi,

today is the first day i am working with HA. I’m not a pro so i really need help. I want to have a trigger that activates my sonos alarm and my hue wake up at a special time. So i want to change the time from 6 to 7 for example.

I tried to apply the script in all yaml files but i see some errors in log files and nothing really shows up.
I changed the input_slider to input_number but it still doesn’t work. Do you have any ideas?
Or is this not working anymore? I would need a step by step for beginners.

Regards

Ok i got it now you need to change input_slider to input_number and media_player.sonos_update _alarm to Sonos.update_alarm

But is there a way to control multiple alarm ids in automation?

@DaveVader is there an option to get the sonos alarm + hue with a single button with pre configured times?

i want to build a horizontal card with my often used alarm times but i dont get this to work.
so theres no need of variables/templates because my alarm should go on at 06:00 another one should go on at 06:30.
anyway to accomplish this?

Is there any way you can also fade-in the music on Sonos for 15 minutes (so in 15 minutes go from 0% to 12%)?