shelly

package
v0.0.0-...-3371691 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 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"`
	Auth      bool   `json:"auth"`
	AuthEn    bool   `json:"auth_en"`
	NumMeters int    `json:"num_meters"`
}

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 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"`
}

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"`
}

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