Appdaemon status notification

I added this at the weekend, and think its worth sharing. Its just a method of sending a notification if the appdaemon service stops running.

  1. Create a command_line sensor to detect the service. You will probably need to change the command line to match how you start the appdaemon service.
  - platform: command_line
    name: "appdaemon status"
    command: systemctl show appdaemon@$USER.service | awk -F= '/^SubState=/ {print $2}'
    scan_interval: 60

  1. yaml automations to send notifications when the sensor enters/exits running. Its conditional on an input_boolean being on, so you can test without being distracted with notifications.
automation:

  - alias: "appdaemon started"
    trigger:
      platform: state
      entity_id: sensor.appdaemon_status
      to: 'running'
    condition:
      condition: state
      entity_id: input_boolean.notifications
      state: 'on'
    action:
      service: notify.notify
      data:
        message: Appdaemon has started
        title: HomeAssistant Error

  - alias: "appdaemon stopped"
    trigger:
      platform: state
      entity_id: sensor.appdaemon_status
      from: 'running'
    condition:
      condition: state
      entity_id: input_boolean.notifications
      state: 'on'
    action:
      service: notify.notify
      data:
        message: Appdaemon has stopped
        title: HomeAssistant Error
4 Likes

the idea is nice, but i dont think im gonna use it.
the only moment that appdaemon stopped working in all the time i used it is when my RPI stopped working.
at that moment HA is also stopped so thereā€™s no notification then :wink:

but ill keep it in mind. maybe in the (near) future i will splitt up the machine that runs HA and Appdaemon again, and then i can let appdaemon send a notify when HA is down and HA send a notify when appdaemon is down.

I agree with @ReneTode in that the execution of this might not be what Iā€™m looking for either, but the idea behind it is fantastic! Working with outside sources of information, that is, not specific to the Home Assistant service and entities within Home Assistant itself, is a GREAT idea. :slight_smile:

That said ā€“ how often do you find AppDaemon stopping? If the service is setup correctly, this should not happen.

Neverā€¦ so far.

I hope I didnā€™t give the impression that appdaemon is unreliable. But since all my automations run on it, I need to know if it stops.

I am trying to figure out a way of getting an alert if my Pi goes down. That hasnā€™t happened yet either.

For what itā€™s worth, you can run AppDaemon on multiple computers, all simultaneously. You could even have each instance ā€œpingā€ the other to make sure itā€™s still responding. If itā€™s not responding, have the fallback ā€œtake overā€ in case of listeners.

Heh - high availability active-active AppDaemon :slight_smile:

I would also say I have found it to be very reliable but I am biased, Iā€™m gratified that others spoke up on the subject:

I still think itā€™s an intriguing idea though - once or twice I have stopped AppDaemon on during tests and wondered why everything stopped working ā€¦

1 Like

in the future i would consider running HA on 1 device and AD on another.
but both installed on both devices.
with the crosscheck you then always can use 1 or the other to start the backup version on the same machine.

1 Like

This line is like perfect! Thanks! Going to use this to monitor my various services to use as sensors