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?