Docs/myggspray-auto-lights.yaml
IKEA MYGGSPRAY - Smart Motion Lights
Manual import URL: https://github.com/0libote/HA-BPs/blob/main/blueprints/myggspray-auto-lights.yaml
Setup guide
IKEA MYGGSPRAY Smart Motion Lights
IKEA MYGGSPRAY Smart Motion Lights

Manual import URL:
https://github.com/0libote/HA-BPs/blob/main/blueprints/myggspray-auto-lights.yaml
This blueprint starts a motion-lighting session when any selected motion detector reports activity, at least one selected illuminance sensor says the room is dark enough, and every selected light is off and available. Motion-only detectors are supported because the illuminance entities are selected separately. It can remember the latest normal light profile, restore it before switch-off and clean up after manual changes, unavailable entities or an overlong session.
Before you start
- Pair the MYGGSPRAY with Home Assistant through Matter-over-Thread.
- Identify the occupancy or motion entities covering the area and at least one
- Make sure the target lights can be controlled normally from Home Assistant.
illuminance entity. They do not have to belong to the same devices.
Configure
- Import the blueprint and select Create automation.
- Select one or more motion/occupancy sensors, one or more illuminance sensors,
- Choose the lux threshold, automation brightness and optional colour.
- Set the clear delay and maximum session runtime.
- Optionally add activation conditions, then save and test in a non-critical
and the target lights.
room first.
The remembered profiles use temporary dynamic scenes. A Home Assistant restart or scene reload clears them; the blueprint learns them again the next time the lights are used normally.
Troubleshooting
- Motion does not start a session: check the current lux value and confirm every
- Lights turn off while part of the area is occupied: confirm every selected
- A previous profile is not restored: use the light normally while the motion
- A bulb briefly flashes an old colour: some bulbs recall their hardware state
target light is both off and available.
motion detector reports on while it detects activity. The clear delay starts only after all selected detectors report off.
session is idle so a fresh profile can be learned.
before applying Home Assistant's combined brightness and colour command. A generic blueprint cannot pre-stage a physically powered-off bulb.
Input reference
Every field, default and selector — generated from the YAML at build time.
| Input | Selector | Default |
|---|---|---|
Motion / Occupancy Sensorsmotion_sensorSelect one or more motion detectors. They do not need to expose a light-level entity; motion from any selected detector can turn the lights | entity | null |
Illuminance Sensorsilluminance_sensorSelect one or more light-level entities. These can belong to different detectors from the motion sensors. The lights may turn on when at lea | entity | null |
Turn On Belowlux_thresholdMotion only activates the lights below this level. | number | 30 |
| Input | Selector | Default |
|---|---|---|
Lightstarget_lightsAll selected lights must be off before activation. | entity | null |
Automation Brightnessbrightness_pct | number | 70 |
Automation Colourcolour_modeKeep the bulb's remembered colour, choose RGB, or choose white temperature. | select | "keep" |
RGB Colourrgb_colourUsed only when Automation Colour is RGB colour. | color_rgb | [255,214,170] |
White Colour Temperaturecolour_temperatureUsed only when Automation Colour is White colour temperature. | color_temp | 2700 |
Turn On Transitionturn_on_transitionZero is usually best for avoiding a visible ramp from an old state. | number | 0 |
| Input | Selector | Default |
|---|---|---|
No Motion Before Offno_motion_duration | duration | {"hours":0,"minutes":2,"seconds":0} |
Maximum Runtimemaximum_runtimeSafety timeout for a stuck sensor or missed clear event. | duration | {"hours":3,"minutes":0,"seconds":0} |
| Input | Selector | Default |
|---|---|---|
Remember & Restore Previous Light Profilerestore_previous_profileRemember the latest normal ON profile while idle. Before automatic switch-off, restore it and then turn the light off. | boolean | true |
Respect Manual Changesrespect_manual_changesRetained for compatibility with existing automations. Manual OFF is always treated as a release of motion-light control in this version. Ric | boolean | true |
Extra Activation Conditionsextra_activation_conditionsOptional conditions such as schedules, sleep mode, media state, or house mode. | condition | [] |
Source
Full blueprint — also on GitHub.
blueprint:
name: IKEA MYGGSPRAY - Smart Motion Lights
author: 0libote
description: |
Smart motion lighting for IKEA MYGGSPRAY Matter-over-Thread sensors and
other Home Assistant motion detectors.
Created by @0libote
GitHub: https://github.com/0libote/HA-BPs
Behaviour:
- Starts when any selected motion detector reports motion, at least one
selected illuminance sensor is below the chosen threshold, and every
selected light is off and available.
- Motion-only detectors are supported; illuminance can be supplied by
separate detectors that expose light-level entities.
- Sends brightness and colour in the same light.turn_on call, avoiding an
intentional "turn on, then dim/recolour" sequence.
- Turns the lights back off after occupancy has stayed continuously clear
for the configured time.
- Remembers each light's latest normal ON brightness/colour while idle and
can restore that profile immediately before automatic switch-off.
- Manual/external OFF immediately releases the current motion-light session.
- Recovers from stale session locks when all target lights are already off.
- Cleans up after sensor/light faults and has a maximum-runtime failsafe.
- Supports extra user-defined activation conditions.
Previous-profile memory:
Home Assistant reports active brightness/colour attributes as null while a
light is off. Without requiring helpers, this blueprint keeps temporary
dynamic scenes whenever target lights are normally ON. Profile tracking is
locked while motion lighting owns the lights, so the automation profile
cannot overwrite the remembered normal profile.
Dynamic scenes are temporary. They are cleared by a Home Assistant restart
or scene reload and are relearned the next time each light is used normally.
If no profile has been learned yet, cleanup still turns the light off but
cannot pre-load its previous brightness/colour first.
Flash prevention:
Home Assistant cannot generically pre-stage brightness/colour while a light
is physically off. This blueprint therefore sends brightness and colour in
one turn_on command. A bulb that itself briefly recalls an old hardware
state before applying that command cannot be fully prevented by a blueprint.
domain: automation
source_url: https://github.com/0libote/HA-BPs/blob/main/blueprints/myggspray-auto-lights.yaml
homeassistant:
min_version: 2025.7.0
input:
sensors:
name: MYGGSPRAY Sensors
icon: mdi:motion-sensor
collapsed: false
input:
motion_sensor:
name: Motion / Occupancy Sensors
description: |
Select one or more motion detectors. They do not need to expose a
light-level entity; motion from any selected detector can turn the
lights on.
selector:
entity:
multiple: true
filter:
- domain: binary_sensor
device_class: occupancy
- domain: binary_sensor
device_class: motion
illuminance_sensor:
name: Illuminance Sensors
description: |
Select one or more light-level entities. These can belong to
different detectors from the motion sensors. The lights may turn
on when at least one valid reading is below the threshold.
selector:
entity:
multiple: true
filter:
- domain: sensor
device_class: illuminance
lux_threshold:
name: Turn On Below
description: Motion only activates the lights below this level.
default: 30
selector:
number:
min: 0
max: 1000
step: 1
unit_of_measurement: lx
mode: box
lights:
name: Lighting
icon: mdi:lightbulb-group
collapsed: false
input:
target_lights:
name: Lights
description: All selected lights must be off before activation.
selector:
entity:
multiple: true
filter:
- domain: light
brightness_pct:
name: Automation Brightness
default: 70
selector:
number:
min: 1
max: 100
step: 1
unit_of_measurement: "%"
mode: slider
colour_mode:
name: Automation Colour
description: Keep the bulb's remembered colour, choose RGB, or choose white temperature.
default: keep
selector:
select:
mode: dropdown
options:
- label: Keep previous colour
value: keep
- label: RGB colour
value: rgb
- label: White colour temperature
value: temperature
rgb_colour:
name: RGB Colour
description: Used only when Automation Colour is RGB colour.
default: [255, 214, 170]
selector:
color_rgb:
colour_temperature:
name: White Colour Temperature
description: Used only when Automation Colour is White colour temperature.
default: 2700
selector:
color_temp:
unit: kelvin
min: 2000
max: 6500
turn_on_transition:
name: Turn On Transition
description: Zero is usually best for avoiding a visible ramp from an old state.
default: 0
selector:
number:
min: 0
max: 5
step: 0.1
unit_of_measurement: s
mode: slider
timing:
name: Timing
icon: mdi:timer-outline
collapsed: false
input:
no_moti
… (truncated — see GitHub for full file)