server

package
v0.0.0-...-d2f1de2 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommandTopicRegex = regexp.MustCompile(".*/(?P<deviceId>\\S+)/set")
View Source
var DefaultClient = http.Client{
	Timeout: 10 * time.Second,
}

Functions

func CreateMqtt

func CreateMqtt(server string, callback mqtt.MessageHandler)

func Publish

func Publish(topic string, v any, retained bool)

func PublishHvac

func PublishHvac(deviceId string, config *homeassistant.Hvac)

func PublishSensor

func PublishSensor(deviceId string, config *homeassistant.Sensor, sensor string)

func PublishState

func PublishState()

func PublishStatus

func PublishStatus(deviceId string, status *Status)

Types

type Server

type Server struct {
	Auth *auth.Auth
	// contains filtered or unexported fields
}

func New

func New(clientId, clientSecret, mqttServer string, logger *zap.Logger) *Server

func (*Server) Run

func (r *Server) Run() error

func (*Server) SetTargetTemp

func (r *Server) SetTargetTemp(deviceId string, targetTemp float64)

type Status

type Status struct {
	Energy       float64 `json:"energy,omitempty"`
	StoredEnergy float64 `json:"stored_energy,omitempty"`
	TargetTemp   float64 `json:"target_temp,omitempty"`
	CurrentTemp  float64 `json:"current_temp,omitempty"`
	Power        float64 `json:"power,omitempty"`
	MaxPower     float64 `json:"max_power,omitempty"`
	Mode         string  `json:"mode,omitempty"`
	Action       string  `json:"action,omitempty"`
}

type Update

type Update struct {
	TargetTemp float64 `json:"temperature,omitempty"`
}

Jump to

Keyboard shortcuts

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