Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template:
- # These first few combine several binary sensors into a single entity that reflects the state of all the sensors
- # I also add each sensor as an attribute so that the individual states are visible under more info.
- # This sensor returns the aggregated states of all the contact sensors
- - binary_sensor:
- - unique_id: ingress_points_group
- name: Ingress Points
- device_class: safety
- state: >
- {% set sensors = [states.binary_sensor.front_door_sensor,
- states.binary_sensor.kitchen_window_north,
- states.binary_sensor.side_window,
- states.binary_sensor.living_room_window_north] %}
- {{ sensors | selectattr('state','eq','on') | list | count > 0 }}
- attributes:
- Front Door: >
- {{ states('binary_sensor.front_door_sensor') }}
- Kitchen North Window: >
- {{ states('binary_sensor.kitchen_window_north') }}
- Living Room Side Window: >
- {{ states('binary_sensor.side_window') }}
- Living Room North Window: >
- {{ states('binary_sensor.living_room_window_north') }}
- # This sensor returns the aggregated states of all the motion sensors
- - binary_sensor:
- - unique_id: motion_group
- device_class: motion
- name: Motion Sensors
- state: >
- {% set sensors = [states.binary_sensor.kitchen_motion,
- states.binary_sensor.living_room_motion,
- states.binary_sensor.pir_sensor] %}
- {{ sensors | selectattr('state','eq','on') | list | count > 0 }}
- attributes:
- Living Room Motion: >
- {{ states('binary_sensor.living_room_motion') }}
- Kitchen Motion: >
- {{ states('binary_sensor.kitchen_motion') }}
- Hall Motion: >
- {{ states('binary_sensor.pir_sensor') }}
- # This sensor returns the aggregated states of all the contact and motion sensors
- - binary_sensor:
- - unique_id: door_motion_group
- device_class: safety
- name: Doors and Motion Sensors
- state: >
- {% set sensors = [states.binary_sensor.kitchen_motion,
- states.binary_sensor.living_room_motion,
- states.binary_sensor.front_door_sensor,
- states.binary_sensor.kitchen_window_north,
- states.binary_sensor.side_window,
- states.binary_sensor.living_room_window_north,
- states.binary_sensor.pir_sensor] %}
- {{ sensors | selectattr('state','eq','on') | list | count > 0 }}
- attributes:
- Living Room Motion: >
- {{ states('binary_sensor.living_room_motion') }}
- Kitchen Motion: >
- {{ states('binary_sensor.kitchen_motion') }}
- Hall Motion: >
- {{ states('binary_sensor.pir_sensor') }}
- Front Door: >
- {{ states('binary_sensor.front_door_sensor') }}
- Kitchen North Window: >
- {{ states('binary_sensor.kitchen_window_north') }}
- Living Room Side Window: >
- {{ states('binary_sensor.side_window') }}
- Living Room North Window: >
- {{ states('binary_sensor.living_room_window_north') }}
- # This last sensor I included as an example of a sensor that returns a text value rather than a binary.
- # This sensor returns a text representation of the current time of day
- - sensor:
- - unique_id: period_of_day
- name: Period of the day
- state: >
- {% if (as_timestamp(state_attr('sun.sun','next_dusk'))) -
- (as_timestamp(state_attr('sun.sun','next_setting'))) < 0 %}
- Dusk
- {% elif (as_timestamp(state_attr('sun.sun','next_rising'))) -
- (as_timestamp(state_attr('sun.sun','next_dawn'))) < 0 %}
- Dawn
- {% elif (state_attr('sun.sun', 'elevation')) < 0 %}
- Night
- {% else %}
- Day
- {% endif %}
- icon: >
- {% set period = states('sensor.period_of_day') %}
- {% if period == 'Dusk' %} mdi:weather-sunset-down
- {% elif period == 'Dawn' %} mdi:weather-sunset-up
- {% elif period == 'Night' %} mdi:weather-night
- {% else %} mdi:weather-sunny
- {% endif %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement