thewatchman icon indicating copy to clipboard operation
thewatchman copied to clipboard

Feature Request: ignore disabled entities

Open TarheelGrad1998 opened this issue 1 year ago • 3 comments

I may have missed it, but I don't see any way to ignore manually disabled entities? It would be a good feature.

Use case: I have a switch used for a humidifier that we use in the winter. Otherwise, we unplug the switch. I disable the device when not in use, and I've written my automations to handle this, but Watchman still picks it up. As is, I have to remember to add it to exclusions and then remove it in the winter.

TarheelGrad1998 avatar Mar 31 '24 15:03 TarheelGrad1998

I think that, given the simplicity of how this integration works, this wouldn't be possible - or at least would add a some complexity layers, needing to actually check for disabled stuff. It just parses YAML files and does text-matching with the entities it finds mentioned.

That all said, I would second this request; not only for the entities, but for places where they're mentioned (which would be even more complex?). For instance, I don't want reports about missing entities when they're only used in disabled automations.

igorsantos07 avatar May 06 '24 01:05 igorsantos07

Actually, digging around the code, it looks like this isn't that hard - given it already checks for entity states, it would be trivial to check if the entity is enabled or not, I guess.

Here is where the entity state is decided as ignored or not, and that state is defined by this simplified function, which could also return disabled, so we could ignore disabled entity "states".

I got curious on this feature and implementation seems simple, but I never touched any HACS code, so I have no clue how to test out a fork of it :(

Edit: doesn't seem that hard, although that will still take some time I won't have for now

igorsantos07 avatar May 06 '24 01:05 igorsantos07

HACS integrations live under the custom_components folder under your HA instance. Alternately, you can fork and just point your HACS to your local fork and install it that way.

But you're right on top of it. I don't have a lot of time either, and have never done a pull request, but if I free up I'll try myself and post any results. As you say, it doesn't look hard.

TarheelGrad1998 avatar May 06 '24 16:05 TarheelGrad1998

From what I can tell any entities that are disabled will not have a state at all, and thus show up as missing to The Watchman. Ignoring the missing state should then already accomplish what you're looking for.

This does however not provide a distinction between manually disabled entities and entities that would otherwise report as missing. But seeing as it's not possible to get additional information from an entity that does not exist I recon that would never be an option anyways.

RoboMagus avatar Nov 21 '24 10:11 RoboMagus

That's what I was afraid of. I'd definitely need to know the difference between missing (because I disabled it) and missing (because I renamed it but forgot to update an automation). Oh well, thanks for checking.

TarheelGrad1998 avatar Nov 21 '24 13:11 TarheelGrad1998

Turns out querying the HA entity_registry is quite easy to implement. I've opened up a PR that implements the option to ignore entities depending on what disabled them: #161

RoboMagus avatar Nov 22 '24 15:11 RoboMagus

Thanks, @RoboMagus. I will check the PR and try to integrate it into WM. I've recently merged 0.6.4-dev into the main branch, which led to conflicts in your PR. Could I ask you to handle these conflicts? I've changed the branching strategy to update the main branch more frequently to minimize such conflicts where possible.

To the issue: my plan was to introduce an extra state for monitored entities in the report: disabled, and to extend the list of ignored_states in the settings accordingly.

dummylabs avatar Nov 25 '24 09:11 dummylabs