hass_mqtt

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: MIT Imports: 9 Imported by: 1

README

hass-mqtt

Idea and generation code taken from https://github.com/W-Floyd/ha-mqtt-iot which is a very well done project but setup for a singular use. I wanted to be able to just use Home Assistant Devices/Entities in other programs so extending what was done there.

Massive work in progress right now.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDeviceFound = fmt.Errorf("no device found")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	NodeID string

	OnConnect func(client mqtt.Client)
	// contains filtered or unexported fields
}

func NewClient

func NewClient(c Config) (*Client, error)

func NewClientWithLogger added in v0.2.2

func NewClientWithLogger(c Config, logger logr.Logger) (*Client, error)

func (*Client) Add

func (c *Client) Add(dev *device.Device) error

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) Disconnect

func (c *Client) Disconnect()

func (*Client) Get

func (c *Client) Get(identifier string) *device.Device

func (*Client) Logger added in v0.2.2

func (c *Client) Logger() *logr.Logger

func (*Client) Publish added in v0.2.3

func (c *Client) Publish(topic string, qos byte, retained bool, payload interface{}) mqtt.Token

func (*Client) Subscribe added in v0.2.3

func (c *Client) Subscribe(topic string, qos byte, callback mqtt.MessageHandler) mqtt.Token

Subscribe is a pass-through of MQTT Subscribe

func (*Client) Unsubscribe added in v0.2.3

func (c *Client) Unsubscribe(topics ...string) mqtt.Token

Unsubscribe is a pass-through of MQTT Unsubscribe

type Config

type Config struct {
	NodeID string `json:"node_id" yaml:"node_id"`
	MQTT   struct {
		Host     string  `json:"host" yaml:"host"`
		Port     int     `json:"port" yaml:"port"`
		SSL      bool    `json:"ssl" yaml:"ssl"`
		UserName *string `json:"user_name,omitempty" yaml:"user_name"`
		Password *string `json:"password,omitempty" yaml:"password"`
	} `json:"MQTT" yaml:"mqtt"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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