https://github.com/olexs/mmm-mqttscreenonoff
Allows you to control your MagicMirror's screen on/off state based on an MQTT topic, for example with data from a smart home motion sensor.
https://github.com/olexs/mmm-mqttscreenonoff
magicmirror2 magicmirror2-module motion-sensor mqtt
Last synced: about 1 month ago
JSON representation
Allows you to control your MagicMirror's screen on/off state based on an MQTT topic, for example with data from a smart home motion sensor.
- Host: GitHub
- URL: https://github.com/olexs/mmm-mqttscreenonoff
- Owner: olexs
- License: mit
- Created: 2024-03-25T14:17:49.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-30T19:57:32.000Z (10 months ago)
- Last Synced: 2025-07-30T22:22:04.693Z (10 months ago)
- Topics: magicmirror2, magicmirror2-module, motion-sensor, mqtt
- Language: JavaScript
- Homepage:
- Size: 43 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MMM-MQTTScreenOnOff
## Description
The `MMM-MQTTScreenOnOff` module is a MagicMirror² module that allows you to control the screen on/off state using MQTT messages.
## Installation
1. Navigate to your MagicMirror's `modules` directory and clone the repository:
```bash
git clone https://github.com/olexs/MMM-MQTTScreenOnOff.git
```
2. Install the required dependencies by navigating into the module's directory and running the following command:
```bash
cd MMM-MQTTScreenOnOff
npm install
```
## Configuration
To use the `MMM-MQTTScreenOnOff` module, you need to add the following configuration to the `config/config.js` file of your MagicMirror:
```js
{
module: 'MMM-MQTTScreenOnOff',
config: {
// MQTT server data
mqttServer: "mqtt://localhost",
mqttPort: 1883,
mqttUsername: "",
mqttPassword: "",
// MQTT topic to listen to
mqttTopic: "zigbee2mqtt/Motion Sensor",
// If the topic payload is a JSON object, specify the field that contains the occupancy boolean. If this is not set, the entire payload is treated as a boolean.
mqttPayloadOccupancyField: "occupancy",
// Commands to run to turn the screen on and off
screenOnCommand: "DISPLAY=:0.0 xrandr --output HDMI-1 --auto",
screenOffCommand: "DISPLAY=:0.0 xrandr --output HDMI-1 --off",
// Whether to turn the screen off on startup
defaultOffOnStartup: true,
// Whether to broadcast USER_PRESENCE notification to other modules when the screen is turned on and off (boolean payload)
broadcastUserPresence: false,
}
}
```
All values are optional, defaults are shown above.