Sørens hjørne

No switch

Ever since I visited my good friend Jonas, , I have been thinking about their Phillips hue motion sensor mounted in their hallway. It simply turns on the light, if there is movement.

With a price tag of 239 kr. (~36USD), that is in my opinion 34USD too much. I have fiddled around with PIR motion sensors for my Raspberry pi in the past. You can get them in China for 2 USD a piece.

Since it is Corona Saturday and everything closes at 10pm, I might as well make the best of it and set up a motion sensor in by bedroom.

My thoughts behind this little build: If there is movement, the light needs to be turned on and stay on for 3 minutes (Updated: This was later adjusted to 60 sec). If there is continuous movement, the light must stay on. If the movement stops the light needs to be turned off – but only the first time. There is no need for the script to tell my hue system to keep turning it off. Furthermore, the light should not turn on in the middle of the night if I move around in my sleep. I usually get up between 6:15am and 6:30 and I leave the room to take my shower. I guess it is fine if the light turns on from 7am until 10pm. After 10pm there should be no light in my bedroom. In the future this could be adjusted to take in to account if it is a weekday or weekend.

Never the less, I created this small piece of code. It is less than 50 lines and with the motion sensor hooked up to the pie, my 1.5 USD sensor has replaced an expensive one. Total build time from start to final build was about 40 minutes.

Last minute update: Added a function, so after 8pm, the light will be dimmed. This is to not blind me and wake me up when im about to go to bed