Would like to present a custom integration to identify entities and services in your configuration files that either no longer exist or have a wrong state. Along with a few sensors, it may create a text version of the report or send it via notification service of choice.
Please don’t be afraid of the documentation volume, I’ve tried to keep the balance between versatility and simplicity of use during development, so all parameters are optional: https://github.com/dummylabs/thewatchman
Unfortunately, this seems to be impossible while watchman is using regular expressions to detect character sequences which looks like an entity or a service. To be able to safely remove an entry from a yaml file the integration should be able to analyze and interpret quite complex data structures as well as custom yaml tags like !include, !secret, and so on. This seems to be feasible, but makes parsing a much more difficult task.
I tried it by running just the “watchman.report” service with no service data:
and I’m getting the following result.
If I don’t specify a default notification service in the configuration.yaml I get an error:
and the report is never saved to the default text path.
If I do configure a default notification service in configuration.yaml the notification gets sent correctly and everything is listed there properly along with the correctly generated text file.
The issue is that I only want to create the text file and not get a notification when I use it.
Explanation: If send_notification service parameter wasn’t explicitly set to false, it is true by default, this why watchman complains about missing service parameter. I was thinking about default values for send_notification and create_file parameters, probably it is worth to have them false by default and require user to always specify either or both of them.
I found a few misconfigured automations, a misnamed input_number, a whole bunch of old customizations that were no longer needed and some unnecessary logbook, history and recorder excludes.
Hey @scr,
this is the first time I hear about your integration… and I was searching for this function quite a few times.
Did you consider registering with HACS so your repo is automatically included in listings and therefore can be found via the search function? That would be most amazing.
Also, UI configuration and an entity holding all warnings as attribute would be great - no rush hahaha
-== WATCHMAN REPORT ==-
-== Missing 1 service(-s) from 50 found in your config:
+--------------------------------+-------------+--------------------------------------------------------------+
| Service ID | State | Location |
+--------------------------------+-------------+--------------------------------------------------------------+
| switch.turn_ | missing | automations.yaml:29 |
+--------------------------------+-------------+--------------------------------------------------------------+
-== Missing 66 entity(-es) from 575 found in your config:
+--------------------------------+-------------+--------------------------------------------------------------+
| Entity ID | State | Location |
+--------------------------------+-------------+--------------------------------------------------------------+
| switch.pc_hibernate | unavail | automations.yaml:199,807 |
| switch.laptop_shutdown | unavail | automations.yaml:798 |
| switch.pc_lock | unavail | automations.yaml:815 |
The first service listed (there were a lot more but thanks to you, not any more ) relates to a template switch turn on, is there any way to exclude template entries like this and or exclude this particular line from the yaml file I wonder?
Also under missing entities, I have a big long list of entities that are unavailable, mostly as they relate to MQTT sensors that spend most of their lives in this state, so as you can see I have tried to exclude “unavailable” in the config above, but they still show?
In trying to work this out I also set column widths to show state column as 11 (based on the longest state being “unavailable” at 11 characters) but it still shows “unavail” and not “unavailable”. I also tried putting exclude unavail in the config but obviously the yaml checker spits this out.
Am i doing something wrong can you see?
Thanks again, this is such a wonderful cleansing exercise.
Sure, PR was created a few days ago and waiting for approval.
Both features are in the backlog. The only problem with UI configuration - so far it has no support for nested data structures like notification service data, that is, part of configuration will remain in yaml.
Current version of integration supports both use cases. You can set up everything in the configuration.yaml and use watchman.report service with no additional parameters. Or, you can specify extra parameters in service data which will take precedence over yaml.
The case makes sense for me and I have it in the backlog. Having only a set of bare entities/attributes will require user to figure out how to make a Lovelace card out of it instead of just get what they want. So there is a text version of the report to make leaning curve less steeper. I believe there should be a possibility to make a Lovelace card, but this shouldn’t be the only way to get information out of watchman.