Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement dynamic ignore_items + service calls #162

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

RoboMagus
Copy link
Contributor

This adds an additional ignore_items list that is dynamically populated by calling newly added services watchman.add_ignored_items and watchman.remove_ignored_items. This would enable users to build automations that change what entities should be ignored depending on various external conditions.

Potentially a solution for #100.

Not sure if this is the best approach to get dynamic filtering support implemented though, so feel free to brainstorm / suggest improvements!

Potential improvements:

  • Somehow represent the active ignore_items list so this info can be taken into account when populating the dynamic list.
  • Should the config be parsed again explicitly after these services are called?
    • Or provide as a service field for user to choose?

@Hiekkaharju
Copy link

I'm not sure if this is something that should be part of Watchman. I've this situation with my RV which occasionally obviously is away from home, and thus from HomeAssistant. For my entities that are in the RV, I use "python_script.set_state" to set their state as "away" when the RV is not at home. That excludes them from watchman reports when their unavailability is obvious. It also shows their state in dashboards clearly as something that is anticipated under such conditions.

@RoboMagus
Copy link
Contributor Author

For my entities that are in the RV, I use "python_script.set_state" to set their state as "away" when the RV is not at home

Externally changing an entities state could have nasty side effects that should ideally be avoided, and would require a user to alter the state for each of these entities. Looking at my setup there could be hundreds of entities offline at any given time which would make altering all those states unfeasible.

On the other hand, a single call to watchman.add_ignored_items using a list of wildcard patterns to match the required entities would do the trick.

@Hiekkaharju
Copy link

On the other hand, a single call to watchman.add_ignored_items using a list of wildcard patterns to match the required entities would do the trick.

Do you have a suggested solution to show their states on dashboards as something that is expected, under those condititions ?

@dummylabs
Copy link
Owner

dummylabs commented Nov 23, 2024

Hi @RoboMagus, thanks for the PR. I believe this task can be simplified with a service that just overwrites the content of the ignored_items list in the Watchman config entry. That way, you don't need to manage a separate list, and the user has one source of truth. And it seems to be more straightforward from the user's perspective. If someone decides to manage it through automation, they won't need a separate configuration option, and vice versa.

Please note that the format of ConfigEntry data has changed in version 0.6.4 to make the config_flow code easier to read and understand. In version 0.6.3, all comma-separated lists (e.g., included_folders, ignored_items, ignored_files, etc.) were stored as lists. Now, they are plain strings with comma-separated names, and all back-and-forth transformations for OptionsFlow code have been removed. Integration settings are now fetched directly from the ConfigEntry object all over the code without an intermediate dictionary in hass.data[DOMAIN_DATA].

I haven't merged these changes into the main branch yet, doing so will definitely cause conflicts with your PRs. I apologize for the inconvenience.

@dummylabs
Copy link
Owner

dummylabs commented Nov 23, 2024

The 0.6.4 is tested and ready to publish, but I'm struggling with hassfest validation flow bug which blocks this version from being published to HACS.

Upd: apparently, failed hassfest validation does not prevent release to publish to HACS, 0.4.6-beta.0 is out! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants