Documentation
¶
Index ¶
Constants ¶
const DefaultRootTopic = "homie"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Device ¶
type Device struct {
Name string `mapstructure:"$name"`
State State `mapstructure:"$state"`
Version string `mapstructure:"$homie"`
Implementation string `mapstructure:"$implementation"`
Extensions []string `mapstructure:"_extensions"`
Nodes map[string]*Node `mapstructure:"_nodes"`
}
Device represents a device in terms of the spec
func (*Device) NewNode ¶
NewNode is a conveniece method for creating a new node and attaching it to the device
func (*Device) Publish ¶
Publish publishes the device including nodes/properties to MQTT at the given topic. It's the callers responsibility to ensure correct topic.
func (*Device) Unmarshal ¶
func (d *Device) Unmarshal(subscribe Subscriber, topic string)
type Homie ¶
type Homie struct {
RootTopic string `mapstructure:"_roottopic"`
Devices map[string]*Device `mapstructure:"_devices"`
}
func (*Homie) Unmarshal ¶
func (h *Homie) Unmarshal(subscribe Subscriber)
type Node ¶
type Node struct {
Name string `mapstructure:"$name"`
Type string `mapstructure:"$type"`
Properties map[string]*Property `mapstructure:"_properties"`
}
Node represents a device's node in terms of the spec
func (*Node) Add ¶
Add attaches a property to the node. An error is raised on duplicate property id.
func (*Node) NewProperty ¶
NewProperty is a conveniece method for creating a new property and attaching it to the nodes
func (*Node) Publish ¶
Publish publishes the node including properties to MQTT at the given topic. It's the callers responsibility to ensure correct topic and include node in the parent devices $nodes attribute.
func (*Node) Unmarshal ¶
func (n *Node) Unmarshal(subscribe Subscriber, topic string)
type Property ¶
type Property struct {
Name string `mapstructure:"$name"`
DataType DataType `mapstructure:"$datatype"`
Value string `mapstructure:"_value"`
Format string `mapstructure:"$format"`
Unit string `mapstructure:"$unit"`
Retained bool `mapstructure:"$retained"`
Settable bool `mapstructure:"$settable"`
}
Property represents a node's property according to the spec
func (*Property) Publish ¶
Publish publishes the property to MQTT at the given topic. It's the callers responsibility to ensure correct topic and include the property in the parent nodes $properties attribute.
func (*Property) Unmarshal ¶
func (p *Property) Unmarshal(subscribe Subscriber, topic string)