• 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.

MMM-Pir-Sensor - Hue lights control

Scheduled Pinned Locked Moved Unsolved Troubleshooting
5 Posts 3 Posters 2.1k Views 4 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.
  • K Offline
    Kimzer
    last edited by Jun 17, 2018, 3:26 PM

    Hey!

    Im using a pir sensor on my mirror and the MMM-Pir-Sensor module.
    Wich works just great.

    Thing is tho, i also added a little python script to turn on some hue light strips i have on the back of the mirror. Wich is being executed when the screen turns on from movement being detected. Buuuut, that is a slow and sluggish way of doing it.

    import requests
    import time
     
    colors = {'white':'{"on":true,"bri":255,"sat":0,"hue":0}',
              'blue':'{"on":true,"bri":255,"sat":255,"hue":46920}',
              'red':'{"on":true,"bri":255,"sat":255,"hue":0}',
              'yellow':'{"on":true,"bri":255,"sat":255,"hue":12750}'}
     
    hour = time.localtime().tm_hour
     
    time_colors = {(0,2):'red', (2,7):'blue', (7, 20):'white', (20,24):'yellow'}
    color_schema  = {hour:color for hours, color in time_colors.items() for hour in range(hours[0], hours[1])}
    color = colors[color_schema[hour]]
    
     
    headers = {
        'Accept': 'application/json',
    }
     
    requests.put('http://192.168.1.47/api/xxxxxxxxxxxxxxxxxxx/lights/2/state', headers=headers, data=color)
    

    Thats the actual script being ran. But execing python from within the node helper.js its too much delay for my liking.
    Does anyone have any decent suggestions for speeding this up or a better way of doing it?

    1 Reply Last reply Reply Quote 1
    • K Offline
      Kimzer
      last edited by Jun 18, 2018, 6:31 PM

      Anyone? :)

      O 1 Reply Last reply Jun 19, 2018, 1:38 AM Reply Quote 0
      • O Offline
        orayoflighto Project Sponsor @Kimzer
        last edited by Jun 19, 2018, 1:38 AM

        @kimzer

        Check this thread out:

        https://forum.magicmirror.builders/topic/4649/led-backlight-for-mirror-pir-to-control-them/5

        1 Reply Last reply Reply Quote 0
        • K Offline
          Kimzer
          last edited by Jun 21, 2018, 9:49 AM

          Thats exactly what i am already doing. But its too slow for my taste :p

          1 Reply Last reply Reply Quote 0
          • G Offline
            grantc66
            last edited by Jun 24, 2018, 9:43 PM

            I found it to slow running it through the mm, maybe cause I’m running it from a pi0.
            So I run the PIR python script (it also does the led strips) as a background task outside of mm enabled at boot via crontab.
            It’s more responsive and seems to use less resources.

            1 Reply Last reply Reply Quote 0
            • 1 / 1
            1 / 1
            • First post
              2/5
              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