devices

package
v0.0.0-...-a0a0ef1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadHomematicDevices

func LoadHomematicDevices(ctx Context, devices *Devices, device Device) error

func LoadIoBrokerDevices

func LoadIoBrokerDevices(ctx Context, devices *Devices, device Device) error

func LoadTasmotaDevices

func LoadTasmotaDevices(ctx Context, devices *Devices, device Device) error

Types

type Context

type Context struct {
	Root      string
	NetClient *http.Client
	Clog      *logrus.Entry
	// contains filtered or unexported fields
}

func (*Context) Fatal

func (c *Context) Fatal(err error, args ...interface{})

func (*Context) Info

func (c *Context) Info(args ...interface{})

func (*Context) Pop

func (c *Context) Pop()

func (*Context) Post

func (c *Context) Post(url string, contentType string, body io.Reader) (resp *http.Response, err error)

func (*Context) PushField

func (c *Context) PushField(key string, value interface{})

func (*Context) PushFields

func (c *Context) PushFields(fields logrus.Fields)

func (*Context) Warn

func (c *Context) Warn(err error, args ...interface{})

type Device

type Device struct {
	Source struct {
		Provider          string `yaml:"provider"`
		EnergyMetric      string `yaml:"energy_metric"`
		PowerMetric       string `yaml:"power_metric"`
		TemperatureMetric string `yaml:"temperature_metric"`
		LightMetric       string `yaml:"light_metric"`
		Address           string `yaml:"address"`
		UserName          string `yaml:"user_name,omitempty"`
		Password          string `yaml:"password,omitempty"`

		Interval string `yaml:"interval"`
		Devices  []struct {
			Name    string `yaml:"name"`
			Room    string `yaml:"room"`
			Address string `yaml:"address"`
			HmName  string `yaml:"hm_name"`
		} `yaml:"devices"`
		// contains filtered or unexported fields
	} `yaml:"source"`
}

type DeviceInterface

type DeviceInterface interface {
	DeviceID() string
	MetricName() string
	Name() string
	Room() string
	FullName() string
	LogName() string
	Labels() []string
	CategoryName() string
	IntervalSec() uint64

	CurrentValue(Context) (float64, error)
	LastValue() string
}

type DeviceList

type DeviceList struct {
	Devices *[]DeviceInterface
}

type Devices

type Devices struct {
	DeviceList
	ByDID map[string]DeviceList
}

func LoadDevices

func LoadDevices(setup string) Devices

func (*Devices) IsEmpty

func (d *Devices) IsEmpty() bool

func (*Devices) Length

func (d *Devices) Length() int

type HomematicDesc

type HomematicDesc struct {
	HmName             string
	Name               string
	Room               string
	Interval           float64
	ScriptUrl          string
	UserName           string
	Password           string
	EnergyMetric       string
	EnergyChannel      int
	PowerMetric        string
	PowerChannel       int
	TemperatureMetric  string
	TemperatureChannel int
	TemperatureName    string
	LightMetric        string
	LightChannel       int
	LightName          string
}

type HomematicDevice

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

func (*HomematicDevice) CategoryName

func (t *HomematicDevice) CategoryName() string

func (*HomematicDevice) CurrentValue

func (t *HomematicDevice) CurrentValue(ctx Context) (float64, error)

func (*HomematicDevice) DeviceID

func (t *HomematicDevice) DeviceID() string

func (*HomematicDevice) FullName

func (t *HomematicDevice) FullName() string

func (*HomematicDevice) IntervalSec

func (t *HomematicDevice) IntervalSec() uint64

func (*HomematicDevice) Labels

func (t *HomematicDevice) Labels() []string

func (*HomematicDevice) LastValue

func (t *HomematicDevice) LastValue() string

func (*HomematicDevice) LogName

func (t *HomematicDevice) LogName() string

func (*HomematicDevice) MetricName

func (t *HomematicDevice) MetricName() string

func (*HomematicDevice) Name

func (t *HomematicDevice) Name() string

func (*HomematicDevice) Room

func (t *HomematicDevice) Room() string

type IoBrokerDevice

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

