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

Service call context #27

Closed
jmot205 opened this issue Feb 13, 2024 · 2 comments
Closed

Service call context #27

jmot205 opened this issue Feb 13, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@jmot205
Copy link

jmot205 commented Feb 13, 2024

Is it possible for the context of a service call to be wired in so that when PythonScriptsPro calls a service and changes the state of a device it shows in the device's attribute's logbook?
e.g. Calling a light to turn on via PSP results in the logbook entry:

Turned on triggered by service light: Turn on

Whereas adding context e.g. like the following would help for debugging and knowing why states have changed when triggered by a PSP script:

Turned on triggered by PythonScriptsPro script: turn_on_lights.py

Alternatively, if there was a way to know what HA script or automation called the PSP script then the logbook context could state this, and would be similar to how it shows when HA native scripts or automations change a device's state:

Turned on triggered by automation My Automation triggered by state of My Device Attribute

Another thought is maybe even optionally surfacing a context kwarg in the service call to allow this context description to be customised by passing a string in?

On the face of it, it sounds like a similar thing that was run into for the pyscript integration:

custom-components/pyscript#50

custom-components/pyscript@d0745ea#diff-35f81a73bbe8c0273529be5bdce6d1fed5f3efd7e1d14877b0c88dabe41f0f26R175-R180

@AlexxIT AlexxIT added the enhancement New feature or request label Feb 16, 2024
@AlexxIT AlexxIT self-assigned this Feb 16, 2024
@jmot205
Copy link
Author

jmot205 commented Mar 7, 2024

After some thought and after switching over a whole bunch of my automations that set the states of various lights from the built-in light service calls to a PSP script, I think that, if possible to implement, the above option of mimicking the HA default logbook entry might provide the most clarity in terms of knowing why the state of an object has changed:

Turned on triggered by automation My Automation triggered by state of My Device Attribute

@AlexxIT AlexxIT added this to the v1.0.3 milestone Dec 7, 2024
AlexxIT added a commit that referenced this issue Dec 7, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented Dec 7, 2024

@AlexxIT AlexxIT closed this as completed Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants