Read the statement by Michael Teeuw here.
MMM-MQTTScreenOnOff - alternative to PIR
-
Hello! I’ve been using a MagicMirror for years and have worked on and developed modules for a while as well, but this is the first I’m posting here on the forums in hopes someone finds it useful besides myself.
I’ve used various PIR modules to make my screen only turn on when someone moves in front of the mirror, to save a lot of power during most times when there’s nobody there. But recently, I’ve installed a bunch of Zigbee motion / presence sensors as part of my smart home upgrades, and decided to ditch the standalone sensor on the mirror and integrate it into the global presence detection instead. The simplest way to do this is via MQTT, since all sensor data flows through there anyway, and the integration can be really lightweight.
What came out is https://github.com/olexs/MMM-MQTTScreenOnOff. Take a look :) No screenshots, since it is a pure background module with nothing rendered to screen.
The default option values approximate a connection to local MQTT and subscribing to a Zigbee2MQTT motion / occupancy sensor data. The module also allows to make the mirror turn the display off at startup (assuming it may restart at night during automated updates, or after a power outage, etc).
You can configure the commands used to turn the screen on and off - by default I use
DISPLAY=:0.0 xrandr --output HDMI-1 --auto
andDISPLAY=:0.0 xrandr --output HDMI-1 --off
, this works on a current out-of-the-box Raspberry Pi OS (ex-Raspbian) installation, but you may need something else depending on which hardware and OS your mirror is running on.Finally, you can optionally make the module broadcast a
USER_PRESENCE
message to other modules in the mirror when the screen turns on and off. This can be useful to disable regular updates when the mirror is inactive, especially for modules that use quota-limited or paid APIs (e.g. Google Maps or similar).I’ve been using this for almost a year now, and it’s solid. External sensor works much more reliably for me than any standalone PIR I’ve plugged into the mirror itself before.
Let me know what you think.
-
@olex.s awesome… I have another mirror runtime, that I integrated MQTT for this very thing, I added HA discovery to create (‘screen’) devices in HA, that can be used in automations etc…
when I am away, or every night going to sleep (I don’t have home locale presence sensors yet)
I was thinking of doing the same thing with MagicMirror , but haven’t yet, so this is very interesting
do you expose the display on/off command strings, such that the user could change them in config if xrandr is not the command (wlr_randr for wayland window mgr)
-
@sdetweil Yes, the commands are both in the options object and can be changed to anything.
-
@olex.s great, thanks
-
@olex.s This is great, thank you for sharing. Like you, I’ve been running MagicMirror on a PIR sensor connected to GPIO pins and it’s worked well but this MQTT setup is on another level!
I’ve never used HA, and MQTT is a whole new learning curve for me but it’s setup and working a treat, i love it.
I’m also running Rpisurv on another Pi and your code would be the icing on the cake for that, but i have no idea how to even implement this.
Anyhow, thought i would say thanks for the great work, it’s much appreciated and opened my eyes on what can be achieved.
-
As you know for sure I‘m really a fan of MMM-Pir - for (my) good reasons.
For a friend of mine I‘ve build a second mirror and because he is heavily engaged in smarten his home :-) I‘ve considered to use alternatives to a PIR sensor - because they are definitely unsmart…
With this I‘ve seeked for an integration for his homee solution which is not really capable for MQTT and randomly found a really cool device which I would like to share with you, guys!
This is not a „motion“ sensor but a real „presence“ sensor (radar based, not infrared) which even is able to identify a silently sitting person!
In addition this genius thingy talks MQTT, delivers the „presence“ status in a JSON object and so it is absolutely easy to use it with magic mirror and the herein presented module MQTTScreenOnOff.This sensor is pretty expensive and invented and build by a small startup here in Germany 🇩🇪 .
You can find this sensor here.
The webpage is in German but for some reason the default UI is in English :-)
From my perspective this is defnitely worth the money (this is the fourth radar sensor I‘ve bought but the first one which is in the near of „working“)The mqttTopic transmitted is: „tele/senvolon/STATE“ and the mqttPayloadOccupancyField is „presence“.
(The middle part is configurable in the sensor‘s UI, I‘ve decided to use vendor‘s name).I REALLY miss the nice animation and the dimming of MMM-Pir but I‘m definitely thinking about to use this sensor as well.
(Which would be a major effort because my Mirror has an exact slot for the PIR sensor which is round and this sensor is squared so I will have to do some rough wood-work. On the other hand I MAY place the sensor away from the mirror on the opposite wall or in an other place and hide the hole from PIR sensor ….)Nice MQTT module - thanks for this idea!
Warmest regards,
Ralf -
@rkorell leave the pir sensor there, just use the other. disable one module, add the other.
i have a zigbee sensor on my office wall, and at the end of the hall and on the fireplace, they control my
office desk light, hall light, and lights over the kitchen island
all collected by zigbee2mqtt which feeds mqtt into home assistant
all running in docker containers.my mirror visibility is controlled by camera motion today, but now that i have the hall sensor, i can move to ha automations
fun stuff
-