Documentation
¶
Overview ¶
Package zwavejs is a standalone client for zwave-js-server's WebSocket JSON protocol (github.com/zwave-js/zwave-js-server) — the Node.js bridge most self-hosted Z-Wave setups already run. It has no dependency on any particular application; it's meant to be usable on its own, the same separation pyatv draws between "speak the device's protocol" and "whatever app is using it."
Index ¶
- type Client
- func (c *Client) Close() error
- func (c *Client) Events() <-chan ValueUpdatedEvent
- func (c *Client) MulticastSetValue(ctx context.Context, nodeIDs []int, valueID ValueID, value any) error
- func (c *Client) SetValue(ctx context.Context, nodeID int, valueID ValueID, value any) error
- func (c *Client) StartListening(ctx context.Context) ([]Node, error)
- type Node
- type Value
- type ValueID
- type ValueMetadata
- type ValueUpdatedEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a connected zwave-js-server session.
func Dial ¶
Dial connects to a zwave-js-server instance at addr ("host:port"), completes the version handshake, and starts the background read loop. It does not yet call StartListening — the caller does that once it's ready to receive the initial node dump and live events.
func (*Client) Events ¶
func (c *Client) Events() <-chan ValueUpdatedEvent
Events returns the channel of "value updated" events. Other event types (node added/removed, controller/driver events, ...) are not modeled and are silently dropped.
func (*Client) MulticastSetValue ¶
func (c *Client) MulticastSetValue(ctx context.Context, nodeIDs []int, valueID ValueID, value any) error
MulticastSetValue sets the same value on the same ValueID across multiple nodes in a single command (multicast_group.set_value) — one real Z-Wave multicast frame instead of len(nodeIDs) sequential unicasts. All targeted nodes must support the same value (e.g. every node in a "living room switches" group having a Binary Switch currentValue); a node that doesn't have a matching ValueID will just fail to apply it.
type Node ¶
type Node struct {
NodeID int `json:"nodeId"`
Status int `json:"status"`
Ready bool `json:"ready"`
Name string `json:"name,omitempty"`
Label string `json:"label,omitempty"`
// ManufacturerID/ProductID/ProductType identify the device model —
// same triple Home Assistant's zwave_js integration keys its own
// per-device quirks on, for devices whose reported generic/specific
// Z-Wave device class doesn't disambiguate what a value actually
// controls (e.g. the Inovelli LZW36's fan endpoint, which reports
// generic "Multilevel Switch" / specific "Not Used" instead of the
// standard "Fan Switch" specific device class).
ManufacturerID int `json:"manufacturerId"`
ProductID int `json:"productId"`
ProductType int `json:"productType"`
Values []Value `json:"values"`
}
Node is one Z-Wave device as reported by start_listening's initial state dump. This only carries the fields this package actually uses — zwave-js-server's real node object has many more.
type Value ¶
type Value struct {
ValueID
PropertyName string `json:"propertyName,omitempty"`
PropertyKeyName string `json:"propertyKeyName,omitempty"`
Metadata ValueMetadata `json:"metadata"`
Value any `json:"value"`
}
Value is one entry in a Node's Values — a ValueID plus its current value and metadata, as returned in the initial state dump.
type ValueID ¶
type ValueID struct {
CommandClass int `json:"commandClass"`
Endpoint int `json:"endpoint,omitempty"`
Property any `json:"property"`
PropertyKey any `json:"propertyKey,omitempty"`
}
ValueID identifies a single value on a node — commandClass + property (+ endpoint/propertyKey for multi-channel or sub-indexed values). Property and PropertyKey are `any` because zwave-js-server's protocol uses either a string or a number for them depending on the command class (e.g. "targetValue" vs. a numeric configuration parameter index).
type ValueMetadata ¶
type ValueMetadata struct {
Type string `json:"type"` // "boolean", "number", "string", ...
Readable bool `json:"readable"`
Writeable bool `json:"writeable"`
Label string `json:"label"`
Unit string `json:"unit,omitempty"`
}
ValueMetadata describes a value's type and capabilities, as reported in a node's initial value dump.
type ValueUpdatedEvent ¶
ValueUpdatedEvent is a "value updated" event, the one this package actually acts on to keep entity state in sync — other event types (node added/removed, controller/driver events, ...) are ignored for now rather than modeled speculatively.