Skip to content

Instantly share code, notes, and snippets.

@JerryWorkman
Last active February 8, 2017 01:08
Show Gist options
  • Save JerryWorkman/d669d2da69d5861af227a4812b0928ba to your computer and use it in GitHub Desktop.
Save JerryWorkman/d669d2da69d5861af227a4812b0928ba to your computer and use it in GitHub Desktop.
layout title description date sidebar comments sharing footer
page
Countdown Timer
Countdown Time for Home Assistant
2016-12-20 22:00
true
false
true
true

Description: Countdown Timer for Home Assistant

Combines one or more binary_sensors (typically PIR sensors) and a switch to provide a switch that automatically turns off after a specified delay time.

Creates a sensor that displays the time remaining before the switch is turned off.

If the sensors detect activity while the switch is on then the timer is restarted.

The can be accomplished otherwise in Home Assistant. However this component reduces the user configuration from dozens of lines of automation and scripting to just a few lines in the configuration.yaml file.

# Example configuration.yaml entry
sensor countdown_timer:
  platform: countdown_timer
  timers:
    lr_light:
      sensors: binary_sensor.lr_pir1
      switch:  switch.lr_light_switch
  • timers (Required): The array that contains all timers.
    • **identifier ** (Required): Name of the timer. Multiple entries are possible.
      • sensors (Required): One or more binary sensor (comma separated).
      • switch (Required): Light (or other) switch.
      • delay (Optional): delay time. default: 20 seconds.
      • restart (Optional): True/False, restart timer when HA is restarted. Default: False

My hardware:

My Config:

# My configuration.yaml entry

sensor countdown_timer:
  platform: countdown_timer
  timers:
    lr_timed_light:
      sensors:    binary_sensor.lr_pir_sensor_7_0
      switch:     switch.lr_wall_light_switch_4_0
    fr_timed_light:
      sensors:    binary_sensor.fr_pir_sensor_9_0 #,binary_sensor.fr_pir_2_sensor_10_0
      switch:     switch.fr_light_switch_19_0
      restart:    True
    garage_timed_light:
      sensors:    binary_sensor.garage_side_pir_sensor_14_0 #,binary_sensor.garage_back_pir_sensor_13_0
      switch:     switch.garage_light_switch_12_0
      restart:    True

Suggestions:

#In group.yaml something like this:

  Living Room Light:
    entities:
      - binary_sensor.lr_pir_sensor_7_0
      - switch.lr_wall_light_switch_4_0
      - sensor.lr_timed_light

  Living Room:
    view: yes
    entities:
      - sensor.lr_temp
      - group.nest_thermostat
      - climate.homelr
      - group.living_room_light
      - group.media
      - camera.living_room

Screenshot:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment