shellygen2

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: 13 Imported by: 0

Documentation

Index

Constants

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

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

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Policy *device.Policy `json:"policy,omitempty"`
	BLE    *settings      `json:"ble,omitempty"`
	Cloud  *settings      `json:"cloud,omitempty"`
	Eth    *settings      `json:"eth,omitempty"`
	Input  *[]*settings   `json:"input,omitempty"`
	MQTT   *settings      `json:"mqtt,omitempty"`
	Switch *[]*settings   `json:"switch,omitempty"`
	Sys    *settings      `json:"sys,omitempty"`
	WiFi   *settings      `json:"wifi,omitempty"`
	WS     *settings      `json:"ws,omitempty"`
}

Config implementation for the Shelly Gen2 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 {
	Realm       string
	Firmware    string
	Version     string
	VersionNext string

	Gen uint8
	// contains filtered or unexported fields
}

Device implementation for the Shelly Gen2 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/gen2/ComponentsAndServices/Shelly#shellysetauth

func (*Device) ChallengeAccepted

func (d *Device) ChallengeAccepted(resp *http.Response) bool

ChallengeAccepted determines whether the current implementation can accept and handle the authentication challenge presented in the provided HTTP response.

func (*Device) ChallengeResponse

func (d *Device) ChallengeResponse(r *http.Request, resp *http.Response) (*http.Request, error)

ChallengeResponse processes the authentication challenge in the provided response and applies the necessary authentication headers to the request. See: https://shelly-api-docs.shelly.cloud/gen2/General/Authentication/#authentication-process

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) DeployRequests

func (d *Device) DeployRequests(client *http.Client, dep *device.Deployment) ([]*http.Request, error)

DeployRequests creates an ordered slice of *http.Request objects for deploying device scripts.

func (*Device) Driver

func (d *Device) Driver() string

Driver name of this Device implementation.

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/gen2/ComponentsAndServices/Shelly#shellyreboot

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/gen2/ComponentsAndServices/Shelly#shellyupdate

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/gen2/ComponentsAndServices/Shelly#shellycheckforupdate

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 Gen2 driver.

func (*Prober) Request

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

Request for probing Shelly Gen2 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.