func (*IoBrokerDevice) CategoryName

func (t *IoBrokerDevice) CategoryName() string

func (*IoBrokerDevice) CurrentValue

func (t *IoBrokerDevice) CurrentValue(ctx Context) (float64, error)

func (*IoBrokerDevice) DeviceID

func (t *IoBrokerDevice) DeviceID() string

func (*IoBrokerDevice) FullName

func (t *IoBrokerDevice) FullName() string

func (*IoBrokerDevice) IntervalSec

func (t *IoBrokerDevice) IntervalSec() uint64

func (*IoBrokerDevice) Labels

func (t *IoBrokerDevice) Labels() []string

func (*IoBrokerDevice) LastValue

func (t *IoBrokerDevice) LastValue() string

func (*IoBrokerDevice) LogName

func (t *IoBrokerDevice) LogName() string

func (*IoBrokerDevice) MetricName

func (t *IoBrokerDevice) MetricName() string

func (*IoBrokerDevice) Name

func (t *IoBrokerDevice) Name() string

func (*IoBrokerDevice) Room

func (t *IoBrokerDevice) Room() string

type TasmotaDevice

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

func (*TasmotaDevice) CategoryName

func (t *TasmotaDevice) CategoryName() string

func (*TasmotaDevice) CurrentValue

func (t *TasmotaDevice) CurrentValue(ctx Context) (float64, error)

func (*TasmotaDevice) DeviceID

func (t *TasmotaDevice) DeviceID() string

func (*TasmotaDevice) FullName

func (t *TasmotaDevice) FullName() string

func (*TasmotaDevice) IntervalSec

func (t *TasmotaDevice) IntervalSec() uint64

func (*TasmotaDevice) Labels

func (t *TasmotaDevice) Labels() []string

func (*TasmotaDevice) LastValue

func (t *TasmotaDevice) LastValue() string

func (*TasmotaDevice) LogName

func (t *TasmotaDevice) LogName() string

func (*TasmotaDevice) MetricName

func (t *TasmotaDevice) MetricName() string

func (*TasmotaDevice) Name

func (t *TasmotaDevice) Name() string

func (*TasmotaDevice) Room

func (t *TasmotaDevice) Room() string

type TasmotaEnergy

type TasmotaEnergy struct {
	StatusSNS struct {
		Time   string `json:"Time"`
		ENERGY struct {
			TotalStartTime string  `json:"TotalStartTime"`
			Total          float64 `json:"Total"`
			Yesterday      float64 `json:"Yesterday"`
			Today          float64 `json:"Today"`
			Power          int     `json:"Power"`
			ApparentPower  int     `json:"ApparentPower"`
			ReactivePower  int     `json:"ReactivePower"`
			Factor         float64 `json:"Factor"`
			Voltage        int     `json:"Voltage"`
			Current        float64 `json:"Current"`
		} `json:"ENERGY"`
	} `json:"StatusSNS"`
}

type TasmotaStatus

type TasmotaStatus struct {
	Status struct {
		Module       int      `json:"Module"`
		DeviceName   string   `json:"DeviceName"`
		FriendlyName []string `json:"FriendlyName"`
		Topic        string   `json:"Topic"`
		ButtonTopic  string   `json:"ButtonTopic"`
		Power        int      `json:"Power"`
		PowerOnState int      `json:"PowerOnState"`
		LedState     int      `json:"LedState"`
		LedMask      string   `json:"LedMask"`
		SaveData     int      `json:"SaveData"`
		SaveState    int      `json:"SaveState"`
		SwitchTopic  string   `json:"SwitchTopic"`
		SwitchMode   []int    `json:"SwitchMode"`
		ButtonRetain int      `json:"ButtonRetain"`
		SwitchRetain int      `json:"SwitchRetain"`
		SensorRetain int      `json:"SensorRetain"`
		PowerRetain  int      `json:"PowerRetain"`
		InfoRetain   int      `json:"InfoRetain"`
		StateRetain  int      `json:"StateRetain"`
	} `json:"Status"`
}

Jump to

Keyboard shortcuts

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