#Automation to start Addon

1 messages · Page 1 of 1 (latest)

drifting canopy
#

I'm trying to create an automation that starts the Frigate addon after it detect that my NAS has mounted in HA properly. Here's the automation I have created.

alias: Frigate NAS Check
description: Checks to make sure the frigate nas mount has occured before starting Frigate
triggers:
  - event: start
    trigger: homeassistant
actions:
  - repeat:
      until:
        - condition: template
          value_template: >-
            {{ wait_result is defined and 'Frigate NAS mounted' in
            wait_result.stdout }}
      sequence:
        - action: shell_command.check_frigate_nas_mount
          response_variable: wait_result
        - delay:
            seconds: 10
  - data:
      addon: ccab4aaf_frigate-fa
    action: hassio.addon_start

Here is my shell scrip that exists in HA configuration.yaml

shell_command:
  check_frigate_nas_mount: "mount | grep -q '/media/frigate' && echo 'Frigate NAS mounted' || echo 'Frigate NAS not yet mounted'"

I'm not even sure if it's even running when HA starts up. Frigate isn't starting and I don't see any related logs (errors or otherwise) in HA. I've tried a few different things for value_template (such as {{ wait_result is defined and wait_result['return_code'] == 0 }} (and obv had a slightly diff config). Not sure if there's something here I'm missing or some other way to tell if it's erroring out.

boreal locust
#

I don't think you can use pipes in a shell_command

#

Write a shell script with that command return the appropriate code

drifting canopy
#

Ahh interesting :/ I'll try something else then. Thank you

drifting canopy
#

When an automation runs does it run in some sort of container?

Tried updating the script. When I run the script in a HA terminal it works, but when it runs in an automation it errors out half way through (when I run a command to check if a mount point exists).

boreal locust
#

HA runs in a container

drifting canopy
#

Right, I'm using the VS code add on. Is that terminal shell different from the one that the automations use? From that doc they seem the same.

boreal locust
#

They are different