shelly

package
v0.0.0-...-d7e87bf Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connection

type Connection struct {
	*request.Helper
	// contains filtered or unexported fields
}

Connection is the Shelly connection

func NewConnection

func NewConnection(uri, user, password string, channel int) (*Connection, error)

NewConnection creates a new Shelly device connection.

type DeviceInfo

type DeviceInfo struct {
	Gen       int    `json:"gen"`
	Id        string `json:"id"`
	Model     string `json:"model"`
	Type      string `json:"type"`
	Mac       string `json:"mac"`
	App       string `json:"app"`
	Auth      bool   `json:"auth"`
	AuthEn    bool   `json:"auth_en"`
	NumMeters int    `json:"num_meters"`
	Profile   string `json:"profile"`
}

Shelly api homepage https://shelly-api-docs.shelly.cloud/#common-http-api

type EnergyMeter

type EnergyMeter struct {
	*Connection
}

func NewEnergyMeter

func NewEnergyMeter(conn *Connection) *EnergyMeter

func (*EnergyMeter) CurrentPower

func (sh *EnergyMeter) CurrentPower() (float64, error)

CurrentPower implements the api.Meter interface

func (*EnergyMeter) Currents

func (sh *EnergyMeter) Currents() (float64, float64, float64, error)

Currents implements the api.PhaseCurrents interface

func (*EnergyMeter) Powers

func (sh *EnergyMeter) Powers() (float64, float64, float64, error)

Powers implements the api.PhasePowers interface

func (*EnergyMeter) TotalEnergy

func (sh *EnergyMeter) TotalEnergy() (float64, error)

TotalEnergy implements the api.Meter interface

func (*EnergyMeter) Voltages

func (sh *EnergyMeter) Voltages() (float64, float64, float64, error)

Voltages implements the api.PhaseVoltages interface

type Gen1StatusResponse

type Gen1StatusResponse struct {
	Meters []struct {
		Power float64
		Total float64
	}
	// Shelly EM meter JSON response
	EMeters []struct {
		Power float64
		Total float64
	}
}

type Gen1SwitchResponse

type Gen1SwitchResponse struct {
	Ison bool
}

type Gen2Em

type Gen2Em struct {
	Current  float64 `json:"current"`
	Voltage  float64 `json:"voltage"`
	ActPower float64 `json:"act_power"`
}

type Gen2EmData

type Gen2EmData struct {
	TotalActEnergy    float64 `json:"total_act_energy"`
	TotalActRetEnergy float64 `json:"total_act_ret_energy"`
}

type Gen2EmDataStatusResponse

type Gen2EmDataStatusResponse struct {
	TotalEnergy float64 `json:"total_act"`
}

type Gen2EmStatusResponse

type Gen2EmStatusResponse struct {
	TotalPower float64    `json:"total_act_power"`
	CurrentA   float64    `json:"a_current"`
	CurrentB   float64    `json:"b_current"`
	CurrentC   float64    `json:"c_current"`
	VoltageA   float64    `json:"a_voltage"`
	VoltageB   float64    `json:"b_voltage"`
	VoltageC   float64    `json:"c_voltage"`
	PowerA     float64    `json:"a_act_power"`
	PowerB     float64    `json:"b_act_power"`
	PowerC     float64    `json:"c_act_power"`
	Em0        Gen2Em     `json:"em1:0"`
	Em1        Gen2Em     `json:"em1:1"`
	Em2        Gen2Em     `json:"em1:2"`
	Em0Data    Gen2EmData `json:"em1data:0"`
	Em1Data    Gen2EmData `json:"em1data:1"`
	Em2Data    Gen2EmData `json:"em1data:2"`
}

type Gen2RpcPost

type Gen2RpcPost struct {
	Id     int    `json:"id"`
	On     bool   `json:"on"`
	Src    string `json:"src"`
	Method string `json:"method"`
}

type Gen2StatusResponse

type Gen2StatusResponse struct {
	Switch0 Gen2Switch `json:"switch:0"`
	Switch1 Gen2Switch `json:"switch:1"`
	Switch2 Gen2Switch `json:"switch:2"`
	Pm0     Gen2Switch `json:"pm1:0"`
	Pm1     Gen2Switch `json:"pm2:1"`
	Pm2     Gen2Switch `json:"pm3:2"`
}

type Gen2Switch

type Gen2Switch struct {
	Apower  float64
	Aenergy struct {
		Total float64
	}
}

type Gen2SwitchResponse

type Gen2SwitchResponse struct {
	Output bool `json:"output"`
}

type Switch

type Switch struct {
	*Connection
}

func NewSwitch

func NewSwitch(conn *Connection) *Switch

func (*Switch) CurrentPower

func (sh *Switch) CurrentPower() (float64, error)

CurrentPower implements the api.Meter interface

func (*Switch) Enable

func (sh *Switch) Enable(enable bool) error

Enable implements the api.Charger interface

func (*Switch) Enabled

func (sh *Switch) Enabled() (bool, error)

Enabled implements the api.Charger interface

func (*Switch) TotalEnergy

func (sh *Switch) TotalEnergy() (float64, error)

TotalEnergy implements the api.Meter interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL