Navigation

    MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    UNSOLVED MMM-Pir-Sensor - Hue lights control

    Troubleshooting
    3
    5
    1407
    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.
    • Kimzer
      Kimzer last edited by

      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
      • Kimzer
        Kimzer last edited by

        Anyone? 🙂

        O 1 Reply Last reply Reply Quote 0
        • O
          orayoflighto Project Sponsor @Kimzer last edited by

          @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
          • Kimzer
            Kimzer last edited by

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

            1 Reply Last reply Reply Quote 0
            • G
              grantc66 last edited by

              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
              • First post
                Last post
              Enjoying MagicMirror? Please consider a donation!
              MagicMirror created by Michael Teeuw.
              Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
              This forum is using NodeBB as its core | Contributors
              Contact | Privacy Policy