feat: initial zigbee control implementation
Some checks failed
Build and Publish Docker Image / build-and-push (push) Failing after 27s

Co-authored-by: Ona <no-reply@ona.com>
This commit is contained in:
2025-10-28 01:11:57 +00:00
parent 2e63609129
commit b55d99dd9e
30 changed files with 901 additions and 70 deletions

49
packages/jrpc/index.ts Normal file
View File

@@ -0,0 +1,49 @@
import type { ZigbeeDeviceName, ZigbeeDeviceStates } from "@eva/zigbee"
export type JrpcSchema = {
subscribeToDevice: {
Params: {
deviceName: ZigbeeDeviceName
}
Response: true
}
setDeviceState: {
Params: {
deviceName: ZigbeeDeviceName
state: unknown
}
Response: true
}
showDeviceState: {
Params: {
[key in ZigbeeDeviceName]: {
deviceName: key
state: ZigbeeDeviceStates[key]
}
}[ZigbeeDeviceName]
Response: true
}
}
export type JrpcRequest<Method extends keyof JrpcSchema = keyof JrpcSchema> = {
[M in keyof JrpcSchema]: {
id: string
jsonrpc: "2.0"
method: M
params: JrpcSchema[M]["Params"]
}
}[Method]
export type JrpcResponse<Method extends keyof JrpcSchema = keyof JrpcSchema> = {
[M in keyof JrpcSchema]:
| {
id: string
jsonrpc: "2.0"
result: JrpcSchema[M]["Response"]
}
| {
id: string
jsonrpc: "2.0"
error: string
}
}[Method]