smarthome

package module
v0.0.0-...-0ff5774 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeConfirmable     = 0
	TypeNonConfirmable  = 1
	TypeAcknowledgement = 2
	TypeReset           = 3
)

Variables

This section is empty.

Functions

func HTTPtoJSON

func HTTPtoJSON(url string, v interface{}) error

Types

type CoIoT

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

func CoIoTinit

func CoIoTinit() (*CoIoT, error)

func (*CoIoT) Read

func (c *CoIoT) Read() *CoIoTpacket

type CoIoToption

type CoIoToption struct {
	Number int
	Value  []byte
}

type CoIoTpacket

type CoIoTpacket struct {
	RemoteAddr *net.UDPAddr
	Version    int
	Type       int
	Code       [2]int
	MessageID  uint16
	Token      []byte
	Options    []CoIoToption
	Payload    []byte
	Path       []string
}

type InfluxClient

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

func NewInfluxClient

func NewInfluxClient(addr string, user string, pass string, database string) (*InfluxClient, error)

func (*InfluxClient) Close

func (i *InfluxClient) Close() error

func (*InfluxClient) Insert

func (i *InfluxClient) Insert(nameTags string, fields map[string]interface{}) error

func (*InfluxClient) InsertLine

func (i *InfluxClient) InsertLine(line string) error

type MQTTClient

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

func NewMQTTClient

func NewMQTTClient(addr string) (*MQTTClient, error)

func (*MQTTClient) Publish

func (m *MQTTClient) Publish(topic string, payload string)

func (*MQTTClient) Subscribe

func (m *MQTTClient) Subscribe(topic string) chan *mqtt.Message

type ShellyInfo

type ShellyInfo struct {
	Settings ShellySettings
	Status   ShellyStatus
}

func ShellyGetInfo

func ShellyGetInfo(host string) (*ShellyInfo, error)

type ShellySettings

type ShellySettings struct {
	// Common HTTP API
	Device struct {
		Type       string
		MAC        string
		Hostname   string
		NumOutputs int `json:"num_outputs"`
		NumMeters  int `json:"num_meters"`
		NumRollers int `json:"num_rollers"`
	}
	WiFiAP struct {
		Enabled bool
		SSID    string
		Key     string
	} `json:"wifi_ap"`
	WiFiStatus struct {
		Enabled    bool
		SSID       string
		IPv4Method string `json:"ipv4_method"`
		IP         string
		GW         string
		Mask       string
		DNS        string
	} `json:"wifi_sta"`
	WiFiStatus1 struct {
		Enabled    bool
		SSID       string
		IPv4Method string `json:"ipv4_method"`
		IP         string
		GW         string
		Mask       string
		DNS        string
	} `json:"wifi_sta1"`
	APRoaming struct {
		Enabled   bool
		Threshold int
	} `json:"ap_roaming"`
	MQTT struct {
		Enabled             bool
		Server              string
		User                string
		ID                  string
		ReconnectTimeoutMax float64 `json:"reconnect_timeout_max"`
		ReconnectTimeoutMin float64 `json:"reconnect_timeout_min"`
		CleanSession        bool    `json:"clean_session"`
		KeepAlive           int     `json:"keep_alive"`
		MaxQoS              int     `json:"max_qos"`
		Retain              bool
		UpdatePeriod        int `json:"update_period"`
	}
	CoIoT struct {
		Enabled      bool
		UpdatePeriod int `json:"update_period"`
		Peer         string
	}
	SNTP struct {
		Server  string
		Enabled bool
	}
	Login struct {
		Enabled     bool
		Unprotected bool
		Username    string
	}
	PinCode      string `json:"pin_code"`
	Name         string
	FW           string
	Discoverable bool
	BuildInfo    struct {
		BuildID        string `json:"build_id"`
		BuildTimestamp string `json:"build_timestamp"`
		BuildVersion   string `json:"build_version"`
	} `json:"build_info"`
	Cloud struct {
		Enabled   bool
		Connected bool
	}
	Timezone                  string
	Lat                       float64
	Lng                       float64
	TZAutodetect              bool
	TZUTCOffset               int  `json:"tz_utc_offset"`
	TZDST                     bool `json:"tz_dst"`
	TZDSTAuto                 bool `json:"tz_dst_auto"`
	Time                      string
	Unixtime                  int
	DebugEnable               bool `json:"debug_enable"`
	AllowCrossOrigin          bool `json:"allow_cross_origin"`
	WiFiRecoveryRebootEnabled bool `json:"wifirecovery_reboot_enabled"`

	// Shelly 1/2.5/...
	Mode string
}

type ShellyStatus

type ShellyStatus struct {
	// Common HTTP API
	WiFiStatus struct {
		Connected bool
		SSID      string
		IP        string
		RSSI      int
	} `json:"wifi_sta"`

	// Extra HTTP API for some Shellies
	Temperature float64
	Voltage     float64
	Relays      []struct {
		IsOn          bool
		HasTimer      bool `json:"has_timer"`
		TimerDuration int  `json:"timer_duration"`
		IsValid       bool `json:"is_valid"`
		Source        string
	}
	Rollers []struct {
		State         string
		Source        string
		Power         float64
		IsValid       bool   `json:"is_valid"`
		LastDirection string `json:"last_direction"`
		CurrentPos    int    `json:"current_pos"`
		Positioning   bool
	}
	Meters []struct {
		Power     float64
		IsValid   bool `json:"is_valid"`
		Timestamp int
		Counters  []float64
		Total     int
	}
	Inputs []struct {
		Input    int
		Event    string
		EventCnt int `json:"event_cnt"`
	}
	Emeters []struct {
		Power         float64
		Reactive      float64
		Voltage       float64
		IsValid       bool `json:"is_valid"`
		Total         float64
		TotalReturned float64 `json:"total_returned"`
	}
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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