Digital-Alchemy-TS / Digital-Alchemy-TS/synapse
Service registration
- Dominant language
- TypeScript
- Stars
- 3
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
## Context
It'd be awesome if synapse was able to expose service calls to home assistant, in addition to entities. This would enable more standard interactions via `hass.call`, instead of weird side workflows involving buttons
Some chatgpt proof of concept to visualize python side.
```python
from homeassistant.helpers import config_validation as cv
import voluptuous as vol
async def handle_service_call(call):
# Handle the service call here
service_data = call.data
# Example: service_data might include parameters passed to the service
async def async_setup(hass, config):
service_schema = vol.Schema({
vol.Required('field1'): cv.string,
vol.Optional('field2', default='default_value'): cv.string,
vol.Required('field3'): cv.positive_int,
})
service_description = {
"description": "Description of what this service does",
"fields": {
"field1": {
"description": "Description of field1",
"example": "example_value"
},
"field2": {
"description": "Description of field2",
"example": "example_value"
},
"field3": {
"description": "Description of field3",
"example": 42
}
}
}
# Register the service
hass.services.async_register(
domain='your_domain',
service='your_service',
service_func=handle_service_call,
schema=service_schema,
description=service_description
)
return True
```
---
Blocked by https://github.com/Digital-Alchemy-TS/hass/issues/34
Contributor guide
Assessment
This issue has not been assessed yet.