Documentation
¶
Index ¶
- Constants
- func ConfigureDeviceSettings(ctx context.Context, log logr.Logger, device *Device, name string, ...) error
- func Foreach(ctx context.Context, log logr.Logger, deviceList []devices.Device, ...) (any, error)
- func Init(log logr.Logger, mc mqtt.Client, timeout time.Duration, ...)
- func IsBluDevice(deviceId string) bool
- func IsGen1Device(deviceId string) bool
- func NewDeviceFromIp(ctx context.Context, log logr.Logger, ip net.IP) (devices.Device, error)
- func NewDeviceFromMqttId(ctx context.Context, log logr.Logger, id string) (devices.Device, error)
- func NewDeviceFromSummary(ctx context.Context, log logr.Logger, summary devices.Device) (devices.Device, error)
- func NewDeviceFromZeroConfEntry(ctx context.Context, log logr.Logger, resolver devices.Resolver, ...) (devices.Device, error)
- func Print(log logr.Logger, d any) error
- type Device
- func (d *Device) CallE(ctx context.Context, via types.Channel, method string, params any) (any, error)
- func (d *Device) Channel(via types.Channel) types.Channel
- func (d *Device) ClearHost()
- func (d *Device) Config() *shelly.Config
- func (d *Device) ConfigRevision() uint32
- func (d *Device) From() <-chan []byte
- func (d *Device) Host() string
- func (d *Device) Id() string
- func (d *Device) Info() *shelly.DeviceInfo
- func (d *Device) Init(ctx context.Context) error
- func (d *Device) Ip() net.IP
- func (d *Device) IsHttpReady() bool
- func (d *Device) IsModified() bool
- func (d *Device) IsMqttReady() bool
- func (d *Device) Mac() net.HardwareAddr
- func (d *Device) Manufacturer() string
- func (d *Device) MethodHandlerE(v any) (types.MethodHandler, error)
- func (d *Device) Name() string
- func (d *Device) Refresh(ctx context.Context, via types.Channel) (bool, error)
- func (d *Device) ReplyTo() string
- func (d *Device) ResetModified()
- func (d *Device) StartDialog(ctx context.Context) uint32
- func (d *Device) Status() *shelly.Status
- func (d *Device) StopDialog(ctx context.Context, id uint32)
- func (d *Device) String() string
- func (d *Device) To() chan<- []byte
- func (d *Device) UpdateHost(host string)
- func (d *Device) UpdateId(id string)
- func (d *Device) UpdateMac(mac string)
- func (d *Device) UpdateName(name string)
- type DeviceMqttChannels
- type DeviceResult
- type Do
- type InitExtra
- type Registrar
- func (r *Registrar) CallE(ctx context.Context, d types.Device, via types.Channel, mh types.MethodHandler, ...) (any, error)
- func (r *Registrar) Init(log logr.Logger)
- func (r *Registrar) MethodHandlerE(m string) (types.MethodHandler, error)
- func (r *Registrar) RegisterDeviceCaller(ch types.Channel, dc types.DeviceCaller)
- func (r *Registrar) RegisterMethodHandler(verb string, mh types.MethodHandler)
- type ShellyDevice
- func (d ShellyDevice) Host() string
- func (d ShellyDevice) Id() string
- func (d ShellyDevice) Ip() net.IP
- func (d ShellyDevice) Mac() net.HardwareAddr
- func (d ShellyDevice) Manufacturer() string
- func (d ShellyDevice) MarshalJSON() ([]byte, error)
- func (d ShellyDevice) Name() string
- func (d ShellyDevice) Online() bool
- func (d ShellyDevice) Provider() string
Constants ¶
const MDNS_SHELLIES string = "_shelly._tcp."
Variables ¶
This section is empty.
Functions ¶
func ConfigureDeviceSettings ¶
func ConfigureDeviceSettings(ctx context.Context, log logr.Logger, device *Device, name string, ecoMode *bool) error
ConfigureDeviceSettings updates Shelly device configuration on the device itself (Gen2+ only). This function should only be called for Gen2+ devices. It updates the device name and/or eco mode on the device.
func Init ¶
func Init(log logr.Logger, mc mqtt.Client, timeout time.Duration, rateLimitInterval time.Duration, extras ...InitExtra)
Init wires up the registrar, rate limiter, and the always-present method handlers. Optional extras (e.g. script.Init) are invoked at the end so a caller can opt into the heavier sub-packages.
func IsBluDevice ¶
func IsGen1Device ¶
IsGen1Device returns true if the device ID indicates a Gen1 device Gen1 devices are identified by their ID prefix (e.g., "shellyht-", "shellyflood-")
func NewDeviceFromIp ¶
func NewDeviceFromMqttId ¶
func NewDeviceFromSummary ¶
Types ¶
type Device ¶
type Device struct {
Id_ string `json:"id"`
MacAddress_ net.HardwareAddr `json:"-"`
Name_ string `json:"name"`
Host_ net.IP `json:"host"`
// contains filtered or unexported fields
}
func (*Device) ConfigRevision ¶
func (*Device) Info ¶
func (d *Device) Info() *shelly.DeviceInfo
func (*Device) Init ¶
Init initializes the device, setting up HTTP and MQTT channels as needed. This is the exported version of init() for use by external packages.
func (*Device) IsHttpReady ¶
func (*Device) IsModified ¶
func (*Device) IsMqttReady ¶
func (*Device) Mac ¶
func (d *Device) Mac() net.HardwareAddr
func (*Device) Manufacturer ¶
func (*Device) MethodHandlerE ¶
func (d *Device) MethodHandlerE(v any) (types.MethodHandler, error)
func (*Device) ResetModified ¶
func (d *Device) ResetModified()
func (*Device) UpdateHost ¶
func (*Device) UpdateName ¶
type DeviceMqttChannels ¶
type DeviceMqttChannels struct {
ReplyTo string
To chan<- []byte
From <-chan []byte
// contains filtered or unexported fields
}
DeviceMqttChannels holds MQTT channels for each device ID to prevent goroutine leaks. When Device structs are recreated (e.g., loaded from database), they reuse existing channels instead of creating new subscriptions/publishers that would leak goroutines.
func (*DeviceMqttChannels) Init ¶
func (m *DeviceMqttChannels) Init(ctx context.Context, deviceId string) (*DeviceMqttChannels, error)
Init initializes MQTT channels for a device. Returns an existing instance from the registry if available, or creates new channels and registers them.
func (*DeviceMqttChannels) IsReady ¶
func (m *DeviceMqttChannels) IsReady() bool
func (*DeviceMqttChannels) Lock ¶
func (m *DeviceMqttChannels) Lock()
Lock acquires the mutex to serialize MQTT request-response cycles
type DeviceResult ¶
DeviceResult represents the result of an operation on a single device
type InitExtra ¶
type InitExtra func(log logr.Logger, r types.MethodsRegistrar)
InitExtra registers extra method handlers against the package-level registrar — used to plug optional sub-packages (script, gen1, ...) without pulling them in unconditionally.
type Registrar ¶
type Registrar struct {
// contains filtered or unexported fields
}
func (*Registrar) MethodHandlerE ¶
func (r *Registrar) MethodHandlerE(m string) (types.MethodHandler, error)
func (*Registrar) RegisterDeviceCaller ¶
func (r *Registrar) RegisterDeviceCaller(ch types.Channel, dc types.DeviceCaller)
func (*Registrar) RegisterMethodHandler ¶
func (r *Registrar) RegisterMethodHandler(verb string, mh types.MethodHandler)
type ShellyDevice ¶
type ShellyDevice struct {
// contains filtered or unexported fields
}
func (ShellyDevice) Host ¶
func (d ShellyDevice) Host() string
func (ShellyDevice) Id ¶
func (d ShellyDevice) Id() string
func (ShellyDevice) Ip ¶
func (d ShellyDevice) Ip() net.IP
func (ShellyDevice) Mac ¶
func (d ShellyDevice) Mac() net.HardwareAddr
func (ShellyDevice) Manufacturer ¶
func (d ShellyDevice) Manufacturer() string
func (ShellyDevice) MarshalJSON ¶
func (d ShellyDevice) MarshalJSON() ([]byte, error)
func (ShellyDevice) Name ¶
func (d ShellyDevice) Name() string
func (ShellyDevice) Online ¶
func (d ShellyDevice) Online() bool
func (ShellyDevice) Provider ¶
func (d ShellyDevice) Provider() string
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
shelly
command
Command shelly is a standalone CLI for talking to Shelly devices over the local network (HTTP/mDNS or MQTT).
|
Command shelly is a standalone CLI for talking to Shelly devices over the local network (HTTP/mDNS or MQTT). |
|
shelly/dispatch
Package dispatch resolves a user-supplied device identifier (name, id, hostname, IP, or wildcard) to one or more devices.Device values and runs a per-device operation against each, in parallel.
|
Package dispatch resolves a user-supplied device identifier (name, id, hostname, IP, or wildcard) to one or more devices.Device values and runs a per-device operation against each, in parallel. |
|
shelly/emulate
Package emulate exposes the script package's goja-based Shelly device emulator as a CLI subcommand.
|
Package emulate exposes the script package's goja-based Shelly device emulator as a CLI subcommand. |
|
shelly/options
Package options holds CLI flags shared across subcommands of the shelly binary.
|
Package options holds CLI flags shared across subcommands of the shelly binary. |
|
https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Input/
|
https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Input/ |
|
script
module
|
|