httpDevice

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config interface {
	Url() *url.URL
	Kind() types.HttpDeviceKind
	Username() string
	Password() string
	PollInterval() time.Duration
}

type DeviceStruct

type DeviceStruct struct {
	device.State
	// contains filtered or unexported fields
}

func NewDevice

func NewDevice(
	deviceConfig device.Config,
	teracomConfig Config,
	stateStorage *dataflow.ValueStorage,
	commandStorage *dataflow.ValueStorage,
) *DeviceStruct

func (*DeviceStruct) GetRequest

func (ds *DeviceStruct) GetRequest(path string) (request *http.Request, err error)

func (*DeviceStruct) Model

func (ds *DeviceStruct) Model() string

func (*DeviceStruct) Run

func (ds *DeviceStruct) Run(ctx context.Context) (err error, immediateError bool)

type Implementation

type Implementation interface {
	GetPath() string
	HandleResponse(body []byte) error
	GetCategorySort(category string) int
	CommandValueRequest(value dataflow.Value) (*http.Request, OnCommandSuccess, error)
}

type OnCommandSuccess

type OnCommandSuccess func()

type ShellyEm3Device

type ShellyEm3Device struct {
	// contains filtered or unexported fields
}

func (*ShellyEm3Device) CommandValueRequest

func (c *ShellyEm3Device) CommandValueRequest(value dataflow.Value) (*http.Request, OnCommandSuccess, error)

func (*ShellyEm3Device) GetCategorySort

func (c *ShellyEm3Device) GetCategorySort(category string) int

func (*ShellyEm3Device) GetPath

func (c *ShellyEm3Device) GetPath() string

func (*ShellyEm3Device) HandleResponse

func (c *ShellyEm3Device) HandleResponse(body []byte) error

type ShellyEm3StatusStruct

type ShellyEm3StatusStruct struct {
	WifiSta struct {
		Connected bool   `json:"connected"`
		Ssid      string `json:"ssid"`
		Ip        string `json:"ip"`
		Rssi      int    `json:"rssi"`
	} `json:"wifi_sta"`
	Cloud struct {
		Enabled   bool `json:"enabled"`
		Connected bool `json:"connected"`
	} `json:"cloud"`
	Mqtt struct {
		Connected bool `json:"connected"`
	} `json:"mqtt"`
	Time          string `json:"time"`
	Serial        int    `json:"serial"`
	HasUpdate     bool   `json:"has_update"`
	Mac           string `json:"mac"`
	CfgChangedCnt int    `json:"cfg_changed_cnt"`
	Relays        []struct {
		Ison           bool   `json:"ison"`
		HasTimer       bool   `json:"has_timer"`
		TimerStarted   int    `json:"timer_started"`
		TimerDuration  int    `json:"timer_duration"`
		TimerRemaining int    `json:"timer_remaining"`
		Overpower      bool   `json:"overpower"`
		IsValid        bool   `json:"is_valid"`
		Source         string `json:"source"`
	} `json:"relays"`
	Emeters []struct {
		Power         float64 `json:"power"`
		Pf            float64 `json:"pf"`
		Current       float64 `json:"current"`
		Voltage       float64 `json:"voltage"`
		IsValid       bool    `json:"is_valid"`
		Total         float64 `json:"total"`
		TotalReturned float64 `json:"total_returned"`
	} `json:"emeters"`
	TotalPower float64 `json:"total_power"`
	EmeterN    struct {
		Current  float64 `json:"current"`
		Ixsum    float64 `json:"ixsum"`
		Mismatch bool    `json:"mismatch"`
		IsValid  bool    `json:"is_valid"`
	} `json:"emeter_n"`
	Uptime int `json:"uptime"`
}

type TeracomDevice

type TeracomDevice struct {
	// contains filtered or unexported fields
}

func (*TeracomDevice) CommandValueRequest

func (c *TeracomDevice) CommandValueRequest(value dataflow.Value) (*http.Request, OnCommandSuccess, error)

func (*TeracomDevice) GetCategorySort

func (c *TeracomDevice) GetCategorySort(category string) int

func (*TeracomDevice) GetPath

func (c *TeracomDevice) GetPath() string

func (*TeracomDevice) HandleResponse

func (c *TeracomDevice) HandleResponse(body []byte) error

Jump to

Keyboard shortcuts

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