shellygen1

package
v0.0.0-...-5bc8923 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Driver name for this device implementation.
	Driver = "shellygen1"

	// Vendor represents the name of the company that developed the device.
	Vendor = "Shelly"

	// Generation of this device implementation.
	Generation = "1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Policy                 *device.Policy `json:"policy,omitempty"`
	Settings               *settings      `json:"settings,omitempty"`
	SettingsAP             *settings      `json:"settings_ap,omitempty"`
	SettingsSTA            *settings      `json:"settings_sta,omitempty"`
	SettingsSTA1           *settings      `json:"settings_sta1,omitempty"`
	SettingsCloud          *settings      `json:"settings_cloud,omitempty"`
	SettingsActions        *[]*settings   `json:"settings_actions,omitempty"`
	SettingsRelay          *[]*settings   `json:"settings_relay,omitempty"`
	SettingsPower          *[]*settings   `json:"settings_power,omitempty"`
	SettingsExtTemperature *[]*settings   `json:"settings_ext_temperature,omitempty"`
	SettingsExtHumidity    *[]*settings   `json:"settings_ext_humidity,omitempty"`
	SettingsExtSwitch      *[]*settings   `json:"settings_ext_switch,omitempty"`
}

Config implementation for the Shelly Gen1 driver.

func (*Config) Driver

func (c *Config) Driver() string

Driver name of this Config implementation.

func (*Config) Empty

func (c *Config) Empty() bool

Empty checks if the struct holding the configuration has a zero value.

type Device

type Device struct {
	Firmware     string
	FirmwareNext string
	// contains filtered or unexported fields
}

Device implementation for the Shelly Gen1 driver.

func (*Device) AuthConfigRequest

func (d *Device) AuthConfigRequest(auth *device.AuthConfig) (*http.Request, error)

AuthConfigRequest returns an authentication setup HTTP request. See: https://shelly-api-docs.shelly.cloud/gen1/#settings-login

func (*Device) ConfigureRequests

func (d *Device) ConfigureRequests(config device.Config) ([]*http.Request, error)

ConfigureRequests generates a slice of *http.Requests that are to be executed in order to configure an IoT device.

func (*Device) DelimitedRow

func (d *Device) DelimitedRow(sep string) string

DelimitedRow returns a string representation of the resource, with fields separated by a delimiter (e.g., comma or tab).

func (*Device) Driver

func (d *Device) Driver() string

Driver name of this Device implementation.

func (*Device) EnrichRequest

func (d *Device) EnrichRequest() (*http.Request, error)

EnrichRequest returns an HTTP request for device data enrichment. See: https://shelly-api-docs.shelly.cloud/gen1/#settings

func (*Device) EnrichUnmarshaler

func (d *Device) EnrichUnmarshaler() *json.Unmarshalers

EnrichUnmarshaler returns a *json.Unmarshalers for decoding additional metadata from a secondary data source (i.e. endpoint).

func (*Device) Generation

func (d *Device) Generation() string

Generation represents the generation of this device.

func (*Device) ID

func (d *Device) ID() string

ID returns the Device's unique identifier.

func (*Device) IP

func (d *Device) IP() net.IP

IP address of the Device.

func (*Device) MAC

func (d *Device) MAC() net.HardwareAddr

MAC address of the Device.

func (*Device) MarshalJSON

func (d *Device) MarshalJSON() ([]byte, error)

MarshalJSON implements the Marshaler interface.

func (*Device) Model

func (d *Device) Model() string

Model of the Device.

func (*Device) Name

func (d *Device) Name() string

Name of the Device.

func (*Device) Outdated

func (d *Device) Outdated() bool

Outdated checks if the device's firmware is out of date.

func (*Device) RebootRequest

func (d *Device) RebootRequest() (*http.Request, error)

RebootRequest returns a device reboot HTTP request. See: https://shelly-api-docs.shelly.cloud/gen1/#reboot

func (*Device) Secured

func (d *Device) Secured() bool

Secured returns true if the device requires authentication to be accessed, false otherwise.

func (*Device) SetCredentials

func (d *Device) SetCredentials(cred *device.Credentials)

SetCredentials for device authentication.

func (*Device) UpdateDetails

func (d *Device) UpdateDetails() string

UpdateDetails prints the device update information.

func (*Device) UpdateRequest

func (d *Device) UpdateRequest() (*http.Request, error)

UpdateRequest returns a device firmware update HTTP request. See: https://shelly-api-docs.shelly.cloud/gen1/#ota

func (*Device) Vendor

func (d *Device) Vendor() string

Vendor represents the name of the company that developed the device.

func (*Device) VersionRequest

func (d *Device) VersionRequest() (*http.Request, error)

VersionRequest for a device version check via HTTP. See: https://shelly-api-docs.shelly.cloud/gen1/#ota

func (*Device) VersionUnmarshaler

func (d *Device) VersionUnmarshaler() *json.Unmarshalers

VersionUnmarshaler returns a *json.Unmarshalers that decodes the JSON response from the device's version API endpoint. It is used to interpret the version information so the caller can determine whether a newer firmware release is available.

type Prober

type Prober struct{}

Prober implementation for the Shelly Gen1 driver.

func (*Prober) Request

func (p *Prober) Request(ip net.IP) (*http.Request, device.Resource, error)

Request for probing Shelly Gen1 devices on a given IP address.

func (*Prober) Unmarshaler

func (p *Prober) Unmarshaler() *json.Unmarshalers

Unmarshaler returns a *json.Unmarshalers for decoding the JSON response from a network probe. On success, it hydrates a Device resource. This typically includes the device model, MAC address, security status, and firmware version. If the required fields are missing, it returns an error indicating an unexpected device.