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.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.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.door_window_sensor_158d0004231f7b:
      unit_of_measurement: "count"
    input_label.door_window_sensor_158d0004248d5b:
      unit_of_measurement: "count"
    input_label.door_window_sensor_158d00040ad8fc:
      unit_of_measurement: "count"
    input_label.door_window_sensor_158d0004880f30:
      unit_of_measurement: "count"
    input_label.door_window_sensor_158d000424a6d6:
      unit_of_measurement: "count"

input_label:
  door_window_sensor_158d000424a6d6:
    name: Front Door
    icon: mdi:run-fast
  door_window_sensor_158d00040ad8fc:
    name: Back Door
    icon: mdi:run-fast
  door_window_sensor_158d0004880f30:
    name: Garage Entry 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

  front_room_window_sensor_sensor:
    name: Front Room Sensor
    icon: mdi:run-fast
  garage_motion:
    name: Garage 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

  door_window_sensor_158d0004248d5b:
    name: Single Car Garage Door
    icon: mdi:run-fast
  door_window_sensor_158d0004231f7b:
    name: Double Car Garage Door
    icon: mdi:run-fast
  stairs_motion_sensor_sensor:
    name: Stairs Motion
    icon: mdi:run-fast

automation:
  - alias: Count Motions
    trigger:
      - platform: state
        to: "on"
        entity_id:
          - binary_sensor.door_window_sensor_158d000424a6d6
          - binary_sensor.door_window_sensor_158d00040ad8fc
          - binary_sensor.door_window_sensor_158d0004880f30 # garage entry door
          - binary_sensor.basement_door_sensor_sensor
          - binary_sensor.front_room_window_sensor_sensor
          - binary_sensor.garage_door_sensor_sensor
          - binary_sensor.garage_motion
          - 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.stairs_motion_sensor_sensor
          - binary_sensor.door_window_sensor_158d0004248d5b # Single Car Garage
          - binary_sensor.door_window_sensor_158d0004231f7b # Double Car Garage
    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.basement_door_sensor_sensor
            - input_label.front_room_window_sensor_sensor
            - input_label.garage_door_sensor_sensor
            - input_label.garage_motion
            - 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.door_window_sensor_158d000424a6d6
            - input_label.door_window_sensor_158d00040ad8fc
            - input_label.door_window_sensor_158d0004880f30
