Advertisement
xangin

Sensor of count how many lights/switch on

Apr 13th, 2022 (edited)
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 0.49 KB | None | 0 0
  1. #put this in configuration.yaml
  2. template:
  3.   - sensor:
  4.       - name: "lights_on"
  5.         unique_id: lights_on
  6.         icon: mdi:lightbulb-on
  7.         state: >
  8.          {% set lights = [ 'light.guest_room',                            
  9.                             'switch.mainbath_left_toolbox',
  10.                             'switch.mainbath_right_mainbath'  #no "," at last entity
  11.                           ] %}
  12.           {{ expand(lights) | selectattr('state','eq','on') | list | count }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement