dummylabs / thewatchman

Home Assistant custom integration to keep track of missing entities and actions in your config files
MIT License
475 stars 20 forks source link

Feature Request: ignore disabled entities #120

Open TarheelGrad1998 opened 7 months ago

TarheelGrad1998 commented 7 months ago

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.

igorsantos07 commented 6 months ago

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 commented 6 months ago

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

TarheelGrad1998 commented 6 months ago

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.

RoboMagus commented 23 hours ago

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.

TarheelGrad1998 commented 20 hours ago

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.