All docs

Docs/myggspray-auto-lights.yaml

IKEA MYGGSPRAY - Smart Motion Lights

automation · HA 2025.7.0+ · 14 inputs

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.

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

![Import blueprint](https://my.home-assistant.io/redirect/blueprint_import/?blueprint_url=https%3A%2F%2Fgithub.com%2F0libote%2FHA-BPs%2Fblob%2Fmain%2Fblueprints%2Fmyggspray-auto-lights.yaml)

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

Configure

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

View the YAML

Input reference

Every field, default and selector — generated from the YAML at build time.

MYGGSPRAY Sensors sensors · open by default
InputSelectorDefault
Motion / Occupancy Sensors
motion_sensor
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
entity null
Illuminance Sensors
illuminance_sensor
Select 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 Below
lux_threshold
Motion only activates the lights below this level.
number 30
Lighting lights · open by default
InputSelectorDefault
Lights
target_lights
All selected lights must be off before activation.
entity null
Automation Brightness
brightness_pct
number 70
Automation Colour
colour_mode
Keep the bulb's remembered colour, choose RGB, or choose white temperature.
select "keep"
RGB Colour
rgb_colour
Used only when Automation Colour is RGB colour.
color_rgb [255,214,170]
White Colour Temperature
colour_temperature
Used only when Automation Colour is White colour temperature.
color_temp 2700
Turn On Transition
turn_on_transition
Zero is usually best for avoiding a visible ramp from an old state.
number 0
Timing timing · open by default
InputSelectorDefault
No Motion Before Off
no_motion_duration
duration {"hours":0,"minutes":2,"seconds":0}
Maximum Runtime
maximum_runtime
Safety timeout for a stuck sensor or missed clear event.
duration {"hours":3,"minutes":0,"seconds":0}
Restore & Safety safety · collapsed by default
InputSelectorDefault
Remember & Restore Previous Light Profile
restore_previous_profile
Remember the latest normal ON profile while idle. Before automatic switch-off, restore it and then turn the light off.
boolean true
Respect Manual Changes
respect_manual_changes
Retained 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 Conditions
extra_activation_conditions
Optional 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)