zackwag / homebridge-somneo

Apache License 2.0
9 stars 2 forks source link

Add support for alarms/wake-up light #28

Open khad opened 3 years ago

khad commented 3 years ago

At the moment, I don't see a way to use the wake-up light using this plugin. Would it be possible to add support for the alarms? Or even just the wake-up light that fades in over the course of a set amount of time?

Configuration could be similar to that of the Sunset Program. It would just require a bit of mental math depending on when you wanted it to be at its brightest.

For example, if I had a trigger in HomeKit to turn this on at 6:00 AM, it would fade in the light over 30 minutes to reach full brightness at 6:30 AM:

"wakeup": {
    "isEnabled": true,
    "duration": 30,
    "lightIntensity": 100,
    "colorScheme": 2,
    "ambientSounds": "0",
    "volume": 0
}

I'm still using the Philips app for alarms and would love to be rid of it if possible. :)

zackwag commented 3 years ago

Hi @khad !

I am looking into this. Unfortunately, the Philips API is pretty limited and tailored to the app. I see no way (currently) to trigger a wakeup via API.

Currently, it looks like the best solution is to update the alarm to run X number of minutes from now (X being the duration you would set in the config file.

There's no documentation on the API so everything so far has been me piecing things together by calling something in the app and inspecting the GET response in the API.

If I look at:

https://SOMNEO_IP/di/v1/products/1/wualm/prfwu

I get the response

{
  "prfnr": 1,
  "prfen": false,
  "prfvs": true,
  "pname": "",
  "ayear": 0,
  "amnth": 0,
  "alday": 0,
  "daynm": 254,
  "almhr": 7,
  "almmn": 0,
  "curve": 20,
  "durat": 30,
  "ctype": 0,
  "snddv": "off",
  "sndch": " ",
  "sndlv": 12,
  "sndss": 0,
  "pwrsz": 0,
  "pszhr": 0,
  "pszmn": 0
}

From what I can tell, prfnr is the alarm ID (I'd just default to 1) almhr is the hour the alarm starts (7 for 7:30) almmn is the minute the alarm starts (30 for 7:30) curve is light intensity (1 - 25) durat is the wakeup program duration ctype is the Scene Type (Carribean Red etc) snddv is the sound source (an enumeration of sounds or FM or aux or Off) sndch is used if it's FM (1 - 5) sndlv is the volume

There's more settings to set I'm sure. I need some time to dig through. Things have been busy in my house.

Thank you for your continued interest in this plugin!

khad commented 3 years ago

Currently, it looks like the best solution is to update the alarm to run X number of minutes from now (X being the duration you would set in the config file.

Smart! Yeah, I could make a setup like that work in some automations.

And I fully appreciate that this is a passion project. Home life comes first. 👍