Documentation
¶
Index ¶
- Variables
- type Client
- type Device
- type DeviceType
- type Discover
- type Option
- type RelaySwitchState
- type Switch
- func (s Switch) Off(ctx context.Context) error
- func (s Switch) On(ctx context.Context) error
- func (s Switch) PowerCycle(ctx context.Context, wait time.Duration) error
- func (s Switch) Relay(ctx context.Context, state RelaySwitchState) error
- func (s Switch) Report(ctx context.Context) (*SwitchReport, error)
- func (s Switch) Temperature(ctx context.Context) (*SwitchTemperature, error)
- func (s Switch) Timer(ctx context.Context, mode SwitchTimerMode, time time.Duration) error
- func (s Switch) Toggle(ctx context.Context) error
- func (s Switch) URL() url.URL
- type SwitchReport
- type SwitchTemperature
- type SwitchTimerMode
Constants ¶
This section is empty.
Variables ¶
var ErrStatus = errors.New("status code error")
ErrStatus respresents a non success status code error.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
Address net.Addr
MAC net.HardwareAddr
Type DeviceType
Cloud bool
Registered bool
MeshChild bool
}
type DeviceType ¶
type DeviceType byte
const ( DeviceTypeBulb DeviceType = 102 DeviceTypeButtonPlus1stGeneration DeviceType = 103 DeviceTypeButtonSmall DeviceType = 104 DeviceTypeLEDStrip DeviceType = 105 DeviceTypeSwitchCH DeviceType = 106 DeviceTypeSwitchEU DeviceType = 107 DeviceTypeMotionSensor DeviceType = 110 DeviceTypeGateway DeviceType = 112 DeviceTypeSTECCO DeviceType = 113 DeviceTypeButtonPlus2ndGeneration DeviceType = 118 DeviceTypeSwitchZero DeviceType = 120 )
https://api.mystrom.ch -> Discovery devices -> Device types
func (DeviceType) String ¶
func (d DeviceType) String() string
type Discover ¶
type Discover struct {
// See func net.Dial for a description of the Address parameter.
Address string
// Network must be "udp", "udp4", "udp6", "unixgram", or an IP transport.
// See net.ListenPacket for more details on the Network parameter.
Network string
ListenConfig net.ListenConfig
}
type Option ¶
type Option func(*Client)
func WithHTTPClient ¶
WithHTTPClient allows to replace the http client.
func WithUserAgent ¶
WithUserAgent allows to change the user agent.
type RelaySwitchState ¶
type RelaySwitchState string
const ( RelaySwitchStateOn RelaySwitchState = "1" RelaySwitchStateOff RelaySwitchState = "0" )
type Switch ¶
type Switch struct {
// contains filtered or unexported fields
}
Switch holds all info and logic to talk your myStrom Switch device.
func (Switch) PowerCycle ¶
PowerCycle turns the switch off, waits for a specified amount of time (max 1h), then starts it again. The switch has to be turned on in order for this call to work.
func (Switch) Report ¶
func (s Switch) Report(ctx context.Context) (*SwitchReport, error)
Report returns a report of the current statut of the Switch.
func (Switch) Temperature ¶
func (s Switch) Temperature(ctx context.Context) (*SwitchTemperature, error)
Temperature returns the current temperature in °C.
func (Switch) Timer ¶
Timer sets the relay state for a given time, after the time has elapsed the state of the relay is reversed.
type SwitchReport ¶
type SwitchReport struct {
Power float64 `json:"power"` // current power consumption in watts
Relay bool `json:"relay"` // state of the Switch, true is on, false is off
}
SwitchReport represets the content of a report of the Switch.
type SwitchTemperature ¶
type SwitchTemperature struct {
Measured float64 `json:"measured"` // measured temp
Compensation float64 `json:"compensation"` // assumed gap
Compensated float64 `json:"compensated"` // real temp
}
SwitchTemperature represets the content of a temperature response of the Switch. All temperatures are provided in °C.
type SwitchTimerMode ¶
type SwitchTimerMode string
const ( SwitchTimerModeOn SwitchTimerMode = "on" SwitchTimerModeOff SwitchTimerMode = "off" SwitchTimerModeToggle SwitchTimerMode = "toggle" SwitchTimerModeNone SwitchTimerMode = "none" )