• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
MagicMirror Forum
  • Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
A New Chapter for MagicMirror: The Community Takes the Lead
Read the statement by Michael Teeuw here.

Philips Hue Light Switches based wakeup

Scheduled Pinned Locked Moved Development
utility
3 Posts 3 Posters 3.4k Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    Tomekkkkk
    last edited by paviro May 8, 2016, 8:50 PM May 5, 2016, 11:10 AM

    Hi,

    i need some help with an Python Script which should wake up the Mirror by pressing the button. I got some Philips Hue Light Switches but have trouble to curl the right data. I think the switch is pretty good for this, because no installation is needed. alt text

    The Script should wake up the Mirror with libcec over HDMI, also turn the LCD off in Standby by pressing the button.

    In the Philips Hue Bridge i have whitelisted the Pi and with curl i can read the last Buttonevents of the right switch over the existing API (http://192.168.X.XXX/api/WBLu***UNIQUEUSERID***bdQ0-iEetTe5/sensors/5)

    This Site gave me the following JSON Data:

    {„state": {"buttonevent":1002,"lastupdated":"2016-05-04T15:00:51"},"config":{"on":true,"battery":100,"reachable":true},"name":"Hue dimmer switch 1","type":"ZLLSwitch","modelid":"RWL021","manufacturername":"Philips","swversion":"5.45.1.16265","uniqueid":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"}
    

    buttonevent 1002 is for turn on and 4002 is for turn off

    So i worked on a script which will should check all 10 seconds the Buttonstatus and regarding this Wake Up the LCD.

    import urllib2
import time
       def SensorState( SensorName ):
        s = "buttonevent\":"
  a = urllib2.urlopen("http://192.168.X.XXX/api/monitor/sensors/" + SensorName    ).read()
  b =  a.find(s) + len(s)
  e = a.find(",",b)
       return a[b:e];
      while 1 == 1:
       lastState = SensorState("2")
 while (SensorState ("2") == lastState):
   time.sleep(0.5)
       print "State Changed!" + SensorState("2")
    

    For LIBCEC the action for Turn on is echo "on 0" | sudo cec-client -s -d 1 and echo "standby 0" | sudo cec-client -s -d 1 to turn it off.

    Over SSH all commands will work good on its own, but i need a script…
    It is my first time with Phyton, the Script should be easy for someone with more experience in this. Maybe someone could help mit with this?

    Thank you for your help!

    1 Reply Last reply Reply Quote 1
    • P Offline
      paviro Admin
      last edited by May 8, 2016, 5:43 PM

      Why not use NodeJS for the script?

      We're all stories in the end. Just make it a good one, eh?

      – The Doctor

      1 Reply Last reply Reply Quote 0
      • M Offline
        MichMich Admin
        last edited by May 8, 2016, 7:51 PM

        Go for node. Adding a python solution would make no sense.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          2/3
          Last post
        Enjoying MagicMirror? Please consider a donation!
        MagicMirror created by Michael Teeuw.
        Forum managed by Sam, technical setup by Karsten.
        This forum is using NodeBB as its core | Contributors
        Contact | Privacy Policy