Versions in this module Expand all Collapse all v0 v0.3.0 Oct 11, 2026 Changes in this version + const BLEFlagAuth + const BLEFlagBuzzer + const BLEFlagDiscoverable + const BLEFlagPairing + const BLEFlagRPC + const BLEScanResultEvent + const Gen1ButtonOff + const Gen1ButtonOn + const Gen1LongPush + const Gen1OutputOff + const Gen1OutputOn + const Gen1RollerClose + const Gen1RollerOpen + const Gen1RollerStop + const Gen1SensorReport + const Gen1ShortPush + const ShellyCompanyID + func BLERelayScript(active bool) string + func BTHomeAddDevice(ctx context.Context, c Caller, cfg BTHomeDeviceConfig, id int) (string, int, error) + func BTHomeAddSensor(ctx context.Context, c Caller, cfg BTHomeSensorConfig, id int) (string, int, error) + func BTHomeDeleteDevice(ctx context.Context, c Caller, id int) error + func BTHomeDeleteSensor(ctx context.Context, c Caller, id int) error + func BTHomeResetEncryptionCounter(ctx context.Context, c Caller) error + func BTHomeStartDiscovery(ctx context.Context, c Caller, seconds int) error + func HookURL(base, device, event string, fields map[string]string, token string) string + func ScanResultData(adverts []BLEAdvert) json.RawMessage + type AlarmStatus struct + Alarm bool + Errors []string + ID int + Mute bool + type BLEAdvert struct + Addr string + Data []byte + RSSI int + func ParseBLEScanEvent(e Event) ([]BLEAdvert, bool, error) + func ParseBLEScanResult(data json.RawMessage) ([]BLEAdvert, error) + func (a BLEAdvert) BTHome(key []byte) (*bthome.Packet, error) + func (a BLEAdvert) Shelly() (BLEMfData, bool) + type BLEMfData struct + Flags int + MAC string + ModelID int + func ParseBLEMfData(d []byte) (BLEMfData, bool) + type BTHomeDeviceConfig struct + Addr string + ID int + Key string + Meta map[string]any + Name *string + type BTHomeDeviceEvent struct + Channel int + Component string + Event string + ID int + Idx int + Sensors map[string][]BTHomeSensorStatus + TS float64 + func ParseBTHomeDeviceEvent(e Event) (BTHomeDeviceEvent, bool) + type BTHomeDeviceStatus struct + Battery *float64 + Errors []string + FWVer string + ID int + Key *bool + LastUpdated float64 + PacketID *float64 + Paired *bool + RPC *bool + RSSI *float64 + type BTHomeDiscovered struct + Addr string + Encrypted bool + LocalName string + RSSI float64 + Shelly *BLEMfData + func ParseBTHomeDiscovered(e Event) (BTHomeDiscovered, bool) + type BTHomeKnownObject struct + Component *string + Idx int + ObjID int + func BTHomeKnownObjects(ctx context.Context, c Caller, id int) ([]BTHomeKnownObject, error) + type BTHomeObjectInfo struct + Name string + ObjID int + Type string + Unit string + func BTHomeObjectInfos(ctx context.Context, c Caller, ids []int) ([]BTHomeObjectInfo, error) + type BTHomeSensorConfig struct + Addr string + ID int + Idx int + Meta map[string]any + Name *string + ObjID int + type BTHomeSensorStatus struct + ID int + LastUpdated float64 + Value any + func (s BTHomeSensorStatus) Float() (float64, bool) type Config + func (c Config) BTHomeDevice(id int) (v BTHomeDeviceConfig, ok bool) + func (c Config) BTHomeSensor(id int) (v BTHomeSensorConfig, ok bool) + type Hook struct + Device string + Event string + Fields url.Values + Method string + Path string + Remote netip.Addr + Time time.Time + func (h Hook) Bool(name string) (bool, bool) + func (h Hook) Float(name string) (float64, bool) + type HookHandler struct + Allow func(netip.Addr) bool + Handle func(Hook) + MaxBody int64 + Prefix string + Token string + func (h *HookHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) + type IlluminanceStatus struct + Errors []string + ID int + Illumination string + Lux *float64 type Status + func (s Status) BTHomeDevice(id int) (v BTHomeDeviceStatus, ok bool) + func (s Status) BTHomeSensor(id int) (v BTHomeSensorStatus, ok bool) + func (s Status) Flood(id int) (v AlarmStatus, ok bool) + func (s Status) Illuminance(id int) (v IlluminanceStatus, ok bool) + func (s Status) Smoke(id int) (v AlarmStatus, ok bool) + func (s Status) Voltmeter(id int) (v VoltmeterStatus, ok bool) + type VoltmeterStatus struct + Errors []string + ID int + Voltage *float64 + XVoltage *float64 type Webhook + func HookWebhook(base, device, event string, cid int, fields map[string]string, token string) Webhook v0.2.0 Oct 11, 2026 Changes in this version + const DefaultScriptChunk + func AddVirtual(ctx context.Context, c Caller, typ string, config map[string]any, id int) (int, error) + func CoverToPosition(ctx context.Context, c Caller, id int, pos float64) error + func CreateSchedule(ctx context.Context, c Caller, j ScheduleJob) (id, rev int, err error) + func CreateScript(ctx context.Context, c Caller, name string) (int, error) + func CreateWebhook(ctx context.Context, c Caller, h Webhook) (id, rev int, err error) + func DeleteAllSchedules(ctx context.Context, c Caller) (rev int, err error) + func DeleteAllWebhooks(ctx context.Context, c Caller) (rev int, err error) + func DeleteSchedule(ctx context.Context, c Caller, id int) (rev int, err error) + func DeleteScript(ctx context.Context, c Caller, id int) error + func DeleteVirtual(ctx context.Context, c Caller, key string) error + func DeleteWebhook(ctx context.Context, c Caller, id int) (rev int, err error) + func EvalScript(ctx context.Context, c Caller, id int, code string) (string, error) + func Gen1ActionNames(actions map[string][]Gen1Action) []string + func Gen1SetAction(name string, index int, enabled bool, urls ...string) string + func Gen1Settings(section string, n int, values url.Values) string + func GetScriptCode(ctx context.Context, c Caller, id int) (string, error) + func IsRPCError(err error, code int) bool + func KVSDelete(ctx context.Context, c Caller, key, etag string) (rev int, err error) + func KVSList(ctx context.Context, c Caller, match string) (map[string]string, int, error) + func KVSSet(ctx context.Context, c Caller, key string, value any, etag string) (newEtag string, rev int, err error) + func MoveCover(ctx context.Context, c Caller, id int, move string, duration float64) error + func PutScriptCode(ctx context.Context, c Caller, id int, code string, chunk int) error + func SetConfig(ctx context.Context, c Caller, key string, config map[string]any) (restartRequired bool, err error) + func SetLight(ctx context.Context, c Caller, typ string, id int, s LightSet) error + func SetScriptConfig(ctx context.Context, c Caller, id int, name *string, enable *bool) error + func SetSwitch(ctx context.Context, c Caller, id int, on bool, toggleAfter float64) (wasOn bool, err error) + func SetVirtual(ctx context.Context, c Caller, key string, value any) error + func StartScript(ctx context.Context, c Caller, id int) (wasRunning bool, err error) + func StopScript(ctx context.Context, c Caller, id int) (wasRunning bool, err error) + func ToggleSwitch(ctx context.Context, c Caller, id int) (wasOn bool, err error) + func UpdateSchedule(ctx context.Context, c Caller, j ScheduleJob) (rev int, err error) + func UpdateWebhook(ctx context.Context, c Caller, h Webhook) (rev int, err error) + func WebhookEvents(ctx context.Context, c Caller) ([]string, error) + type BLEDevice struct + G GATT + Src string + func (d *BLEDevice) RPC(ctx context.Context, method string, params map[string]any) (json.RawMessage, error) + type Caller interface + RPC func(ctx context.Context, method string, params map[string]any) (json.RawMessage, error) + type CallerFunc func(ctx context.Context, method string, params map[string]any) (json.RawMessage, error) + func (f CallerFunc) RPC(ctx context.Context, method string, params map[string]any) (json.RawMessage, error) type Client + func (c *Client) Gen1Actions(ctx context.Context) (map[string][]Gen1Action, error) + func (c *Client) Settings1(ctx context.Context, section string, n int, values url.Values) (map[string]any, error) + type Component struct + Attrs json.RawMessage + Config json.RawMessage + Key string + Status json.RawMessage + func GetComponents(ctx context.Context, c Caller, dynamicOnly bool) ([]Component, int, error) + type Config map[string]json.RawMessage + func GetConfig(ctx context.Context, c Caller) (Config, error) + func ParseConfig(b []byte) (Config, error) + func (c Config) Cover(id int) (v CoverConfig, ok bool) + func (c Config) Decode(key string, v any) bool + func (c Config) Input(id int) (v InputConfig, ok bool) + func (c Config) Keys(typ string) []string + func (c Config) Light(typ string, id int) (v LightConfig, ok bool) + func (c Config) Name() string + func (c Config) Switch(id int) (v SwitchConfig, ok bool) + func (c Config) Sys() (v SysConfig, ok bool) + func (c Config) WiFi() (v WiFiConfigView, ok bool) + type CoverConfig struct + ID int + InMode string + InitialState string + InvertDirection bool + MaxtimeClose *float64 + MaxtimeOpen *float64 + Name *string + PowerLimit *float64 + SwapInputs bool + type CoverStatus struct + CurrentPos *float64 + Errors []string + ID int + LastDirection string + MoveStartedAt *float64 + MoveTimeout *float64 + PosControl bool + SlatPos *float64 + Source string + State string + TargetPos *float64 + func GetCover(ctx context.Context, c Caller, id int) (CoverStatus, error) + type DevicePowerStatus struct + Battery struct{ ... } + Errors []string + External ... + ID int + type EM1DataStatus struct + ID int + TotalActEnergy *float64 + TotalActRetEnergy *float64 + type EM1Status struct + Errors []string + ID int + type EMDataStatus struct + ATotalActEnergy *float64 + ATotalActRetEnergy *float64 + BTotalActEnergy *float64 + BTotalActRetEnergy *float64 + CTotalActEnergy *float64 + CTotalActRetEnergy *float64 + ID int + TotalAct *float64 + TotalActRet *float64 + type EMPhase struct + ActPower *float64 + AprtPower *float64 + Current *float64 + Freq *float64 + PF *float64 + Voltage *float64 + type EMStatus struct + A EMPhase + B EMPhase + C EMPhase + Errors []string + ID int + NCurrent *float64 + TotalActPower *float64 + TotalAprtPower *float64 + TotalCurrent *float64 + func (e *EMStatus) UnmarshalJSON(b []byte) error + type Energy struct + ByMinute []float64 + MinuteTS int64 + Total float64 + type Gen1Action struct + Enabled bool + Index int + URLs []Gen1ActionURL + func (a *Gen1Action) UnmarshalJSON(b []byte) error + type Gen1ActionURL struct + Int string + URL string + type HumidityStatus struct + Errors []string + ID int + RH *float64 type Info + func GetDeviceInfo(ctx context.Context, c Caller) (Info, error) + type InputConfig struct + Enable *bool + FactoryReset *bool + ID int + Invert bool + Name *string + Type string + type InputCounts struct + ByMinute []float64 + MinuteTS int64 + Total float64 + XTotal *float64 + type InputStatus struct + Counts *InputCounts + Errors []string + Freq *float64 + ID int + Percent *float64 + State *bool + type KVSItem struct + Etag string + Key string + Value json.RawMessage + func KVSGet(ctx context.Context, c Caller, key string) (KVSItem, error) + func KVSGetMany(ctx context.Context, c Caller, match string) ([]KVSItem, error) + type LightConfig struct + AutoOff bool + AutoOffDelay float64 + AutoOn bool + AutoOnDelay float64 + Default ... + ID int + InMode string + InitialState string + Name *string + NightMode ... + TransitionDur *float64 + type LightSet struct + Brightness *float64 + CT *float64 + On *bool + RGB []int + ToggleAft *float64 + Transition *float64 + White *float64 + type LightStatus struct + Brightness *float64 + CT *float64 + Errors []string + ID int + Output bool + RGB []int + Source string + TimerDuration *float64 + TimerStartedAt *float64 + White *float64 + type MQTTDevice struct + M *MQTT + Root string + func (d MQTTDevice) RPC(ctx context.Context, method string, params map[string]any) (json.RawMessage, error) + type Meter struct + AEnergy *Energy + APower *float64 + Current *float64 + Freq *float64 + PF *float64 + RetAEnergy *Energy + Temp *Temperature + Voltage *float64 + type PM1Status struct + Errors []string + ID int + type ScheduleCall struct + Method string + Params map[string]any + type ScheduleJob struct + Calls []ScheduleCall + Enable bool + ID int + Timespec string + func ListSchedules(ctx context.Context, c Caller) ([]ScheduleJob, int, error) + type Script struct + Enable bool + ID int + Name string + Running bool + func ListScripts(ctx context.Context, c Caller) ([]Script, error) + type ScriptStatus struct + Errors []string + ID int + MemFree int + MemPeak int + MemUsed int + Running bool + func GetScriptStatus(ctx context.Context, c Caller, id int) (ScriptStatus, error) + type Status map[string]json.RawMessage + func GetStatus(ctx context.Context, c Caller) (Status, error) + func ParseStatus(b []byte) (Status, error) + func (s Status) Cover(id int) (v CoverStatus, ok bool) + func (s Status) Decode(key string, v any) bool + func (s Status) DevicePower(id int) (v DevicePowerStatus, ok bool) + func (s Status) EM(id int) (v EMStatus, ok bool) + func (s Status) EM1(id int) (v EM1Status, ok bool) + func (s Status) EM1Data(id int) (v EM1DataStatus, ok bool) + func (s Status) EMData(id int) (v EMDataStatus, ok bool) + func (s Status) Humidity(id int) (v HumidityStatus, ok bool) + func (s Status) Input(id int) (v InputStatus, ok bool) + func (s Status) Keys(typ string) []string + func (s Status) Light(typ string, id int) (v LightStatus, ok bool) + func (s Status) PM1(id int) (v PM1Status, ok bool) + func (s Status) Switch(id int) (v SwitchStatus, ok bool) + func (s Status) Sys() (v SysStatus, ok bool) + func (s Status) Temperature(id int) (v TemperatureStatus, ok bool) + func (s Status) WiFi() (v WiFiStatus, ok bool) + type SwitchConfig struct + AutoOff bool + AutoOffDelay float64 + AutoOn bool + AutoOnDelay float64 + AutorecoverVolts *bool + CurrentLimit *float64 + ID int + InMode string + InitialState string + Name *string + PowerLimit *float64 + VoltageLimit *float64 + type SwitchStatus struct + Errors []string + ID int + Output bool + Source string + TimerDuration *float64 + TimerStartedAt *float64 + func GetSwitch(ctx context.Context, c Caller, id int) (SwitchStatus, error) + type SysConfig struct + CfgRev int + Device struct{ ... } + Location struct{ ... } + type SysStatus struct + AvailableUpdates map[string]struct{ ... } + CfgRev int + FSFree int + FSSize int + KVSRev int + MAC string + RAMFree int + RAMSize int + ResetReason int + RestartRequired bool + ScheduleRev int + Time string + UnixTime int64 + Uptime float64 + WakeupPeriod int + WebhookRev int + type Temperature struct + C *float64 + F *float64 + type TemperatureStatus struct + C *float64 + Errors []string + F *float64 + ID int + type Webhook struct + ActiveBetween []string + CID int + Condition string + Enable bool + Event string + ID int + Name string + RepeatPeriod int + SSLCA string + URLs []string + func ListWebhooks(ctx context.Context, c Caller) ([]Webhook, int, error) + type WiFiConfigView struct + AP struct{ ... } + STA struct{ ... } + STA1 struct{ ... } + type WiFiStatus struct + APClientCount *int + RSSI *float64 + SSID *string + StaIP *string + Status string v0.1.0 Oct 11, 2026 Changes in this version + const BLEData + const BLENamePrefix + const BLERxControl + const BLEService + const BLETxControl + const CoIoTGroup + const CoIoTPort + const DefaultAPAddress + const DefaultMQTTPrefix + const User + var ErrAuth = errors.New("the device refused the password") + func BLERPC(ctx context.Context, g GATT, src string, id int, method string, ...) (json.RawMessage, error) + func BaseURL(addr string) (string, error) + func DigestResponse(user, realm, password, method, uri, nonce, nc, cnonce string) string + func EncodeCoIoT(devType, devID string, serial int, payload []byte) []byte + func Gen1Colour(n int, r, g, b uint8, gain *float64) string + func Gen1Event(e string) string + func Gen1Level(n int, level float64, colourMode bool, transition *float64) string + func Gen1MQTT(pathQuery string) (string, string, error) + func Gen1Roller(n int, move string) string + func Gen1RollerPos(n int, pos float64) string + func Gen1Turn(kind string, n int, turn string) string + func MACOfID(id string) string + func MethodPrefix(typ string) string + func SHA256Hex(s string) string + func ServeInbound(ctx context.Context, ln net.Listener, path string, in *Inbound) error + func SplitKey(k string) (typ string, id int, ok bool) + func WSAuth(challengeJSON, password string) (map[string]any, error) + func WSURL(base string) string + func WatchWS(ctx context.Context, base string, o WSOptions) error + func WiFiConfig(ssid, password string) map[string]any + type Announce struct + ID string + IP string + MAC string + Model string + type BLEDialer func(ctx context.Context, adapter, target string) (g GATT, name string, closeFn func(), err error) + type CitBlock struct + D string + I int + type CitDesc struct + Blk []CitBlock + Sen []CitSensor + func (c CitDesc) BlockIndex(s CitSensor) (n int, ok bool) + func (c CitDesc) Decode(payload []byte) []CitValue + type CitSensor struct + Blocks []int + D string + I int + L int + T string + U string + func (s *CitSensor) UnmarshalJSON(b []byte) error + type CitValue struct + HasIndex bool + Index int + Sensor CitSensor + Value any + type Client struct + Base string + HTTP *http.Client + Password string + Username string + func (c *Client) CitDescription(ctx context.Context) (CitDesc, error) + func (c *Client) Get(ctx context.Context, pathQuery string) ([]byte, error) + func (c *Client) Get1(ctx context.Context, pathQuery string) (map[string]any, error) + func (c *Client) OutboundWS(ctx context.Context) (OutboundWS, error) + func (c *Client) RPC(ctx context.Context, method string, params map[string]any) (json.RawMessage, error) + func (c *Client) Reboot(ctx context.Context) error + func (c *Client) SetOutboundWS(ctx context.Context, server string) (restart bool, err error) + func (c *Client) SetWiFi(ctx context.Context, gen int, ssid, password string) error + func (c *Client) Shelly(ctx context.Context) (Info, error) + func (c *Client) Update(ctx context.Context, gen int, imageURL string) error + func (c *Client) WaitVersion(ctx context.Context, before, want string, every time.Duration) (Info, error) + type CoIoTListener struct + func ListenCoIoT(addr *net.UDPAddr, group string) (*CoIoTListener, error) + func (l *CoIoTListener) Addr() string + func (l *CoIoTListener) Close() error + func (l *CoIoTListener) Serve(ctx context.Context, fn func(m CoIoTMessage, from *net.UDPAddr)) error + type CoIoTMessage struct + Code byte + DevID string + DevType string + Path string + Payload []byte + Serial int + Version string + func ParseCoAP(b []byte) (CoIoTMessage, error) + type Event struct + Component string + Fields map[string]any + Name string + TS float64 + func Events(params map[string]any) []Event + type Frame struct + Method string + Params json.RawMessage + Src string + type GATT interface + Read func(ctx context.Context, char string) ([]byte, error) + Write func(ctx context.Context, char string, b []byte) error + type Gen1Report struct + Event string + EventCnt float64 + Index int + IsNum bool + Kind Gen1TopicKind + Light map[string]any + Name string + Num float64 + On bool + Online bool + Text string + func ParseGen1Report(rest []string, payload string) Gen1Report + type Gen1TopicKind int + const TopicInputEvent + const TopicLight + const TopicLightStatus + const TopicOnline + const TopicOther + const TopicRelay + const TopicRelayEnergy + const TopicRelayPower + const TopicRoller + const TopicRollerPos + const TopicSensor + type Inbound struct + Closed func(ch *InboundChannel) + Frame func(ctx context.Context, ch *InboundChannel, f Frame) + func (in *Inbound) ServeHTTP(w http.ResponseWriter, r *http.Request) + type InboundChannel struct + RemoteIP string + Value any + type Info struct + App string + Auth bool + AuthEn bool + FW string + Gen int + ID string + MAC string + Model string + Name string + Type string + Ver string + func (i Info) DefaultID() string + func (i Info) Firmware() string + func (i Info) Generation() int + func (i Info) ModelName() string + type MQTT struct + Prefix string + Pub Publisher + Src string + Timeout time.Duration + func (m *MQTT) Command1(ctx context.Context, root, pathQuery string) error + func (m *MQTT) Filters() []string + func (m *MQTT) Handle(topic string, payload []byte) MQTTMessage + func (m *MQTT) RPC(ctx context.Context, root, method string, params map[string]any) (json.RawMessage, error) + type MQTTKind int + const MQTTAnnounce + const MQTTGen1 + const MQTTNone + const MQTTNotification + type MQTTMessage struct + Announce Announce + Device string + Kind MQTTKind + Method string + Params json.RawMessage + Report Gen1Report + Root string + Src string + Topic []string + type OutboundWS struct + Enable bool + Server string + type Publisher interface + Publish func(ctx context.Context, topic string, payload []byte, retain bool) error + type RPCError struct + Code int + Message string + func (e *RPCError) Error() string + type WSOptions struct + Notify func(method string, params json.RawMessage) error + Password string + Ping time.Duration + Src string + Status func(status map[string]any) error + Timeout time.Duration