(service_name: str)
| 2004 | pending = _rusense_notify_state.get('pending_close_ts') |
| 2005 | if pending is not None and (now - pending) > _RUSENSE_SIGHTING_MERGE_S: |
| 2006 | if alerts_now: |
| 2007 | po.notify_rusense( |
| 2008 | 'presence', |
| 2009 | "\U0001F6E1️ A monitored space is now empty.", |
| 2010 | title="RuSense — Empty") |
| 2011 | _rusense_close_sighting(pending) # ends at the moment it actually fell |
| 2012 | _rusense_notify_state['pending_close_ts'] = None |
| 2013 | # Vitals lag first detection, so keep filling in the open sighting while |
| 2014 | # the space stays occupied (no-op when there is no open sighting). |
| 2015 | if present: |
| 2016 | _rusense_update_sighting(now, conf if confident else None, vitals) |
| 2017 | # Publish the smoothed, model-aware presence decision (the SAME state that |
| 2018 | # gates alerts) for the dashboard to render — one source of truth instead |
| 2019 | # of the frontend re-deriving presence from a noisier 2s window. |
| 2020 | bk_present = _rusense_notify_state.get('presence_state', False) |
| 2021 | _rusense_notify_state['presence_pub'] = { |
| 2022 | 'present': bool(bk_present), |
no test coverage detected