Skip to content

Periodically detects ambient brightness (using camera) and sets the mirror brightness accordingly

License

Notifications You must be signed in to change notification settings

eric-h-st/MMM-AmbientBrightnessDetection

Repository files navigation

MMM-AmbientBrightnessDetection

Extension for the MagicMirror. Monitors the room's ambient brightness by sampling images from the attached camera and calculating the brightness in the image. Supports automatic brightsness adjutment via MMM-RemoteControl.

Notes:

  • As of now, this has been tested with the PI camera module and a USB Logitech webcam, but should work with any PI compatibale webcam.
  • This module does not have to be visible to operate (send notifications) and update the screen brightness. If visible, will show and optionally animate brightness changes.

Screenshots

Installation

cd ~/MagicMirror/modules
git clone https://github.com/eric-h-st/MMM-AmbientBrightnessDetection.git
cd MMM-AmbientBrightnessDetection
npm install

Using the module

To use this module, add it to the modules array in the config/config.js file:

modules: [
	{
		module: 'MMM-AmbientBrightnessDetection',
		position: "fullscreen_above", // Optional, but if used- it is recommended to use "fullscreen_above" only
		config: {
			// See 'Configuration options' for more information.
		}
	}
]

Configuration Options

The following properties can be configured:

Option Description
device Camera device name and path, in case more than one camera is connected to the PI
For example: /dev/device0
Possible values: string, or null to select the default camera.
Default value: null
captureWidth Width, in pixels, of the image to capture in order to calculate the brightness

Possible values: int
Default value: 640
Note: The bigger the sample, the longer it would take to calculate. A 640x480 image should be accurate enough.
capturHeight Height, in pixels, of the image to capture in order to calculate the brightness

Possible values: int
Default value: 480
Note: The bigger the sample, the longer it would take to calculate. A 640x480 image should be accurate enough.
captureIntervalSeconds The frequency of re-capturing and re-calculating the brightness, in seconds

Possible values: int > 0
Default value: 60
animateBrightnessChange When visible, should brightness changes be animated?
Possible values: boolean
Default value: true
autoSetBrightnessViaRemoteControl Should MMM-RemoteControl be notified with a REMOTE_ACTION to set the brightness according to the ambient light in the room?

Possible values: boolean
Default value: true
autoBrightnessFactorViaRemoteControl Factor to add to the edge values when setting the brightness via MMM-RemoteControl
The factor is added when the calculated automatic brightness is either very high or very low, in order to avoid screen blanking at close-to-dark environments, or screen too bright in very bright environments.
Possible values: 1 >= int <= 100 or null for no factor
Default value: null
autoBrightnessMinValueViaRemoteControl Minimum value to for brightness when setting via MMM-RemoteControl
Possible values: 10 > int < 200 or null for none
Default value: null
autoBrightnessMaxValueViaRemoteControl Maximum value to for brightness when setting via MMM-RemoteControl
Possible values: 10 > int < 200 or null for none
Default value: 30

Developer Notes

This module broadcasts a AMBIENT_BRIGHTNESS_DETECTED notification with the payload of an integer representing the percentage of ambient light detected. You could use it to perform various actions.

This module also broadcasts a REMOTE_ACTION notification (to be used by the MMM-RemoteControl module) with the payload of an integer between 10-200 representing coresponding to the percentage of ambient light detected within the specific range supported by that module.

Dependencies

  • node-webcam (installed via npm install)
  • MMM-RemoteControl (optional) for auto-brightness

The MIT License (MIT)

About

Periodically detects ambient brightness (using camera) and sets the mirror brightness accordingly

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published