Addon restart automation

Hi!

Anyone knows how to make an automation based on addon state “stop/start/restart”?
I tried with the supervisor integration but it is not working…
I have frigate addon installed and I want to make an automation when the addon has been restarted.

Thank you in advance!

1 Like

Can you please share what you tried that did not work?

I enabled "binary_sensor.frigate_nvr_running" entity from Supervisor integration, but when I stop/start or restart the addon, nothing happens…

I found something on the internet and now I am trying with a rest sensor like this

- platform: rest
  resource: http://192.168.0.102:8123/api/hassio/addon/ccab4aaf_frigate/info
  name: Frigate Status
  value_template: >
    {{ value_json.data.state }}
  scan_interval:
    minutes: 10
  headers:
    Authorization: "Bearer eyJ0eXAiOiJKV1QiLSI<redacted>diHAIUWRikjhasdiuahYDIuYweriyaA"
    Content-Type: application/json

But I get " Template variable error: ‘value_json’ is undefined when rendering ‘{{ value_json.data.state }}’ "

Edit: Someone told me to use

  value_template: '{{ value_json.state }}'

But I get the same error

Please don’t post your tokens. They can be used against you. I have edited your post and hidden the original.

Stopping the the addon should work. Not sure what the sensor scan interval is though (it is polled, not push). The addon might have to be off for somewhere between 10 to 60 seconds before the state updates.

Leaving aside your value_template issues, you’re definitely not going to catch a brief addon outage with this:

I would recommend not increasing this to the required 1 second. As calls to the HA API are quite CPU intensive.

Does the Frigate addon (not the supervisor integration) produce any sensors that you could monitor for the “unavailable” state when it is off?

Their state may be pushed and thus update virtually instantly.

1 Like

It’s ok, I didn’t put the real token, thanks anyway for being cautious :hugs:

The scan interval from that rest sensor, does really not matter because I get error in the log, as I said… so… it is useless

Yes, frigate from supervisor, have a very big delay, if I restart the addon, it won’t catch the state change, only if I stop it for 20-30 seconds, then it will catch the new state.

The frigate addon, no… nothing, only a sensor which is always unknown :smiley:

1 Like

:+1:

I was looking at it the other way, even if we fix the state issue, it will have the same problem as the supervisor integration. Worse even, you’d have to wait up to 10 minutes for it to update. And as I said, it is not a good idea to poll the HA API too frequently.

Yeah ok, the polling interval must be 30 seconds.

I’m out of ideas then.

Why do you need to know if the Frigate addon is restarted?

There may be another way to accomplish what you need.

I understand.
I think the most helpful thing is something which can be requested and get the state… But I don’t have any idea.
I still search :slight_smile:
Thank you!

Can you tell us why you need this?

What are you trying to do?

I have 10 cameras configured in frigate and two of the cameras I want them to have motion enabled not always. All good, an automation with a time schedule will do this, it is ok. But when I restart the frigate addon, all the frigate settings for cameras are reinitiated, does not care about the automation.
In my mind, I said that if I will make an automation which will be triggered by the frigate restart and the first automation can be retriggered/rechecked, something.

Real case: I have recording and clips enabled for two cameras, but I always have these settings off (manually, everytime when I restart the addon), because I don’t need them on right now and I don’t want to change the settings in the yaml till I want them real on :smiley: Thinking that maybe I can find a way to achieve this by having a sensor for addon state, could open me more ideas in the future…

You can use the frigate sensors from the frigate integration directly. Just have the automation trigger when:

state:
  entity: camera.your_frigate_cam
  from: unavailable
  to: 

Thanks for the idea. I will use switch.camera_kitchen_frigate_detect because the camera could go unavailable if is not working, but the switch it will be always available.

That’s exactly what I suggested earlier:

1 Like

:frowning: This switch entity it is from frigate integration, in the devices, not from the frigate addon. The addon produces the integration and the integration produces entities.
I think it was a little confusing because I looked straight to the addon part :smiley: , but yes, if you follow the path, it will take me to the same result, now that I know what you have referred to.
Anyway, I didn’t know that the entities like switch/camera from the integration will go “unavailable” instantly, I was always watch other entities from frigate and those were not changing the state when frigate was off…