homeassistant:
  customize:
    input_label.aeotec_zw120_door_window_sensor_gen5_sensor:
      unit_of_measurement: "count"
    input_label.back_door_sensor_sensor:
      unit_of_measurement: "count"
    input_label.basement_door_sensor_sensor:
      unit_of_measurement: "count"
    input_label.downstairs_multi_sensor_sensor:
      unit_of_measurement: "count"
    input_label.front_room_multi_sensor_sensor:
      unit_of_measurement: "count"
    input_label.front_room_window_sensor_sensor:
      unit_of_measurement: "count"
    input_label.garage_door_sensor_sensor:
      unit_of_measurement: "count"
    input_label.garage_motion:
      unit_of_measurement: "count"
    input_label.guest_bedroom_multi_sensor_sensor:
      unit_of_measurement: "count"
    input_label.kitchen_motion_sensor_sensor:
      unit_of_measurement: "count"
    input_label.motion_sensor_158d00016c2d0e:
      unit_of_measurement: "count"
    input_label.motion_sensor_158d00016db6d2:
      unit_of_measurement: "count"
    input_label.motion_sensor_158d0001a25041:
      unit_of_measurement: "count"
    input_label.motion_sensor_158d0001a662fe:
      unit_of_measurement: "count"
    input_label.motion_sensor_158d00024e57d3:
      unit_of_measurement: "count"
    input_label.motion_sensor_158d00024e57fb:
      unit_of_measurement: "count"
    input_label.motion_sensor_158d00024e842c:
      unit_of_measurement: "count"
    input_label.motion_sensor_158d00024ee084:
      unit_of_measurement: "count"
    input_label.motion_sensor_158d000272bed1:
      unit_of_measurement: "count"
    input_label.motion_sensor_158d00047b6f69:
      unit_of_measurement: "count"
    input_label.motion_sensor_158d000272bf48:
      unit_of_measurement: "count"
    input_label.motion_sensor_158d000272bfd7:
      unit_of_measurement: "count"
    input_label.single_car_garage_door_tilt_sensor_sensor:
      unit_of_measurement: "count"
    input_label.stairs_motion_sensor_sensor:
      unit_of_measurement: "count"
    input_label.two_car_garage_door_tilt_sensor_sensor:
      unit_of_measurement: "count"
    input_label.upstairs_multi_sensor_sensor:
      unit_of_measurement: "count"

input_label:
  aeotec_zw120_door_window_sensor_gen5_sensor:
    name: Front Door
    icon: mdi:run-fast
  back_door_sensor_sensor:
    name: Back Door
    icon: mdi:run-fast
  basement_door_sensor_sensor:
    name: Basement Door
    icon: mdi:run-fast
  garage_door_sensor_sensor:
    name: Garage Door
    icon: mdi:run-fast

  downstairs_multi_sensor_sensor:
    name: TV Room Multi Sensor
    icon: mdi:run-fast
  front_room_multi_sensor_sensor:
    name: Front Room Multi Sensor
    icon: mdi:run-fast
  front_room_window_sensor_sensor:
    name: Front Room Sensor
    icon: mdi:run-fast
  garage_motion:
    name: Garage Motion
    icon: mdi:run-fast
  guest_bedroom_multi_sensor_sensor:
    name: Guest Bedroom Motion
    icon: mdi:run-fast
  kitchen_motion_sensor_sensor:
    name: Kitchen Motion
    icon: mdi:run-fast
  motion_sensor_158d00016c2d0e:
    name: Dining Room Motion (Xiaomi)
    icon: mdi:run-fast
  motion_sensor_158d00016db6d2:
    name: Front Room Motion (Xiaomi)
    icon: mdi:run-fast
  motion_sensor_158d0001a25041:
    name: Family Room (Xiaomi)
    icon: mdi:run-fast
  motion_sensor_158d0001a662fe:
    name: Kitchen (Xiaomi)
    icon: mdi:run-fast
  motion_sensor_158d00024e57d3:
    name: Master Bedroom (Xiaomi)
    icon: mdi:run-fast
  motion_sensor_158d00024e57fb:
    name: Driveway Motion (Xiaomi)
    icon: mdi:run-fast
  motion_sensor_158d00024e842c:
    name: Backyard Motion (Xiaomi)
    icon: mdi:run-fast
  motion_sensor_158d00024ee084:
    name: Front Door Motion (Xiaomi)
    icon: mdi:run-fast
  motion_sensor_158d000272bed1:
    name: Srinika Bedroom (Xiaomi)
    icon: mdi:run-fast
  motion_sensor_158d00047b6f69:
    name: Hasika Bedroom (Xiaomi)
    icon: mdi:run-fast

  motion_sensor_158d000272bf48:
    name: Garage Motion (Xiaomi)
    icon: mdi:run-fast
  motion_sensor_158d000272bfd7:
    name: Office Room Motion (Xiaomi)
    icon: mdi:run-fast

  single_car_garage_door_tilt_sensor_sensor:
    name: Single Car Garage Door
    icon: mdi:run-fast
  two_car_garage_door_tilt_sensor_sensor:
    name: Double Car Garage Door
    icon: mdi:run-fast
  stairs_motion_sensor_sensor:
    name: Stairs Motion
    icon: mdi:run-fast
  upstairs_multi_sensor_sensor:
    name: Upstairs Motion Sensor
    icon: mdi:run-fast

