Skip to content

Service call context #27

@jmot205

Description

@jmot205

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

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions