Sensors

Misc examples using sensors.

Doors Open (Specific)

Creates a sensor indicating how many specific doors are open.

Usage Ideas
  • Count open house doors, exterior doors, first floor doors, car doors, etc
  • Alert when its bedtime and doors are open
sensor:
- platform: template
sensors:
doors_open:
friendly_name: "Doors"
unit_of_measurement: 'open'
value_template: >
{% set doors = [
states.binary_sensor.front_door,
states.binary_sensor.kitchen_door,
] -%}
{% set covers = [
states.cover.garage_door,
] -%}
{% set doors_open = doors | selectattr('state','eq','on') | list | count -%}
{% set covers_open = covers | selectattr('state','eq','open') | list | count -%}
{{ doors_open + covers_open }}

Lights On

Creates a sensor indicating how many lights are on.

note

This example includes in all and only entities in the light domain (ex. light.bathroom). See the Lights On (Specific) example to include specific entities (ex. light.bathroom, switch.garage_light).

sensor:
- platform: template
sensors:
lights_on:
friendly_name: "Lights"
unit_of_measurement: 'on'
value_template: >
{{ states['light'] | selectattr('state','eq','on') | list | count }}

Lights On (Specific)

Creates a sensor indicating how many specific lights are on.

sensor:
- platform: template
sensors:
lights_on:
friendly_name: "Lights"
unit_of_measurement: 'on'
value_template: >
{% set lights = [
states.light.living_room_lamp,
states.light.bathroom,
states.switch.garage_light,
] %}
{{ lights | selectattr('state','eq','on') | list | count }}

Lights On Areas (Specific)

Creates sensors indicating how many specific lights are on in specific areas.

sensor:
- platform: template
sensors:
lights_on_indoors:
friendly_name: "Lights | Indoors"
unit_of_measurement: 'on'
value_template: >
{% set lights = [
states.light.living_room_lamp,
states.light.bathroom,
states.switch.garage_light,
] %}
{{ lights | selectattr('state','eq','on') | list | count }}
lights_on_outdoors:
friendly_name: "Lights | Outdoors"
unit_of_measurement: 'on'
value_template: >
{% set lights = [
states.light.front_door,
states.light.driveway,
] %}
{{ lights | selectattr('state','eq','on') | list | count }}
lights_on:
friendly_name: "Lights | Total"
unit_of_measurement: 'on'
value_template: >
{{ (states.sensor.lights_on_indoors.state | int) +
(states.sensor.lights_on_outdoors.state | int) }}

Locks Unlocked (Specific)

Creates a sensor indicating how many locks are unlocked.

Usage Ideas
  • Count unlocked house doors, car doors, etc
  • Alert when your car is not home and its doors are unlocked
note

Trying to make this example non-specific (ex. like Lights On) does not work.

sensor:
- platform: template
sensors:
locks_unlocked:
friendly_name: "Locks"
unit_of_measurement: 'unlocked'
value_template: >
{% set locks = [
states.lock.front_door,
states.lock.kitchen_door,
] %}
{{ locks | selectattr('state','eq','unlocked') | list | count }}