Documentation
¶
Index ¶
- func MQTTDiscoveryOverride(field reflect.StructField) (string, bool)
- func MQTTOverride(field reflect.StructField) (string, bool)
- func SimpleKVMapParser(kvSep string, itemSep string) func(v string) (interface{}, error)
- type GeneralConfig
- type MQTT
- func (c *MQTT) Initialize() *MQTT
- func (c *MQTT) Publish(topic string, payload string) MQTTMessage
- func (c *MQTT) PublishWithOpts(topic string, payload string, opts MQTTPublishOpts) MQTTMessage
- func (c *MQTT) Run()
- func (c *MQTT) SetConnectHandler(handler func()) *MQTT
- func (c *MQTT) SetDisconnectHandler(handler func()) *MQTT
- func (c *MQTT) SetDiscoveryHandler(handler func() []MQTTDiscovery) *MQTT
- func (c *MQTT) SetReadIncomingChannelHandler(handler func()) *MQTT
- func (c *MQTT) SetSubscribeHandler(handler func()) *MQTT
- func (c *MQTT) Subscribe(topic string, qos byte, callback mqtt.MessageHandler) mqtt.Token
- type MQTTDiscovery
- type MQTTDiscoveryDevice
- type MQTTMessage
- type MQTTOpts
- type MQTTPublishOpts
- type MoqClient
- func (t MoqClient) AddRoute(topic string, callback mqtt.MessageHandler)
- func (t MoqClient) Connect() mqtt.Token
- func (t MoqClient) Disconnect(quiesce uint)
- func (t MoqClient) IsConnected() bool
- func (t MoqClient) IsConnectionOpen() bool
- func (t MoqClient) OptionsReader() mqtt.ClientOptionsReader
- func (t MoqClient) Publish(topic string, qos byte, retained bool, payload interface{}) mqtt.Token
- func (t MoqClient) Subscribe(topic string, qos byte, callback mqtt.MessageHandler) mqtt.Token
- func (t MoqClient) SubscribeMultiple(filters map[string]byte, callback mqtt.MessageHandler) mqtt.Token
- func (t MoqClient) Unsubscribe(topics ...string) mqtt.Token
- type MoqMessage
- type MoqToken
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MQTTDiscoveryOverride ¶
func MQTTDiscoveryOverride(field reflect.StructField) (string, bool)
MQTTDiscoveryOverride -
Types ¶
type GeneralConfig ¶
type GeneralConfig struct {
DebugLogLevel bool `env:"DEBUG" envDefault:"false"`
}
GeneralConfig - Configuration applicable to the genereal application
type MQTT ¶ added in v0.4.5
type MQTT struct { MQTTOpts // contains filtered or unexported fields }
MQTT - A wrapper for the Paho MQTT
func (*MQTT) Initialize ¶ added in v0.4.5
Initialize - Initialize the MQTT Client with all the appropriate settings
func (*MQTT) Publish ¶ added in v0.4.5
func (c *MQTT) Publish(topic string, payload string) MQTTMessage
Publish - Publish a topic and payload with default options
func (*MQTT) PublishWithOpts ¶ added in v0.4.5
func (c *MQTT) PublishWithOpts(topic string, payload string, opts MQTTPublishOpts) MQTTMessage
PublishWithOpts - Publish a topic and payload with specific options
func (*MQTT) SetConnectHandler ¶ added in v0.4.5
SetConnectHandler - Sets the function to be called at the end of a successful MQTT connection
func (*MQTT) SetDisconnectHandler ¶ added in v0.4.5
SetDisconnectHandler - Sets the function to be called at the end of a successful MQTT connection
func (*MQTT) SetDiscoveryHandler ¶ added in v0.4.5
func (c *MQTT) SetDiscoveryHandler(handler func() []MQTTDiscovery) *MQTT
SetDiscoveryHandler - Sets the function to be called when it's time to publish MQTT discovery messages
func (*MQTT) SetReadIncomingChannelHandler ¶ added in v0.4.5
SetReadIncomingChannelHandler - Sets the function to be called when it's time to subscribe to MQTT topics
func (*MQTT) SetSubscribeHandler ¶ added in v0.4.5
SetSubscribeHandler - Sets the function to be called when it's time to subscribe to MQTT topics
type MQTTDiscovery ¶
type MQTTDiscovery struct { // Used for topic generation; never output in discovery JSON DiscoveryName string `json:"-"` DiscoveryPrefix string `json:"-"` Component string `json:"-"` NodeID string `json:"-"` ObjectID string `json:"-"` // Used in discovery JSON AuxCommandTopic string `json:"aux_command_topic,omitempty"` AuxStateTemplate string `json:"aux_state_template,omitempty"` AuxStateTopic string `json:"aux_state_topic,omitempty"` AvailabilityTopic string `json:"availability_topic,omitempty"` AwayModeCommandTopic string `json:"away_mode_command_topic,omitempty"` AwayModeStateTemplate string `json:"away_mode_state_template,omitempty"` AwayModeStateTopic string `json:"away_mode_state_topic,omitempty"` BrightnessCommandTopic string `json:"brightness_command_topic,omitempty"` BrightnessScale string `json:"brightness_scale,omitempty"` BrightnessStateTopic string `json:"brightness_state_topic,omitempty"` BrightnessValueTemplate string `json:"brightness_value_template,omitempty"` ColorTempCommandTopic string `json:"color_temp_command_topic,omitempty"` ColorTempStateTopic string `json:"color_temp_state_topic,omitempty"` ColorTempValueTemplate string `json:"color_temp_value_template,omitempty"` CommandTopic string `json:"command_topic,omitempty"` CurrentTemperatureTopic string `json:"current_temperature_topic,omitempty"` Device MQTTDiscoveryDevice `json:"device,omitempty"` DeviceClass string `json:"device_class,omitempty"` EffectCommandTopic string `json:"effect_command_topic,omitempty"` EffectList string `json:"effect_list,omitempty"` EffectStateTopic string `json:"effect_state_topic,omitempty"` EffectValueTemplate string `json:"effect_value_template,omitempty"` ExpireAfter string `json:"expire_after,omitempty"` FanModeCommandTopic string `json:"fan_mode_command_topic,omitempty"` FanModeStateTemplate string `json:"fan_mode_state_template,omitempty"` FanModeStateTopic string `json:"fan_mode_state_topic,omitempty"` ForceUpdate string `json:"force_update,omitempty"` HoldCommandTopic string `json:"hold_command_topic,omitempty"` HoldStateTemplate string `json:"hold_state_template,omitempty"` HoldStateTopic string `json:"hold_state_topic,omitempty"` Icon string `json:"icon,omitempty"` Initial string `json:"initial,omitempty"` JSONAttributesTopic string `json:"json_attributes_topic,omitempty"` JSONAttributes string `json:"json_attributes,omitempty"` MaxTemp string `json:"max_temp,omitempty"` MinTemp string `json:"min_temp,omitempty"` ModeCommandTopic string `json:"mode_command_topic,omitempty"` ModeStateTemplate string `json:"mode_state_template,omitempty"` ModeStateTopic string `json:"mode_state_topic,omitempty"` Name string `json:"name,omitempty"` OnCommandType string `json:"on_command_type,omitempty"` Optimistic string `json:"optimistic,omitempty"` OscillationCommandTopic string `json:"oscillation_command_topic,omitempty"` OscillationStateTopic string `json:"oscillation_state_topic,omitempty"` OscillationValueTemplate string `json:"oscillation_value_template,omitempty"` PayloadArmAway string `json:"payload_arm_away,omitempty"` PayloadArmHome string `json:"payload_arm_home,omitempty"` PayloadAvailable string `json:"payload_available,omitempty"` PayloadClose string `json:"payload_close,omitempty"` PayloadDisarm string `json:"payload_disarm,omitempty"` PayloadHighSpeed string `json:"payload_high_speed,omitempty"` PayloadLock string `json:"payload_lock,omitempty"` PayloadLowSpeed string `json:"payload_low_speed,omitempty"` PayloadMediumSpeed string `json:"payload_medium_speed,omitempty"` PayloadNotAvailable string `json:"payload_not_available,omitempty"` PayloadOff string `json:"payload_off,omitempty"` PayloadOn string `json:"payload_on,omitempty"` PayloadOpen string `json:"payload_open,omitempty"` PayloadOscillationOff string `json:"payload_oscillation_off,omitempty"` PayloadOscillationOn string `json:"payload_oscillation_on,omitempty"` PayloadStop string `json:"payload_stop,omitempty"` PayloadUnlock string `json:"payload_unlock,omitempty"` PowerCommandTopic string `json:"power_command_topic,omitempty"` Retain string `json:"retain,omitempty"` RgbCommandTemplate string `json:"rgb_command_template,omitempty"` RgbCommandTopic string `json:"rgb_command_topic,omitempty"` RgbStateTopic string `json:"rgb_state_topic,omitempty"` RgbValueTemplate string `json:"rgb_value_template,omitempty"` SendIfOff string `json:"send_if_off,omitempty"` SetPositionTemplate string `json:"set_position_template,omitempty"` SetPositionTopic string `json:"set_position_topic,omitempty"` SpeedCommandTopic string `json:"speed_command_topic,omitempty"` SpeedStateTopic string `json:"speed_state_topic,omitempty"` SpeedValueTemplate string `json:"speed_value_template,omitempty"` Speeds string `json:"speeds,omitempty"` StateClosed string `json:"state_closed,omitempty"` StateOff string `json:"state_off,omitempty"` StateOn string `json:"state_on,omitempty"` StateOpen string `json:"state_open,omitempty"` StateTopic string `json:"state_topic,omitempty"` StateValueTemplate string `json:"state_value_template,omitempty"` SwingModeCommandTopic string `json:"swing_mode_command_topic,omitempty"` SwingModeStateTemplate string `json:"swing_mode_state_template,omitempty"` SwingModeStateTopic string `json:"swing_mode_state_topic,omitempty"` TemperatureCommandTopic string `json:"temperature_command_topic,omitempty"` TemperatureStateTemplate string `json:"temperature_state_template,omitempty"` TemperatureStateTopic string `json:"temperature_state_topic,omitempty"` TiltClosedValue string `json:"tilt_closed_value,omitempty"` TiltCommandTopic string `json:"tilt_command_topic,omitempty"` TiltInvertState string `json:"tilt_invert_state,omitempty"` TiltMax string `json:"tilt_max,omitempty"` TiltMin string `json:"tilt_min,omitempty"` TiltOpenedValue string `json:"tilt_opened_value,omitempty"` TiltStatusOptimistic string `json:"tilt_status_optimistic,omitempty"` TiltStatusTopic string `json:"tilt_status_topic,omitempty"` Topic string `json:"topic,omitempty"` UniqueID string `json:"unique_id,omitempty"` UnitOfMeasurement string `json:"unit_of_measurement,omitempty"` ValueTemplate string `json:"value_template,omitempty"` WhiteValueCommandTopic string `json:"white_value_command_topic,omitempty"` WhiteValueStateTopic string `json:"white_value_state_topic,omitempty"` WhiteValueTemplate string `json:"white_value_template,omitempty"` XyCommandTopic string `json:"xy_command_topic,omitempty"` XyStateTopic string `json:"xy_state_topic,omitempty"` XyValueTemplate string `json:"xy_value_template,omitempty"` }
MQTTDiscovery - Aid creating/publishing Home-Assistant MQTT Discovery.
func NewMQTTDiscovery ¶ added in v0.4.5
func NewMQTTDiscovery(proxyConfig MQTTOpts, deviceName string, sensorName string, sensorType string) *MQTTDiscovery
NewMQTTDiscovery - Create a new MQTTDiscovery object
type MQTTDiscoveryDevice ¶ added in v0.3.1
type MQTTDiscoveryDevice 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"` }
MQTTDiscoveryDevice - Contains the Device properties for MQTT Discovery.
type MQTTMessage ¶ added in v0.4.5
MQTTMessage - The result of a publish action
type MQTTOpts ¶ added in v0.4.5
type MQTTOpts struct { ClientID string `env:"MQTT_CLIENTID"` Broker string `env:"MQTT_BROKER" envDefault:"tcp://test.mosquitto.org:1883"` Username string `env:"MQTT_USERNAME"` Password string `env:"MQTT_PASSWORD"` TopicPrefix string `env:"MQTT_TOPICPREFIX"` Discovery bool `env:"MQTT_DISCOVERY" envDefault:"false"` DiscoveryPrefix string `env:"MQTT_DISCOVERYPREFIX" envDefault:"homeassistant"` DiscoveryName string `env:"MQTT_DISCOVERYNAME"` }
MQTTOpts - Configuration applicable to the MQTTProxy
func (*MQTTOpts) AvailabilityTopic ¶ added in v0.4.5
AvailabilityTopic - Generate the availability topic
func (*MQTTOpts) CommandTopic ¶ added in v0.4.5
CommandTopic - Generate the command topic for a named sensor
type MQTTPublishOpts ¶ added in v0.4.5
MQTTPublishOpts - MQTTProxy Publish Options
type MoqClient ¶ added in v0.4.6
type MoqClient struct{}
MoqClient - Aid testing MQTT callbacks
func (MoqClient) AddRoute ¶ added in v0.4.6
func (t MoqClient) AddRoute(topic string, callback mqtt.MessageHandler)
AddRoute - I'm just here so I don't get fined
func (MoqClient) Disconnect ¶ added in v0.4.6
Disconnect - I'm just here so I don't get fined
func (MoqClient) IsConnected ¶ added in v0.4.6
IsConnected - I'm just here so I don't get fined
func (MoqClient) IsConnectionOpen ¶ added in v0.4.6
IsConnectionOpen - I'm just here so I don't get fined
func (MoqClient) OptionsReader ¶ added in v0.4.6
func (t MoqClient) OptionsReader() mqtt.ClientOptionsReader
OptionsReader - I'm just here so I don't get fined
func (MoqClient) SubscribeMultiple ¶ added in v0.4.6
func (t MoqClient) SubscribeMultiple(filters map[string]byte, callback mqtt.MessageHandler) mqtt.Token
SubscribeMultiple - I'm just here so I don't get fined
type MoqMessage ¶
MoqMessage - Aid testing MQTT callbacks
func (*MoqMessage) Duplicate ¶
func (m *MoqMessage) Duplicate() bool
Duplicate - I'm just here so I don't get fined
func (*MoqMessage) MessageID ¶
func (m *MoqMessage) MessageID() uint16
MessageID - I'm just here so I don't get fined
func (*MoqMessage) Payload ¶
func (m *MoqMessage) Payload() []byte
Payload - I'm just here so I don't get fined
func (*MoqMessage) Retained ¶
func (m *MoqMessage) Retained() bool
Retained - I'm just here so I don't get fined
func (*MoqMessage) Topic ¶
func (m *MoqMessage) Topic() string
Topic - I'm just here so I don't get fined