Hi
I’m looking for a way to know if and which Restful integrations are unavailable for a while.
I’ve found a way to monitor entities and also devices but not for the rest integrations yet.
It would be nice if the solution shows all unavailable integrations though. So not only rest.
Any suggestions?
What I’m using now is an automation that triggers when a rest sensor is not changing it’s state, but I’ve got like 20 rest integrations, with all different entity names, I think this automation solution isn’t best practice and it could be more robust right?
What I’m after: get notified when an integrations goes unavailable for a while and a lovelace card would be nice that displays a list of the unavailable integrations.
If you have a way to identify them logically in a filter or so then you can use a table card. Mine can not be identified based on name or attribs.
If you can identify them, then you can run a ‘while’ in automations based on a list (template filter) and for each item fire an action
Got some help from TheFes… {{ integration_entities('rest') }}
gives you all the rest sensors, from there on you can filter on state and fire this through an automation that could send either the list or a notification per entry
They are strings so not object with attr. My (possibly non efificient) solution would be to iterate over them and find the object via expanding sensors, then you can use attr… let me know if I need to provide some help…repeating that I am not the specialist but it will get you what you want (likely)
EDIT: am away from server rright now so no examples
vingerha is on the right track, expand will take the list of entity_id’s and convert it to a list of state objects, and then the filtering will work. Then it can be mapped back to an entity_id or a friendly name depending on what output you want.
There are more solutions to list entities/devices but the OP stated to aim for ‘rest’ only hence. In order to send a notification it requires a list of rest entities in a certain state if (!) you want to use automations. Sending a list with unavailable things can also be done with (hacs) watchman
@mekaneck
The links you’ve shared is about monitoring devices and entities.
I’m looking for the rest integrations or all integrations.
any suggestions for this?
I was thinking about renaming all rest sensors to include the word “rest” at the beginning.
this way I can filter easily.
or maybe better: I see that all of my rest sensors have attributes. When a rest sensor doesn’t pull its data > it doesn’t contain an attribute ( but it still shows available in HA!? )
maybe I can filter those rest sensors that doesn’t have any attributes.
Maybe we’re not using the same language here. Integrations don’t go unavailable and in fact they don’t have a state at all. Neither do devices. In HA, entities are the only things that have a state.
But you could, for example, look for which entities are unavailable and then determine which devices or integrations they belong to.
Or if you want to detect integrations that have errors (like the ones that have a red box around them when you view all your integrations by navigating to settings → devices and services) you could monitor for specific log errors. To do this, you can configure HA to fire events when items are posted to the log, and you can trigger off those events. Here is a post about that.
If none of this is getting what you want, it would be helpful if you could explain a bit more about what you’re actually trying to accomplish.
{% set ns = namespace(restlist=[]) %}
{% for x in integration_entities('rest') %}
{% set y = (states.sensor |
selectattr('entity_id', 'eq', x)) | selectattr('state', 'eq', 'Green') | map(attribute='name') | list %}
{% set ns.restlist = ns.restlist + y %}
{% endfor %}
{{ ns.restlist }}
After some further research, filtering by state may not be the right way to do it after all. My rest integrations/sensors remain in the same status even though they cannot retrieve data.
That’s why I was looking for a way to detect the Rest sensors that don’t have custom attributes (i.e. attributes that I defined myself). but this seems difficult to me.
I donot understand this too well as you have no examples and I no reference. When my rest fails the state usually goes to unknown or unavailable…so maybe you should review how to setup your rest integrations?