Forked from WizBangCrash/occupancy-response-sml001.yaml
Last active
February 9, 2025 11:20
-
-
Save joepio/9c5514ea5907c8c8ec40353f8a32c723 to your computer and use it in GitHub Desktop.
Occupancy Blueprint for Philips Hue SML001 motion sensor - Zigbee2MQTT version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
blueprint: | |
name: Occupancy Detection Response (SML001) - Zigbee2MQTT | |
description: | | |
Controls a light (or lights) using a Philips Hue SML001 motion sensor connected to Home Assistant via Zigbee2MQTT. | |
- Turns on lights when occupancy is detected and off when unoccupied. | |
- Uses different brightness settings for day and night. | |
- Optionally, disables motion-based activation if a media player (e.g., TV) is on. | |
- Allows user-configurable fade-in and fade-out times for smooth lighting effects. | |
domain: automation | |
input: | |
occupancy_entity: | |
name: Occupancy Sensor | |
description: "The occupancy sensor to use for this automation" | |
selector: | |
entity: | |
domain: binary_sensor | |
device_class: occupancy | |
ieee_id: | |
name: Occupancy Sensor Zigbee2MQTT Device Name | |
description: "The Zigbee2MQTT friendly name of the sensor" | |
selector: | |
text: | |
o_to_u_delay: | |
name: Occupied to Unoccupied Delay | |
description: "Time in seconds before turning off lights after last motion detection" | |
default: 180 | |
selector: | |
number: | |
min: 0 | |
max: 1800 | |
mode: box | |
unit_of_measurement: "seconds" | |
sensitivity: | |
name: Sensor Sensitivity | |
description: "Adjusts motion sensitivity (0 = least sensitive, 2 = most sensitive)" | |
default: 2 | |
selector: | |
number: | |
min: 0 | |
max: 2 | |
illuminance_entity: | |
name: Illuminance Sensor | |
description: "The luminance sensor to use for light-based triggers" | |
selector: | |
entity: | |
domain: sensor | |
device_class: illuminance | |
luminance_value: | |
name: Light Trigger Level | |
description: "Light will turn on if ambient light is below this level" | |
default: 6 | |
selector: | |
number: | |
min: 2 | |
max: 3000 | |
mode: box | |
unit_of_measurement: "lx" | |
light_entity: | |
name: Lights | |
description: "The light(s) to control" | |
selector: | |
entity: | |
domain: light | |
daytime_brightness: | |
name: Daytime Brightness | |
description: "Brightness level during the day" | |
default: 75 | |
selector: | |
number: | |
min: 10 | |
max: 100 | |
mode: box | |
unit_of_measurement: "%" | |
nighttime_brightness: | |
name: Nighttime Brightness | |
description: "Brightness level at night" | |
default: 10 | |
selector: | |
number: | |
min: 10 | |
max: 100 | |
mode: box | |
unit_of_measurement: "%" | |
daytime_colour: | |
name: Daytime Colour Temperature | |
description: "Colour temperature of the light during the day" | |
default: 4500 | |
selector: | |
number: | |
min: 2200 | |
max: 6500 | |
step: 100 | |
mode: box | |
unit_of_measurement: "Kelvin" | |
nighttime_colour: | |
name: Nighttime Colour Temperature | |
description: "Colour temperature of the light at night" | |
default: 3000 | |
selector: | |
number: | |
min: 2200 | |
max: 6500 | |
step: 100 | |
mode: box | |
unit_of_measurement: "Kelvin" | |
fade_in_time: | |
name: Light Fade-In Duration | |
description: "Time in seconds for the light to fade in when turning on" | |
default: 2 | |
selector: | |
number: | |
min: 0 | |
max: 10 | |
step: 0.5 | |
mode: slider | |
unit_of_measurement: "seconds" | |
fade_out_time: | |
name: Light Fade-Out Duration | |
description: "Time in seconds for the light to fade out when turning off" | |
default: 3 | |
selector: | |
number: | |
min: 0 | |
max: 10 | |
step: 0.5 | |
mode: slider | |
unit_of_measurement: "seconds" | |
disable_entity: | |
name: Disable Sensor (Input Boolean) | |
description: "An input_boolean to disable the motion sensor" | |
default: {} | |
selector: | |
target: | |
entity: | |
domain: input_boolean | |
media_entity: | |
name: Disable if Media Player is On | |
description: "A media_player entity that disables the motion sensor when active (e.g., TV)" | |
default: {} | |
selector: | |
target: | |
entity: | |
domain: media_player | |
variables: | |
ieee_id: !input ieee_id | |
disable_entity: !input disable_entity | |
media_entity: !input media_entity | |
mode: single | |
trigger: | |
- platform: homeassistant | |
event: start | |
- platform: state | |
entity_id: !input occupancy_entity | |
condition: | |
# Using a template allows us to cater for either of these entities being "None" | |
- alias: "Exit if sensor is disabled" | |
condition: template | |
value_template: "{{ True if not disable_entity else is_state(disable_entity.entity_id, 'off') }}" | |
- alias: "Exit if media player on" | |
condition: template | |
value_template: "{{ True if not media_entity else is_state(media_entity.entity_id, 'off') }}" | |
action: | |
- alias: "What caused the trigger?" | |
choose: | |
- conditions: | |
- condition: template | |
value_template: "{{ trigger.platform == 'homeassistant' }}" | |
sequence: | |
- service: mqtt.publish | |
data: | |
topic: "zigbee2mqtt/{{ ieee_id }}/set" | |
payload: '{"occupancy_timeout": {{ o_to_u_delay }}}' | |
- service: mqtt.publish | |
data: | |
topic: "zigbee2mqtt/{{ ieee_id }}/set" | |
payload: '{"motion_sensitivity": {{ sensitivity }}}' | |
- conditions: | |
- condition: template | |
value_template: "{{ trigger.platform == 'state' and trigger.to_state.state == 'on' }}" | |
- condition: numeric_state | |
entity_id: !input illuminance_entity | |
below: !input luminance_value | |
sequence: | |
- alias: "Night time or day time?" | |
choose: | |
- conditions: | |
- condition: time | |
after: "22:00:00" | |
before: "07:00:00" | |
sequence: | |
- service: light.turn_on | |
entity_id: !input light_entity | |
data: | |
brightness_pct: !input nighttime_brightness | |
kelvin: !input nighttime_colour | |
transition: !input fade_in_time | |
- conditions: [] | |
sequence: | |
- service: light.turn_on | |
entity_id: !input light_entity | |
data: | |
brightness_pct: !input daytime_brightness | |
kelvin: !input daytime_colour | |
transition: !input fade_in_time | |
- conditions: | |
- condition: template | |
value_template: "{{ trigger.platform == 'state' and trigger.to_state.state == 'off' }}" | |
sequence: | |
- service: light.turn_off | |
entity_id: !input light_entity | |
data: | |
transition: !input fade_out_time |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment