Nighlight alternative: Philips Somneo Smart Alarm Clock with API

Einklappen
X
 
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge
  • nufke
    Smart Home'r
    • 10.11.2018
    • 57

    Nighlight alternative: Philips Somneo Smart Alarm Clock with API

    Hi all,

    I purchased a Philips Somneo Wake-Up Light with build-in Alarm Clock (HF3672/01) which offers the capability to access and program it remotely via Wifi and a dedicated Philips App. The good news is that the connection is not going via the Cloud, but uses the local Wifi network and IP address to exchange information. Although Philips did not publish the API to program this thing, with some trail-and-error I was able to access and program it via NodeRed via a simple https node.
    The capabilities I got working are:
    * sensor readings (brightness, temperature, noise-level, humidity)
    * light readings
    * alarm settings incl programming alarm times

    I managed to use the Loxone clock block to set wake-up times in the Loxone app, and sync this with the Somneo Wake-Up Light via some NodeRed glue logic.

    Although the price of this "Smart" Wake-Up Light is a bit higher than the non-programmable Wake-up lights, there are regular discounts (at least here in NL) with price levels between 100-130 EUR. So a cheaper alternative for the Nighlight.

    In case there is sufficient interest, I will consider creating a LoxBerry plugin to enable easy integration.

  • Gast

    #2
    Can you provide some details on how you did this?

    I am considering buying a connected Philips wake-up light and I don't like the idea of the remote control functionality being dependent on a proprietary app. I want to be able to customize as I please with scripts.

    I'll probably not get the Somneo, but I hope all the connected wake-up lights have a similar API.

    I've thought about just buying Philips Hue lights, but I suspect the wake-up lights have been engineered for their specific use in ways that is hard to reproduce perfectly with Hue lights.

    Kommentar

    • nufke
      Smart Home'r
      • 10.11.2018
      • 57

      #3
      Below my current Node-red experimental (!) setup for alarm clock reading and programming. I did not add the sensor readings and light programming since I did not need this. Node-red requires the following additional nodes: node-red-contrib-https and node-red-contrib-loxone
      (NOTE: anonymized Loxone MS control. IP address of Somneo set to dummy address 1.1.1.1)

      Code:
      [{"id":"9793ee5d.b17cc","type":"loxone-control-in","z":"4d6b4df0.00515c","name":"Read Loxone Alarm Clock","miniserver":"","control":"00000000-0000-0000-0000000000000000","state":"00000000-0000-0000-0000000000000000","x":210,"y":140,"wires":[["ee7b4b19.f5207"]]},{"id":"77ad754c.51223c","type":"split","z":"4d6b4df0.00515c","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":570,"y":140,"wires":[["b0e33fe9.0864a8"]]},{"id":"b0e33fe9.0864a8","type":"function","z":"4d6b4df0.00515c","name":"","func":"var time = msg.payload.alarmTime;\nvar hr = Math.floor(time / 3600);\nvar min = Math.floor((time - hr*3600)/60);\nvar idx = parseInt(msg.parts.index)+1;\nvar modes = msg.payload.modes;\nvar days = 0;\nfor (var i=0; i< modes.length; i++) {\n    if (modes[i]==1); // skip\n    if (modes[i]==2); // skip\n    if (modes[i]==3) days+=2; // mon\n    if (modes[i]==4) days+=4; // tue\n    if (modes[i]==5) days+=8; // wed\n    if (modes[i]==6) days+=16; // thu\n    if (modes[i]==7) days+=32; // fri\n    if (modes[i]==8) days+=64; // Sat\n    if (modes[i]==9) days+=128; // Sun\n}\nvar alarm = { \n    prfnr: idx,\n    prfen: msg.payload.isActive,\n    prfvs: true,\n    pname: \"Alarm\",\n    ayear: 0,\n    amnth: 0,\n    alday: 0,\n    daynm: days,\n    almhr: hr,\n    almmn: min,\n    curve: 20,\n    durat: 30,\n    ctype: 0,\n    snddv: \"wus\",\n    sndch: \"2\",\n    sndlv: 12, // sound level\n    sndss: 0,\n    pwrsz: 0, // power wake off\n    pszhr: 0,\n    pszmn: 0,\n}\nmsg.method=\"PUT\";\nmsg.payload=alarm;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":740,"y":140,"wires":[["13bb9d6d.97021b"]]},{"id":"13bb9d6d.97021b","type":"https-node","z":"4d6b4df0.00515c","name":"set wu prefs","method":"use","ret":"obj","url":"https://1.1.1.1/di/v1/products/1/wualm/prfwu","authorized":false,"agent":true,"x":950,"y":140,"wires":[["46f144f8.478bf4"]]},{"id":"46f144f8.478bf4","type":"debug","z":"4d6b4df0.00515c","name":"set wu","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1130,"y":140,"wires":[]},{"id":"ee7b4b19.f5207","type":"rbe","z":"4d6b4df0.00515c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":430,"y":140,"wires":[["77ad754c.51223c"]]},{"id":"2c630ae7.ce5bc6","type":"function","z":"4d6b4df0.00515c","name":"reformat","func":"// convert Somneo message into Loxone format\n// entryList/put/{entryID}/{name}/{alarmTime}/{isActive}/{modes}\nvar as = msg.payload[0];\nvar al = msg.payload[1];\nvar pref = \"entryList/put/\";\nvar str= \"\";\nvar max_entries = 4; // for now, only 2 entries supported\n// var max_entries = al.amnth.length+1;max_entries\nvar x;\n\nfor(var i=0; i<max_entries; i++) {\n    x = max_entries-1-i;\n    str += pref;\n    str += x + \"/Wekker/\";\n    str += al.almhr[x]*3600+al.almmn[x]*60 + \"/\";\n\n    if (as.prfen[x]) str +=\"1/\";\n      else str += \"0/\";\n    \n    var days = [];\n    if (al.daynm[x]&2) days.push(3);\n    if (al.daynm[x]&4) days.push(4);\n    if (al.daynm[x]&8) days.push(5);\n    if (al.daynm[x]&16) days.push(6);\n    if (al.daynm[x]&32) days.push(7);\n    if (al.daynm[x]&64) days.push(8);\n    if (al.daynm[x]&128) days.push(9);\n\n    for(var j=0; j<days.length;j++)\n    {\n        str += days[j];\n        if (j<days.length-1) str +=\",\";\n    } \n    if (i<max_entries-1) str+=\"\\n\";\n}\n\nmsg.payload=str;\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":920,"y":380,"wires":[["24104f79.8d4d1"]]},{"id":"a68dcfcf.9af65","type":"join","z":"4d6b4df0.00515c","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":630,"y":380,"wires":[["4dc50cdb.bb9454"]]},{"id":"ca34ca86.68c8e","type":"https-node","z":"4d6b4df0.00515c","name":"get alarm env","method":"GET","ret":"obj","url":"https://1.1.1.1/di/v1/products/1/wualm/aenvs","authorized":false,"agent":true,"x":380,"y":380,"wires":[["a68dcfcf.9af65"]]},{"id":"7695ea2.1c39394","type":"https-node","z":"4d6b4df0.00515c","name":"get alarm times","method":"GET","ret":"obj","url":"https://1.1.1.1/di/v1/products/1/wualm/aalms","authorized":false,"agent":true,"x":380,"y":320,"wires":[["a68dcfcf.9af65"]]},{"id":"7bb99f9e.af35f8","type":"inject","z":"4d6b4df0.00515c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"10","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":190,"y":380,"wires":[["ca34ca86.68c8e","7695ea2.1c39394"]]},{"id":"24104f79.8d4d1","type":"split","z":"4d6b4df0.00515c","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"topic","x":1070,"y":380,"wires":[["d7a60a5f.1ec608","777667e7.9e8aa8"]]},{"id":"d7a60a5f.1ec608","type":"debug","z":"4d6b4df0.00515c","name":"get wu","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1250,"y":300,"wires":[]},{"id":"777667e7.9e8aa8","type":"loxone-control-out","z":"4d6b4df0.00515c","name":"Set Loxone Alarm Clock","miniserver":"","control":"00000000-0000-0000-0000000000000000","x":1310,"y":380,"wires":[]},{"id":"4dc50cdb.bb9454","type":"rbe","z":"4d6b4df0.00515c","name":"","func":"rbe","gap":"","start":"","inout":"out","property":"payload","x":770,"y":380,"wires":[["2c630ae7.ce5bc6"]]},{"id":"c0e9a789.00f75","type":"comment","z":"4d6b4df0.00515c","name":"Get Loxone Alarm Clock entries and pass it to Somneo","info":"","x":300,"y":80,"wires":[]},{"id":"de32bd9b.3476f","type":"comment","z":"4d6b4df0.00515c","name":"Get Somneo settings and update Loxone Alarm Clock","info":"","x":300,"y":260,"wires":[]}]
      Zuletzt geändert von nufke; 16.02.2021, 21:48.

      Kommentar

      • Dostal
        LoxBus Spammer
        • 22.02.2016
        • 318

        #4
        Google can Help...

        Kommentar

        Lädt...