Documentation
¶
Index ¶
- Constants
- type Config
- type Device
- func (d *Device) AuthConfigRequest(auth *device.AuthConfig) (*http.Request, error)
- func (d *Device) ChallengeAccepted(resp *http.Response) bool
- func (d *Device) ChallengeResponse(r *http.Request, resp *http.Response) (*http.Request, error)
- func (d *Device) ConfigureRequests(config device.Config) ([]*http.Request, error)
- func (d *Device) DelimitedRow(sep string) string
- func (d *Device) DeployRequests(client *http.Client, dep *device.Deployment) ([]*http.Request, error)
- func (d *Device) Driver() string
- func (d *Device) Generation() string
- func (d *Device) ID() string
- func (d *Device) IP() net.IP
- func (d *Device) MAC() net.HardwareAddr
- func (d *Device) MarshalJSON() ([]byte, error)
- func (d *Device) Model() string
- func (d *Device) Name() string
- func (d *Device) Outdated() bool
- func (d *Device) RebootRequest() (*http.Request, error)
- func (d *Device) Secured() bool
- func (d *Device) SetCredentials(cred *device.Credentials)
- func (d *Device) UpdateDetails() string
- func (d *Device) UpdateRequest() (*http.Request, error)
- func (d *Device) Vendor() string
- func (d *Device) VersionRequest() (*http.Request, error)
- func (d *Device) VersionUnmarshaler() *json.Unmarshalers
- type Prober
Constants ¶
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.
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 ¶
AuthConfigRequest returns an authentication setup HTTP request. See: https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Shelly#shellysetauth
func (*Device) ChallengeAccepted ¶
ChallengeAccepted determines whether the current implementation can accept and handle the authentication challenge presented in the provided HTTP response.
func (*Device) ChallengeResponse ¶
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 ¶
ConfigureRequests generates a slice of *http.Requests that are to be executed in order to configure an IoT device.
func (*Device) DelimitedRow ¶
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) Generation ¶
Generation represents the generation of this device.
func (*Device) MarshalJSON ¶
MarshalJSON implements the Marshaler interface.
func (*Device) RebootRequest ¶
RebootRequest returns a device reboot HTTP request. See: https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Shelly#shellyreboot
func (*Device) Secured ¶
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 ¶
UpdateDetails prints the device update information.
func (*Device) UpdateRequest ¶
UpdateRequest returns a device firmware update HTTP request. See: https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Shelly#shellyupdate
func (*Device) VersionRequest ¶
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) 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.