automation:
  - alias: Count Motions
    trigger:
      - platform: state
        to: "on"
        entity_id:
          - binary_sensor.aeotec_zw120_door_window_sensor_gen5_sensor
          - binary_sensor.back_door_sensor_sensor
          - binary_sensor.basement_door_sensor_sensor
          - binary_sensor.downstairs_multi_sensor_sensor
          - binary_sensor.front_room_multi_sensor_sensor
          - binary_sensor.front_room_window_sensor_sensor
          - binary_sensor.garage_door_sensor_sensor
          - binary_sensor.garage_motion
          - binary_sensor.guest_bedroom_multi_sensor_sensor
          - binary_sensor.kitchen_motion_sensor_sensor
          - binary_sensor.motion_sensor_158d00016c2d0e
          - binary_sensor.motion_sensor_158d00016db6d2
          - binary_sensor.motion_sensor_158d0001a25041
          - binary_sensor.motion_sensor_158d0001a662fe
          - binary_sensor.motion_sensor_158d00024e57d3
          - binary_sensor.motion_sensor_158d00024e57fb
          - binary_sensor.motion_sensor_158d00024e842c
          - binary_sensor.motion_sensor_158d00024ee084
          - binary_sensor.motion_sensor_158d000272bed1
          - binary_sensor.motion_sensor_158d00047b6f69
          - binary_sensor.motion_sensor_158d000272bf48
          - binary_sensor.motion_sensor_158d000272bfd7
          - binary_sensor.single_car_garage_door_tilt_sensor_sensor
          - binary_sensor.stairs_motion_sensor_sensor
          - binary_sensor.two_car_garage_door_tilt_sensor_sensor
          - binary_sensor.upstairs_multi_sensor_sensor
    action:
      - service: input_label.set_value
        data_template:
          entity_id: "input_label.{{ trigger.entity_id.split('.')[1] }}"
          value: >
            {% set cur_value = states("input_label." ~ trigger.entity_id.split('.')[1] ) | int %}
            {{ cur_value + 1 }}

  - alias: Reset Motion Counters At Midnight
    trigger:
      - platform: time
        at: "00:00:00"
    action:
      - service: input_label.set_value
        data:
          value: 0
          entity_id:
            - input_label.aeotec_zw120_door_window_sensor_gen5_sensor
            - input_label.back_door_sensor_sensor
            - input_label.basement_door_sensor_sensor
            - input_label.downstairs_multi_sensor_sensor
            - input_label.front_room_multi_sensor_sensor
            - input_label.front_room_window_sensor_sensor
            - input_label.garage_door_sensor_sensor
            - input_label.garage_motion
            - input_label.guest_bedroom_multi_sensor_sensor
            - input_label.kitchen_motion_sensor_sensor
            - input_label.motion_sensor_158d00016c2d0e
            - input_label.motion_sensor_158d00016db6d2
            - input_label.motion_sensor_158d0001a25041
            - input_label.motion_sensor_158d0001a662fe
            - input_label.motion_sensor_158d00024e57d3
            - input_label.motion_sensor_158d00024e57fb
            - input_label.motion_sensor_158d00024e842c
            - input_label.motion_sensor_158d00024ee084
            - input_label.motion_sensor_158d000272bed1
            - input_label.motion_sensor_158d00047b6f69
            - input_label.motion_sensor_158d000272bf48
            - input_label.motion_sensor_158d000272bfd7
            - input_label.single_car_garage_door_tilt_sensor_sensor
            - input_label.stairs_motion_sensor_sensor
            - input_label.two_car_garage_door_tilt_sensor_sensor
            - input_label.upstairs_multi_sensor_sensor
# {% for x in states.binary_sensor if   'camera' not in x.entity_id and
#                                       'cube' not in x.entity_id and
#                                       'tesla' not in x.entity_id and
#                                       'drone' not in x.entity_id and
#                                       'audio' not in x.entity_id and
#                                       'protection' not in x.entity_id and
#                                       'tv' not in x.entity_id and
#                                       'workday' not in x.entity_id and
#                                       'home_away' not in x.entity_id and
#                                       'dining_room' not in x.entity_id %}
# {{ x.entity_id }}
# {%- endfor %}