Check if notify service is available

I have a problem with nfandroidtv integration which doesn’t become available until I turn on my TV.

A solution to my problem would be to check if the notify service exists.
I tried the following, but for notifications, it doesn’t work. It just returns unknown even though it exists:

states("notify.living_room_tv")

This is a major issue for me because my automations don’t continue after failing on sending the notification, so if I am able to check with an if statement the status of this notification, it would solve my problem.

Do you have any tip on how to check this, or any other workaround?


This is the error I get:

Testing Automation uses an unknown service

The automation “Testing Automation” (automation.testing_automation) has an action that calls an unknown service: notify.living_room_tv.

This error prevents the automation from running correctly. Maybe this service is no longer available, or perhaps a typo caused it.

To fix this error, edit the automation and remove the action that calls this service.

Click on SUBMIT below to confirm you have fixed this automation.

I am interested in the ability to check of a service is available. For me personally a Python Script would do, but I have no idea how to check for availability. The only think I can think of is a try and on failure return an “error”, but there’s probably a cleaner way.

@bkbilly You could try adding continue_on_error: true to your service call to make sure your automation continues. For example:

sequence:
  - service: notify.living_room_tv
    continue_on_error: true
    ...

@Recte
Unfortunately the continue_on_error doesn’t work on an automation and I don’t want to create a new python script to call a simple notification service.
There must be another way to check for it’s availability.

I use it myself in several automation steps and can tell it does work, see the docs too. It however could be that it doesn’t work in this specific case, that I don’t know.

We are on the same page when it comes to the Python script. I hope there is a way to check availability using a simple Python script since a try-approach isn’t my way of doing it.

About your TV. Can’t you just check if the TV is on before you try to notify towards it?
I don’t have an android TV, but I do this with my TV by just checking the state of the media_player.<my tv>.

maybe setup a ping sensor?

Here’s what I do: check if the media_player representing the TV is not off before calling the notification service.

  - if: "{{ states('media_player.tv') != 'off') }}"
    then:
      - service: notify.tv
        data:
          message: ... etc ...