Hello, What considerations did you have when deciding which data to expose as binary “alert” sensors (e.g., high crime, rising trend, active priorities) versus keeping it as numeric or Red humana informational sensors, especially in terms of avoiding false positives or over-triggering automations in Home Assistant?
We hard-coded the binary alert logic (e.g. the 50-crime threshold for High Crime Alert, and the custom “rising” trend rule) because we wanted simple, actionable triggers for Home Assistant automations without forcing users to build complex templates.
The main considerations were:
Reducing noise — We used conservative thresholds and a stability band on trends so automations don’t fire on minor fluctuations.
Clear separation — Binary sensors (PROBLEM class) for automations/notifications, numeric sensors + attributes for dashboards and detailed data.
Low false positives — High-crime uses a reasonably high bar (50), trends require a clear directional change, and the others are simple presence checks on official police data.
All of this logic lives in the integration code (not the API). Going forward, these thresholds and rules can easily be made configurable or removed entirely if users prefer to handle alerting themselves.
Specific Considerations for Each Binary Sensor
Binary Sensor
Why it was made binary
How we avoided false positives / over-triggering
Threshold / Logic
High Crime Alert
Clear “something is wrong” trigger
Used a reasonably high fixed threshold (50 crimes in the latest month). This is high enough to represent genuinely elevated activity in most UK neighbourhoods (street-level ~1 mile radius) without firing constantly in busier areas.
total_crimes >= 50 (hardcoded, exposed in attributes)
Rising Crime Trend
Actionable early warning
Added a custom stability band in the trend calculation (abs(diff) <= max(1, oldest * 0.05)). Small fluctuations are treated as “stable”. Only clear directional changes over the chosen history window trigger “rising”.
Custom _trend_label() with 5% + min-1 stability band
Active Policing Priorities
Useful to know when police have declared focus areas
Simple > 0 check on official police data. Very low false-positive risk because priorities are explicitly published by the force.
priorities_count > 0
Upcoming Events
Good for notifications / awareness
Pure presence check (len(events) > 0). Objective data from the police, so minimal risk of spurious triggers.
has_upcoming_events
Neighbourhood Team Assigned
Indicates active local policing presence
Simple > 0 check. Again, based directly on published team data.