Documentation
¶
Index ¶
- func WithDeviceClass(deviceClass string) addValueOption
- func WithIcon(icon string) addValueOption
- func WithSensorID(id string) newMQTTSensorOption
- func WithSensorValueID(id string) addValueOption
- func WithUnitOfMeasurement(unitOfMeasurement string) addValueOption
- type MQTTPublisher
- type MQTTPublisherFunc
- type MQTTSensor
- type MQTTSensorValue
- type Sensor
- type SensorValue
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithDeviceClass ¶
func WithDeviceClass(deviceClass string) addValueOption
WithDeviceClass to set a device class for the sensor value (see: https://www.home-assistant.io/integrations/sensor/#device-class)
func WithIcon ¶
func WithIcon(icon string) addValueOption
WithUnitAndIcon can be used alternatively to WithDeviceClass to add a custom unit and icon
func WithSensorID ¶
func WithSensorID(id string) newMQTTSensorOption
func WithSensorValueID ¶
func WithSensorValueID(id string) addValueOption
func WithUnitOfMeasurement ¶
func WithUnitOfMeasurement(unitOfMeasurement string) addValueOption
WithUnitAndIcon can be used alternatively to WithDeviceClass to add a custom unit and icon
Types ¶
type MQTTPublisher ¶
type MQTTPublisherFunc ¶
MQTTPublisherFunc type is an adapter to allow the use of ordinary functions as MQTT publisher. If f is a fuction with the appropriate signature, MQTTPublisherFunc(f) is a MQTTPublisher that calls f
type MQTTSensor ¶
type MQTTSensor struct {
// contains filtered or unexported fields
}
func NewMQTTSensor ¶
func NewMQTTSensor(client MQTTPublisher, sensorName string, opts ...newMQTTSensorOption) *MQTTSensor
func (*MQTTSensor) AddValue ¶
func (ms *MQTTSensor) AddValue(valueName string, opts ...addValueOption) MQTTSensorValue
AddValue adds a new mqtt value to the mqtt sensor
type MQTTSensorValue ¶
type MQTTSensorValue interface {
SensorValue
// Update and publish a sensor value
Update(float64)
// PublishConfig sends autodiscover configuration that can be understood by home assistant
PublishConfig()
}
type Sensor ¶
type Sensor interface {
// Name returns the sensor name
Name() string
// ID returns the sensor id (consists only of the following characters: [a-zA-Z0-9_-])
ID() string
}
Sensor interface
type SensorValue ¶
Click to show internal directories.
Click to hide internal directories.