Help! Hot to make this automation survive restart

I was trying to get a easy tracker for my home taking advantage of homekit integration, i managed to do it through input booleans exposed to apple home app, everything works flawlessly, but when i do a restart o reload automations, the tracker turn not_home and i have to trigger manually to recover the previous states, even though the inputs booleans do saves their states. Any suggestions? This is my automation so far


alias: 'Homekit tracker '
description: ''
trigger:
  - platform: state
    entity_id: input_boolean.alexis
  - platform: state
    entity_id: input_boolean.stefany
condition: []
action:
  - service: device_tracker.see
    data:
      dev_id: '{{ trigger.to_state.object_id }}'
      location_name: '{{ ''home'' if trigger.to_state.state == ''on'' else ''not_home'' }}'
mode: single

So you inquire exclusive support from Taras?

Should I tag people?

For more information, refer to guideline 16 in the FAQ.

3 Likes

Im sorry about my mistake I just tag him because he was really helpful when i started asking for an automation. I should read again the rules, I delete the tag btw thanks for point that

There are hundreds or even thousands of nice and competent people here in the forum :+1:t4: Point your questions/support requests to all of them rather than to a single person and you’ll multiply the chances to find the answers you are seeking for.

1 Like

Add a couple of extra triggers:

trigger:
  - platform: state
    entity_id: input_boolean.alexis
  - platform: state
    entity_id: input_boolean.stefany
  - platform: homeassistant
    event: start
  - platform: event
    event_type: automation_reloaded

I tried add this extra triggers before, but they just create more trackers and didn’t update the correct ones

Sorry, I really should have read your question a bit more carefully. My solution will work if you use two separate animations, one for each entity, and hard-code the dev_id into the action rather than using that template.

Alternatively, you could run a separate startup animation that toggles each of the input_booleans twice.

can you give an example how?. I’m sorry if asking too much, I’m just a little bit lost with your explanation

alias: Alexis tracker
description: Update Alexis status.
id: 33a0b48a-83e0-4578-a0ac-f5d1feed03cf
trigger:
  - platform: state
    entity_id: input_boolean.alexis
  - platform: homeassistant
    event: start
  - platform: event
    event_type: automation_reloaded
action:
  - service: device_tracker.see
    data:
      dev_id: alexis
      location_name: "{{ {'on': 'home', 'off': 'not_home'}[states('input_boolean.alexis')] }}"

…and then a similar one for Stefany. The id is just a unique string: I use a UUID4 from here. By including it, you can access the automation traces in the UI.

Your location_name template structure was fine, but I’ve included an alternative here, as I’d write it.

1 Like

this work flawlessly thanks for your help

1 Like