Automation to notify when integration stops working

I have a Meross integration which started acting up recently and devices keep going offline (even though it says they are connected in the logs) while I have raised the issue with the owner, I need a way to fix their availability with some automation

It looks like this when they stop responding:
image

I created an automation like so but it never triggers:

- id: '1627152370529'
  alias: Meross is unavailable
  description: ''
  trigger:
  - platform: state
    entity_id: switch.recliners
    to: Unavailable
    for: 0:05:00
  condition: []
  action:
  - service: notify.mobile_app_sm_g998b
    data:
      message: Meross is unavailable for more than 5 mins
  mode: single

Any ideas why it is not triggering, I’m thinking the trigger logic but it looks good to me

Because you are using:

to: Unavailable

When you should be using:

to: unavailable

As shown in your screen-shot of the state.

Letter case (upper or lower) is important.

Another alternative if you have a lot of entities that needed attention in case they are unavailable-

It will create an entity called sensor.unavailable_entities that updates once every 60 seconds.You’ll also have the option to set an automation to notify you if some devices became unavailable.

Doh it’s with a capital U when you click on its history so I just used that.
Updated it and will see if it works now :slight_smile:
Thanks

Yeah you can only trust the state shown in the Developer Tools States Menu as Lovelace will prettyfy some states.

1 Like

Apparently there is also a way to reload an integration without full HA restart.
Any idea how that achieved?

It’s done via the UI (Integrations > The integration > Overflow menu > Reload). Currently, there’s no service call to do that (you can check that by examining the list of available service calls in Developer Tools > Services).

well, there is actually, for config entry integrations:

  reload_integration:
    alias: Reload integration
    mode: restart
    sequence:
      service: homeassistant.reload_config_entry
      data:
        entry_id: >
          {% set mapper =
            {'AirVisual':'37d37cd6c04641e5d73831be06a9105b',
             'Gdacs':'0587f746fec34d07a32ed70de2d2b18a',
             'Ikea':'37702840aa084ed4af2155b0811b1951',
             'Ipp':'999b75bd3d7349b793995c7ae3d51716',
             'Life360':'2a76ec65ecd84857afe24e2ac2659e7c',
             'Luftdaten Roosendaal T':'08dc2eb8057b11ebaf313de78a26ad7c',
             'Luftdaten Rotterdam P':'c6a0d358ef29c38385928de7375f1281',
             'Luftdaten Rotterdam T':'01644083c1d0f7e30cee3dd55625012e',
             'Luftdaten Tilburg P':'9565788c086e11eba8da7ba5c092109c',
             'Luftdaten Tilburg T':'850adf05086e11eb9835bd2520ff1bf8',
             'OpenWeather':'1dd06a93f9d711ea93621f21b9d8b93f',
             'Owntracks':'6b204295435a42c9a50d0c7229c4322a',
             'Philips Hue 1':'7afbac0fccdd4e478fcd82fae86fabc5',
             'Philips Hue 2':'a4ed6f6c6f4e4c2bb00940672dfd731e',
             'Plugwise':'474a410dc55f45ad8124f87f62baa412',
             'Plex':'dd13e187a0764dfea368905ce8654e05',
             'Spotify':'12edb162fa5111eaa980717559c47c08',
             'Synology Dsm':'fd8b44750830460c98e7938ae3881367',
             'Weatherbit':'79ae77f927714985b1046191c05f2b5c',
             'Xbox':'e8cd7b63b43040dd0c7e86ddf685abe6'} %}
          {% set state = states('input_select.select_integration') %}
          {% set id = mapper[state] if state in mapper %}
          {{id}}

2 Likes

Where do you get the ids?

Not really dedicated to reloading integrations, is it?

It appears that its ability to reload an integration was an afterthought because the user is required to supply an identifier that isn’t readily available unless they explore the hidden registry files.

Even Updating Add-Ons don’t require hard-to-find identifiers:

Screenshot from 2021-07-25 10-33-10
Screenshot from 2021-07-25 10-32-58

Nevertheless, I appreciate you posting that and the only thing left unsaid is explaining to the OP where to find the integration’s identifier.

Exactly, where indeed.

They are located in a file in a hidden directory where the average user is not supposed to be exploring.

config/.storage/core.config_entries

Look for the integration’s name and then use its entry_id.

To be clear, this only applies to integrations that are initially configured via the UI and not YAML.

1 Like

wouldnt say an after thought, (this was developed after my FR was issued) but indeed, things should become more obvious, and I hope they will.

  1. Your original request suggested a far more intuitive way of calling a dedicated integration.reload service.

  2. I agree with Kane610’s comment.

FWIW, there’s a PR in the works to provide new templating functions to access registry data. Whenever it becomes available, it may offer a means of acquiring the entry_id using the integration’s name (assuming it’s unique).

Found it, thanks

But homeassistant.reload_config_entry doesn’t seem to work for me

Has this ever come to pass?

Here’s what’s available:

Templating - Config Entries

1 Like

(post deleted by author)

@dbrunt Please open a new topic with your question :wink:

./Klaas

1 Like