vd Brink Home Automations

Home automations: Home Assistant, ESPHome, Node-RED and more.

Follow me on GitHub

DIY Zigbee chair occupancy sensor

Based on a Zigbee contact sensor and a car seat pressure sensor

Introduction

Zigbee chair occupancy sensor For my office I want a way to detect if I'm there. To detect that, it's possible to use a motion sensor, or to detect when you sit still on a chair, it's alo possible to use a radar millimeter wave sensors, the downside with one of those, those will also detect animals or blowing fans.

My solution

This “hack” uses a Zigbee contact sensor connected to a car seat sensor to detect if a chair is occupied, exactly what I needed!


Table of Contents


Required hardware

This project only requires these two devices:

Zigbee contact sensor
I have a Zigbee network, so I use a Zigbee contact sensor, but any other protocol sensor can also be used for this.

contact sensor

And a Car seat pressure sensor

pressure sensor

To connect both, you need also some soldering tools:


Wire them together

opened_contact_sensor.jpg remove_reed_from_contact_sensor.jpg solder_wires_to_reed_contacts.jpg wires_through_hole.jpg double_pressure_sensor.jpg

pillow_with_sensor_top.jpg


Automations

With this new sensor, it’s possible to make all kind different automations, a few examples are:

  • When the light can turn on/off
  • When the PC can shut down
  • When it’s time to take a break
  • When it’s time to end your working day
  • Control the room temperature because it’s occupied

Home Assistant

Create a new custom chair sensor

By default, the contact status is inverted as preferred. With this addition in the configuration.yaml file, it creates a new sensor that shows the correct status in the dashboard.


# Sourcecode by vdbrink.github.io
# configuration.yaml
binary_sensor:
  - platform: template
    sensors:
      chair:
        friendly_name: "chair"
        value_template: >-
          {% if is_state('binary_sensor.contact1_contact', 'off') %}
             on
          {% else %}
             off
          {% endif %}

homeassistant:
  customize: 
    binary_sensor.chair:
      icon: mdi:chair-rolling

Occupancy time sensor

With the history stats it’s possible to create new sensors which indicate how long something takes. In this case we want to track how long the chair is occupied on each day. The start/reset is on a new day and end time is the current time and within this timeframe how long has entity binary_sensor.chair_work the state on. This is the code to add in the configuration.yaml.
This will generate a new sensor called sensor.chair_occupancy.


# Sourcecode by vdbrink.github.io
# configuration.yaml
- platform: history_stats
  name: chair occupancy
  entity_id: binary_sensor.chair_work
  state: 'on'
  type: time
  start: '{{ now().replace(hour=0, minute=0, second=0) }}'
  end: '{{ now() }}'

Graphs

Now we have the data, it’s possible to present this on the dashboard!

Total time as text

Show the amount of time on the chair as an entity.
8 hours, 12 minutes and 36 seconds.

Entities Card in Home Assistant

# Sourcecode by vdbrink.github.io
type: entities
entities:
  - entity: sensor.chair_occupancy

Occupied in time as graph

Or show the occupied time in a line graph in time.
It shows exactly where I took some breaks, the line is flat at that time.

History graph Card in Home Assistant

A History graph Card is used for this.


# Sourcecode by vdbrink.github.io
type: history-graph
entities:
  - entity: sensor.chair_occupancy
logarithmic_scale: false
hours_to_show: 24
title: Office chair

Total time in a bar

Use the same History graph Card with binary sensors, then it’s presented as a bar.

Here I add the chair occupancy sensor next to the value of a pir motion sensor in the same room. As you can see, the chair sensor is much more reliable if you sit still!

History graph bar Card in Home Assistant

# Sourcecode by vdbrink.github.io
type: history-graph
entities:
  - entity: binary_sensor.chair_occupancy
  - entity: binary_sensor.motion_occupancy
hours_to_show: 24


Indicate if someone is sitting on the chair.


# Sourcecode by vdbrink.github.io
type: entities
entities:
  - entity: binary_sensor.chair_occupancy


^^ Top

<< See also my other Zigbee content


Top | Homepage | Best Buy Tips