finity69x2 / nws_alerts

An updated version of the nws_alerts custom integration for Home Assistant
84 stars 29 forks source link

Add a service that will reply a list of active alerts #74

Closed SirIndubitable closed 3 weeks ago

SirIndubitable commented 4 months ago

I found the concatenated strings in the entity attributes a little cumbersome to write automatons for. And I saw the recommendation in Issue 66 to take advantage of the new service response feature.

This adds the new service nws_alerts.list which can be called on any entry provided by this integration.

ps. When starting on this change, my pylint/flake8/mypy had a lot of warnings that I cleaned up first. I'll gladly remove those from this PR if they are making the change harder to follow.

I also noticed some of the typehints were wrong, so I updated those as well.

SirIndubitable commented 3 months ago

Hey @finity69x2 any chance you can take a look at this?

leoherzog commented 1 month ago

This sounds super cool. How does this present in the UI?

SirIndubitable commented 1 month ago

It would just be an additional service call you can make in scripts/automations/templates. This would be similar to calendar.get_events or weather.get_forecasts https://www.home-assistant.io/blog/2023/07/05/release-20237/#services-can-now-respond

finity69x2 commented 3 weeks ago

Sorry it's taken so long to get to this. real life gets in the way.

But to your point of the PR...

I've just released an update to the integration that reorganizes the alert attributes. It doesn't add the list service that the PR requests but it does fix the way the attributes are structured to make writing automations etc with them more straightforward.

Hopefully the new changes make this PR unnecessary. Let me know what you think.

But thanks for contributing even if it ultimately doesn't get implemented.

SirIndubitable commented 3 weeks ago

No worries, I definitely know how real life can get in the way :) I like the rewrite, and I think that's a better way to do it if we don't mind a breaking change. I'll drop this PR, because I don't think the service is necessary anymore.