-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Add event platform to ntfy integration #143529
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
base: dev
Are you sure you want to change the base?
Conversation
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
ca779ea
to
b1a083c
Compare
acf92bb
to
98959a7
Compare
vol.Required(SECTION_FILTER): data_entry_flow.section( | ||
vol.Schema( | ||
{ | ||
vol.Optional(CONF_PRIORITY): SelectSelector( | ||
SelectSelectorConfig( | ||
multiple=True, | ||
options=["5", "4", "3", "2", "1"], | ||
mode=SelectSelectorMode.DROPDOWN, | ||
translation_key="priority", | ||
) | ||
), | ||
vol.Optional(CONF_TAGS): TextSelector( | ||
TextSelectorConfig( | ||
type=TextSelectorType.TEXT, | ||
multiple=True, | ||
), | ||
), | ||
vol.Optional(CONF_TITLE): str, | ||
vol.Optional(CONF_MESSAGE): str, | ||
} | ||
), | ||
{"collapsed": True}, | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when subscribing ntfy allows passing parameters to filter the messages that are received https://docs.ntfy.sh/subscribe/api/#list-of-all-parameters
self.ntfy = config_entry.runtime_data | ||
self.config_entry = config_entry | ||
self.subentry = subentry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we store everything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the config_entry is already used in the notify entity to initiate the reauth flow. In the event entity to create a backgroud task that is automatically cancelled when the config entry is unloaded. the subentry was added to have access to the per topic filter settings
self._ws = self.config_entry.async_create_background_task( | ||
hass=self.hass, | ||
target=self.ntfy.subscribe( | ||
topics=[self.topic], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how many websocket connections do you make in the end? Because this would leave us with 1 websocket per entity which I think is quite a lot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ntfy is limited to 30 open websocket connections anyway. Having individual websocket connections per topic allows using different filter settings when subscribing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but I mean, in the end, do we create 1 websocket or do we create 1 per entity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is 1 socket per entity yes
"filter_message": "Include messages with content that exactly matches the specified text" | ||
}, | ||
"name": "Message filters (optional)", | ||
"description": "Apply filters to narrow down the messages received when Home Assistant subscribes to the topic" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These filters are passed on to the websocket right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yepp
2211
A30F
5bf
to
0447001
Compare
Proposed change
Adds an event entity that subscribes to topics to receive notifications in Home Assistant.
When a topic is protected, it will fail to subscribe. Currently an error is logged but the entity will continue trying to subscribe to the topic. My idea was to raise a repair issue with a fix that deactivates the entity. I will add the repair in a follow-up PR.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: