Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejeffreystone/187e943ec5d32cba461460fdb7dbe6e6 to your computer and use it in GitHub Desktop.
Save thejeffreystone/187e943ec5d32cba461460fdb7dbe6e6 to your computer and use it in GitHub Desktop.
State Based Template Framework - Sensor and Binary Sensor
template: # Not needed if you are saving this in a template.yaml. But required in configuration.yaml or a package
- sensor:
- name: sensor_1 # not required, but should be - used as entity_id and friendly_name
unique_id: sensor_1 # not required, but is if you want to be able to manage this via the UI
icon: mdi:cat # not required
device_class: none # Can be helpful when displaying state, if not included default is none
# All Device Classes -> https://www.home-assistant.io/integrations/sensor/#device-class
state: > # required
{{ states('sensor.cat_count') | int }}
- binary_sensor
- name: sensor_2 # not required, but should be - used as entity_id and friendly_name
unique_id: sensor_2 # not required, but is if you want to be able to manage this via the UI
icon: mdi:cat # not required
device_class: presence # Can be helpful when displaying state, if not included default is none
# All Binary Sensor Device Classes -> https://www.home-assistant.io/integrations/binary_sensor/#device-class
state: > # required, and for binary sensor neeeds to be either (off, on), (enable, disabled), (true, false)
{{ is_state('sensor.cat_home','home') }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment