hass

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2022 License: GPL-3.0 Imports: 4 Imported by: 3

README

hass

Smart home configuration and discovery protocol over MQTT for Golang, compatible with Home Assistant.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnnounceDevice added in v0.0.2

func AnnounceDevice(client mqtt.Client, prefix string, nodeid string, objectid string, device IConfig) error

<discovery_prefix>/<component>/[<node_id>/]<object_id>/config

func ConsumeDiscoveredConfigs added in v0.0.2

func ConsumeDiscoveredConfigs(client mqtt.Client, consumer ConfigConsumer, errs chan error)

func Discover

func Discover(client mqtt.Client, prefix string) (chan DiscoveredConfig, error)

func GetDiscoveryTopic

func GetDiscoveryTopic(c IConfig, prefix string, nodeID string, objectID string) string

func GetDiscoveryWildcard

func GetDiscoveryWildcard(prefix string) string

func GetPayload

func GetPayload(c IConfig) ([]byte, error)

Types

type BasicConfig

type BasicConfig struct {
	Device   *Device `json:"device,omitempty"`
	UniqueID string  `json:"unique_id,omitempty"`
}

func (*BasicConfig) GetBasic added in v0.0.7

func (c *BasicConfig) GetBasic() *BasicConfig

type BinarySensor added in v0.0.5

type BinarySensor struct {
	BasicConfig
	Name          string `json:"name,omitempty"`
	ValueTemplate string `json:"value_template,omitempty"`
	DeviceClass   string `json:"device_class,omitempty"`
	Topic         string `json:"state_topic"`
	Icon          string `json:"icon,omitempty"`
	PayLoadOff    any    `json:"payload_off,omitempty"`
	PayLoadOn     any    `json:"payload_on,omitempty"`
}

func (*BinarySensor) Consume added in v0.0.5

func (c *BinarySensor) Consume(consumer ConfigConsumer, nodeID string, objectID string)

func (*BinarySensor) GetComponent added in v0.0.5

func (*BinarySensor) GetComponent() string

type ConfigConsumer

type ConfigConsumer interface {
	ConsumeCover(c *Cover, nodeID string, objectID string)
	ConsumeDInput(c *DInput, nodeID string, objectID string)
	ConsumeHVAC(c *HVAC, nodeID string, objectID string)
	ConsumeSwitch(c *Switch, nodeID string, objectID string)
	ConsumeSensor(c *Sensor, nodeID string, objectID string)
	ConsumeLight(c *Light, nodeID string, objectID string)
	ConsumeBinarySensor(c *BinarySensor, nodeID string, objectID string)
}

type Cover

type Cover struct {
	BasicConfig
	CommandTopic   string `json:"command_topic,omitempty"`
	Name           string `json:"name,omitempty"`
	PositionTopic  string `json:"position_topic,omitempty"`
	PositionOpen   int    `json:"position_open"`
	PositionClosed int    `json:"position_closed"`
}

func (*Cover) Consume added in v0.0.2

func (c *Cover) Consume(consumer ConfigConsumer, nodeID string, objectID string)

func (*Cover) GetComponent

func (*Cover) GetComponent() string

type DInput

type DInput struct {
	BasicConfig
	Name       string `json:"name"`
	StateTopic string `json:"state_topic"`
}

func (*DInput) Consume added in v0.0.2

func (c *DInput) Consume(consumer ConfigConsumer, nodeID string, objectID string)

func (*DInput) GetComponent

func (*DInput) GetComponent() string

type Device

type Device struct {
	Identifiers  []string `json:"identifiers,omitempty"`
	Connections  []string `json:"connections,omitempty"`
	Manufacturer string   `json:"manufacturer,omitempty"`
	Model        string   `json:"model,omitempty"`
	Name         string   `json:"name,omitempty"`
	SwVersion    string   `json:"sw_version,omitempty"`
}

type DiscoveredConfig added in v0.0.2

type DiscoveredConfig struct {
	Topic   string
	Payload []byte
}

type HVAC

type HVAC struct {
	BasicConfig
	Name string `json:"name,omitempty"`

	ActionTopic string `json:"action_topic,omitempty"`

	CurrentTemperatureTopic string `json:"current_temperature_topic,omitempty"`
	TemperatreCommandTopic  string `json:"temperature_command_topic,omitempty"`
	//TemperatureUnit         string  `json:"temperature_unit,omitempty"`
	TemperatureStateTopic string   `json:"temperature_state_topic,omitempty"`
	MaxTemp               float64  `json:"max_temp,omitempty"`
	MinTemp               float64  `json:"min_temp,omitempty"`
	TempStep              float64  `json:"temp_step,omitempty"`
	Modes                 []string `json:"modes,omitempty"`
	ModeCommandTopic      string   `json:"mode_command_topic,omitempty"`
}

func (*HVAC) Consume added in v0.0.2

func (c *HVAC) Consume(consumer ConfigConsumer, nodeID string, objectID string)

func (*HVAC) GetComponent

func (*HVAC) GetComponent() string

type IConfig

type IConfig interface {
	GetComponent() string
	Consume(consumer ConfigConsumer, nodeID string, objectID string)
	GetBasic() *BasicConfig
}

func ProcessConfig

func ProcessConfig(prefix string, confData DiscoveredConfig) (IConfig, string, string, error)

type Light

type Light struct {
	BasicConfig
	CommandTopic           string   `json:"command_topic,omitempty"`
	Name                   string   `json:"name,omitempty"`
	Brightness             bool     `json:"brightness,omitempty"`
	BrightnessCommandTopic string   `json:"brightness_command_topic,omitempty"`
	BrightnessScale        int32    `json:"brightness_scale"`
	BrightnessStateTopic   string   `json:"brightness_state_topic,omitempty"`
	ColorTemp              bool     `json:"color_temp,omitempty"`
	OnCommandType          string   `json:"on_command_type,omitempty"`
	StateTopic             string   `json:"state_topic,omitempty"`
	Effect                 bool     `json:"effect,omitempty"`
	EffectList             []string `json:"effect_list,omitempty"`
	HS                     bool     `json:"hs,omitempty"`
	JsonAttributesTopic    string   `json:"json_attributes_topic,omitempty"`
	Schema                 string   `json:"schema,omitempty"`
	XY                     bool     `json:"xy,omitempty"`
}

func (*Light) Consume added in v0.0.2

func (c *Light) Consume(consumer ConfigConsumer, nodeID string, objectID string)

func (*Light) GetComponent

func (*Light) GetComponent() string

type Sensor

type Sensor struct {
	BasicConfig
	Name              string `json:"name,omitempty"`
	UnitOfMeasurement string `json:"unit_of_measurement"`
	Topic             string `json:"state_topic"`
	Icon              string `json:"icon,omitempty"`
	StateClass        string `json:"state_class,omitempty"`
	ValueTemplate     string `json:"value_template,omitempty"`
	DeviceClass       string `json:"device_class,omitempty"`
}

https://www.home-assistant.io/integrations/sensor.mqtt/

func (*Sensor) Consume added in v0.0.2

func (c *Sensor) Consume(consumer ConfigConsumer, nodeID string, objectID string)

func (*Sensor) GetComponent

func (*Sensor) GetComponent() string

type Switch

type Switch struct {
	BasicConfig
	CommandTopic  string `json:"command_topic,omitempty"`
	Name          string `json:"name,omitempty"`
	StateTopic    string `json:"state_topic,omitempty"`
	ValueTemplate string `json:"value_template,omitempty"`
	PayLoadOff    any    `json:"payload_off,omitempty"`
	PayLoadOn     any    `json:"payload_on,omitempty"`
}

https://www.home-assistant.io/integrations/switch.mqtt/

func (*Switch) Consume added in v0.0.2

func (c *Switch) Consume(consumer ConfigConsumer, nodeID string, objectID string)

func (*Switch) GetComponent

func (*Switch) GetComponent() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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