Skip to content

Instantly share code, notes, and snippets.

@tonyroberts
Last active October 20, 2022 18:07
Show Gist options
  • Save tonyroberts/4b7466c8b4f19d605deab896ed8dab45 to your computer and use it in GitHub Desktop.
Save tonyroberts/4b7466c8b4f19d605deab896ed8dab45 to your computer and use it in GitHub Desktop.
#
# Blueprint to control a light (or lights) using a Philips Hue SML001
# motion sensor connected to Home Assistant via ZHA
#
# Home Assitant configures the sensor to be an Occupancy Sensor at boot,
# setting the Occupied to Unoccipied time and sensitivity of the sensor.
# I used to use HA timers to do this, but Blueprint is now much more simple :-)
#
# Additionally the sensor can be disabled using a oneof two entities.
# I usually link this to a TV state, as I do not want my lights going on & off
# while sitting in the Lounge watching TV.
# I also use an input_boolean to enable me to disable all my occupancy sensors.
#
blueprint:
name: Occupancy Detection Settings (SML001)
description: |
The sets the sensor attributes when Home Assistant boots
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 Zigbee IEEE ID
description: "The zigbee network id of the sensor"
selector:
text:
sensitivity:
name: Sensitivity of sensor
description: |
Set how sensitive we want the sensor to be: 0 = least sensitive
NOTE: Restart Home Assistant on changing this value
default: 2
selector:
number:
min: 0
max: 2
#
# The automation
#
variables:
ieee_id: !input ieee_id
# Trigger mode
mode: single
# Trigger
trigger:
# When HA starts
- platform: homeassistant
event: start
# Actions
# TODO: Figure out how to get ieee address of sensor from entity
action:
- alias: "Update settings"
sequence:
# Set device sensitivity
- service: zha.set_zigbee_cluster_attribute
data:
ieee: "{{ ieee_id }}"
endpoint_id: 2
cluster_id: 0x0406
cluster_type: in
attribute: 0x0030
value: !input sensitivity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment