import appdaemon.plugins.hass.hassapi as hass from ad_toolbox.smartobject import SmartObject from ad_toolbox.eventhandler import EventHandler from ad_toolbox.expressionparser import ParsingException import time # ============================================================================= # MotionTracker — Multi-area motion tracking app # ============================================================================= # Tracks the last time motion was detected in each configured area and exposes # that information as HA sensor entities. Also optionally tracks door close # events per area and can reset area data in response to custom HA events. # # Inherits all SmartObject YAML keys (see smartobject.py). # # YAML CONFIGURATION # ------------------ # # max_time: # optional, default 120 # Global cap for the "minutes since last motion" sensors. # Overrides the MAX_TIME constant and can itself be overridden # per area with the area-level max_time key. # Precedence: area max_time > app max_time > MAX_TIME constant # # areas: # : # motion_sensors: # One or more binary_sensor entities to watch. # update_on_both_front: true # optional, default false # When true, motion is also recorded on the falling edge # (sensor going on→off), not only on the rising edge. # max_time: # optional # Per-area cap, overrides the app-level max_time. # door_sensor: # optional # Binary sensor for the area door. When the door closes # (on→off), the close timestamp is stored and exposed as # a sensor (see OUTPUT ENTITIES below). # # Shorthand form (no extra options needed): # : # # areas_excluded_from_last_area_with_movement: # - # - ... # Areas that should NOT update sensor.last_area_with_movement when motion is # detected in them (e.g. utility rooms). # # clear_areas_events: #