Persistant state during restart

I’ve been having an issue with my Alarm Automation. I have 5 persons being tracked. If no one is home the alarm arms. Works great in all situations except one. If for some reason an update or reboot occurs to my HA or router(persons are being tracked by wifi) the state goes to unknown or unavailable. When this happens, the alarm is armed before any persons are refreshed and show as home. When this happens and no one notices, the alarm goes off. Sometimes in the middle of the night when someone gets up to go to the restroom. Is there a way to preserve the states of these persons when these updates or reboots occur?

Can you share your automation? I am sure we can add a condition to ignore when the state goes to unknown or unavailable.

Here is the automation. I tried to add a condition for the router reboot but it didn’t seem to do anything.

‘’’

  • id: ‘1682009254299’
    alias: Auto Arm Alarm
    description: ‘’
    trigger:
    • platform: state
      entity_id:
      • group.persons
        to: not_home
        condition:
    • condition: not
      conditions:
      • condition: state
        entity_id: button.rbr50_reboot
        state: unavailable
        action:
    • service: alarmo.arm
      data:
      mode: away
      skip_delay: false
      force: false
      entity_id: alarm_control_panel.alarmo
      mode: single
      ‘’’

Can you please format it properly (enclose it with ``` on the first and last line).

regardless, try this:

trigger:
  - platform: state
    entity_id:  group.persons
    to: not_home
    from: home

…so the trigger must be from not_home to home instead of (for example from unavailable to not_home.

Ok… I removed the condition and added the from… Will test this and see what it does…

- id: '1682009254299'
  alias: Auto Arm Alarm
  description: ''
  trigger:
  - platform: state
    entity_id:
    - group.persons
    to: not_home
    from: home
  condition: []
  action:
  - service: alarmo.arm
    data:
      mode: away
      skip_delay: false
      force: false
      entity_id: alarm_control_panel.alarmo
  mode: single

great, let me know know it goes.

as you only have one entity (group.persons) you can out it all one one line iof you wish:

entity_id: group.persons

You might have to get creative for when you restart HA or reboot your router since that might still trigger things, but it’s easy to add some Jinja to your automation to help with that, for instance:

{% if states('group.persons') not in ['unavailable','unknown'] %}
 ...
{% endif %}

I think that fixed one scenario, and now I have another. Not sure what I can to about it. The alarm went off in the middle of the night again. This time it was not related to the reboot\restart, but because the only one home lost wifi signal, was detected as away, and the system armed itself.

Using the wifi of the cell phone as the presence sensor. I guess I need to find a more reliable way to track presence.