Add action callbacks to simplepush#80744
Conversation
|
Hey there @engrbm87, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
MartinHjelmare
left a comment
There was a problem hiding this comment.
I don't think the way the callback is implemented in the stack is good. Polling for a response like that is not good.
| actions=actions, | ||
| attachments=attachments, | ||
| event=event, | ||
| feedback_callback=feedback_action_callback, |
There was a problem hiding this comment.
The callback will potentially make a request every second for one minute. That doesn't seem prudent.
n is never increased in the loop either.
There was a problem hiding this comment.
While it is certainly not prudent, I think it is a good enough first step considering that I will probably be the only user of this feature for a while anyway and an alternative solution would require a lot of work.
However, I would of course understand if Home Assistant doesn't want to subscribe to the move-fast-break-things philosophy as much as I have to.
Could there be a compromise for now where we set a fixed timeout?
There was a problem hiding this comment.
We're not some playground. We're real people spending real time maintaining Home Assistant and reviewing PRs. If you are making something that is only used by yourself and it's full of hacks… it doesn't belong in HA. I suggest to make it available as a custom component that people can install to HACS. There are 900 PRs open across Home Assistant, all intended for a bigger audience.
| title=title, | ||
| message=message, | ||
| event=event, | ||
| self.hass.async_create_task( |
There was a problem hiding this comment.
If we create a task the exceptions won't be caught here. We should await here.
There was a problem hiding this comment.
Hmm, this is a bit tricky.
If I don't create a task and use await instead, then a wait_for_trigger (see the example I provided in the description) will never be triggered.
And the possibility to use wait_for_trigger is crucial for this feature.
Do you have an idea on how to resolve this?
| except (ValueError, TypeError): | ||
| feedback_action_timeout = 60 | ||
|
|
||
| attachments_data = data.get(ATTR_ATTACHMENTS) |
There was a problem hiding this comment.
Please limit the PR to one thing. Don't both add callbacks and attachments.
There was a problem hiding this comment.
Okay, I removed attachments from this PR and create a separate PR for them.
Breaking change
Proposed change
This PR adds action callback functionality for the Simplepush component.
It also aims to use Home Assistant's shared aiohttp client session in order to improve performance.
I will update the documentation (https://www.home-assistant.io/integrations/simplepush/), after this PR gets merged. If preferred I can also do it beforehand.
The new functionality can be tested with the following automation:
Type of change
Additional information
simplepush#73471, Bump simplepush to 2.1.1 #80608Checklist
black --fast 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..coveragerc.To help with the load of incoming pull requests: