First Home Assistant Project: Motion Detected!

For my first project, I thought I’d start slow. We have stairs that lead to our basement. The light switch is at the top of the stairs. Normally that’s fine, someone goes down and usually comes back up and turns off the light. However, when I work from home we don’t leave the light on all day. My wife usually turns the light off right after I go down the stairs, which is fine until 5:00 comes around and I’m tripping my way up the stairs in the dark. Home Assistant to the rescue. My idea was to set up a motion sensor and have it talk to the light switch to turn on the light.

Physical Setup

A few days before purchasing the Raspberry Pi setup I picked up the battery operated ZOOZ Z-Wave Plus 4-in-1 Sensor. I installed it at the bottom of the basement stairs facing the hallway. That way when someone walks towards the stairs the sensor should trigger and eventually flip the light. But for now, I wanted to just make the sensor work.

It did take a while for the sensor run its setup. I had to wake it up several times to fully set up. It involved taking a paperclip and rapidly pushing it into a small hole 3 times. Once that is done new entities showed in Home Assistant.

Home Assistant Configuration

I wanted to make the sensor values more friendly so first I added this line to the configuration.yaml file

sensor: !include sensors.yaml

After that I created the file above and added this code:

  - platform: template
    sensors:
      zooz_motion_detect:
        value_template: "{%if states.sensor.zooz_zse40_4in1_sensor_alarm_level.state > '253' %}motion detected{% elif states.sensor.zooz_zse40_4in1_sensor_alarm_level.state == '0' %}standby{% endif %}"
        friendly_name: "Basement Hall Motion"
        entity_id: sensor.zooz_zse40_4in1_sensor_alarm_level
      zooz_motion_battery:
        value_template: "{{ states.zwave.zooz_zse40_4in1_sensor.attributes.battery_level }}"
        friendly_name: "Basement Hall Sensor Battery"
        unit_of_measurement: '%'

This adds two sensors. One that will say “motion detected” or “standby” and another that will display the percentage of battery remaining. I will point out that it seems to always read 100% (Edit: even 3 months later). So I’m not sure how accurate it is. Now when I walk past the sensor the template sensor created in home assistant shows “motion detected”. Now I just need to set up a light switch.


2 thoughts on “First Home Assistant Project: Motion Detected!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.