hass

package
v11.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoStateCallback   = errors.New("no state callback function")
	ErrNoCommandCallback = errors.New("no command callback function")
)
View Source
var HomeAssistantTopic = "homeassistant"

HomeAssistantTopic is the prefix applied to all entity topics by default. Typically, this defaults to "homeassistant". It is exposed by this package such that it can be overridden as necessary.

Functions

func FormatID

func FormatID(s string) string

FormatID will take a string s and format it as snake_case. The new string is then an appropriate format to be used as a unique ID in Home Assistant.

func FormatName

func FormatName(s string) string

FormatName will take a string s and format it with appropriate spacing between words and capitalised the first letter of each word. For example someString becomes Some String. The new string is then an appropriate format to be used as a name in Home Assistant.

func NewEntity

func NewEntity(app, name, id string) *entity

NewEntity creates a minimal entity based on the given name and id and associates it with the given app. Additional builder functions should be chained to fill out functionality that the entity will provide.

Types

type BinarySensorEntity

type BinarySensorEntity struct {
	// contains filtered or unexported fields
}

BinarySensorEntity represents an entity which has a boolean state. For more details, see https://www.home-assistant.io/integrations/binary_sensor.mqtt/

func AsBinarySensor

func AsBinarySensor(entity *entity) *BinarySensorEntity

AsBinarySensor converts the given entity into a BinarySensorEntity. Additional builders can potentially be applied to customise it further.

func (BinarySensorEntity) AsDiagnostic

func (e BinarySensorEntity) AsDiagnostic() *entity

AsDiagnostic will mark this entity as a diagnostic entity in Home Assistant.

func (BinarySensorEntity) GetTopics

func (e BinarySensorEntity) GetTopics() *Topics

GetTopics returns a Topic struct containing the topics configured for this entity. If an entity does not have a particular topic (due to not having some functionality), the topic value will be an empty string.

func (BinarySensorEntity) MarshalAttributes

func (e BinarySensorEntity) MarshalAttributes(args ...any) (*mqttapi.Msg, error)

MarshalAttributes will generate an *mqtt.Msg for the attributes of an entity, that can be used for updating the entity's attributes.

func (BinarySensorEntity) MarshalConfig

func (e BinarySensorEntity) MarshalConfig() (*mqttapi.Msg, error)

func (BinarySensorEntity) MarshalState

func (e BinarySensorEntity) MarshalState(args ...any) (*mqttapi.Msg, error)

MarshalState will generate an *mqtt.Msg for a given entity, that can be used to publish the entity's state to the MQTT bus.

func (BinarySensorEntity) MarshalSubscription

func (e BinarySensorEntity) MarshalSubscription() (*mqttapi.Subscription, error)

MarshallSubscription will generate an *mqtt.Subscription for a given entity, which can be used to subscribe to an entity's command topic and execute a callback on messages.

func (BinarySensorEntity) WithAttributesCallback

func (e BinarySensorEntity) WithAttributesCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithAttributesCallback will add the passed in function as the callback action to be run whenever the attributes of the entity are needed. If this callback is to be used, then the WithAttributesTopic() builder function should also be called to set-up the attributes topic.

func (BinarySensorEntity) WithAttributesTemplate

func (e BinarySensorEntity) WithAttributesTemplate(t string) *entity

WithAttributesTemplate configures the passed in template to be used to extract the value of the attributes in Home Assistant.

func (BinarySensorEntity) WithCommandCallback

func (e BinarySensorEntity) WithCommandCallback(c func(p *paho.Publish)) *entity

WithCommandCallback will add the passed in function as the callback action to be run when a message is received on the command topic of the entity. It doesn't make sense to add this for entities that don't have a command topic, like regular sensors.

func (BinarySensorEntity) WithDefaultOriginInfo

func (e BinarySensorEntity) WithDefaultOriginInfo() *entity

WithOriginInfo adds a pre-filled origin that references go-hass-agent to the entity config.

func (BinarySensorEntity) WithDeviceClass

func (e BinarySensorEntity) WithDeviceClass(d string) *entity

WithDeviceClass configures the Device Class for the entity.

func (BinarySensorEntity) WithDeviceInfo

func (e BinarySensorEntity) WithDeviceInfo(d *Device) *entity

WithDeviceInfo adds the passed in device info to the entity config.

func (BinarySensorEntity) WithIcon

func (e BinarySensorEntity) WithIcon(i string) *entity

WithIcon adds an icon to the entity.

func (BinarySensorEntity) WithNodeID

func (e BinarySensorEntity) WithNodeID(id string) *entity

WithNodeID adds an additional section to the topics of the entity in MQTT. It can be used to help structure various entities being provided.

func (BinarySensorEntity) WithOriginInfo

func (e BinarySensorEntity) WithOriginInfo(o *Origin) *entity

WithOriginInfo adds the passed in origin info to the entity config.

func (BinarySensorEntity) WithStateCallback

func (e BinarySensorEntity) WithStateCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithStateCallback will add the passed in function as the callback action to be run whenever the state of the entity is needed. It doesn't make sense to add this for entities that don't report a state, like buttons. It might not be useful to use this where you have a single state that represents many entities. In such cases, it would be better to manually send the state in your own code.

func (BinarySensorEntity) WithStateClassMeasurement

func (e BinarySensorEntity) WithStateClassMeasurement() *entity

WithStateClassMeasurement configures the State Class for the entity to be "measurement".

func (BinarySensorEntity) WithStateClassTotal

func (e BinarySensorEntity) WithStateClassTotal() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total".

func (BinarySensorEntity) WithStateClassTotalIncreasing

func (e BinarySensorEntity) WithStateClassTotalIncreasing() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total_increasing".

func (BinarySensorEntity) WithStateExpiry

func (e BinarySensorEntity) WithStateExpiry(i int) *entity

WithStateExpiry defines the number of seconds after the sensor’s state expires, if it’s not updated. After expiry, the sensor’s state becomes "unavailable".

func (BinarySensorEntity) WithUnits

func (e BinarySensorEntity) WithUnits(u string) *entity

WithUnits adds a unit of measurement to the entity.

func (BinarySensorEntity) WithValueTemplate

func (e BinarySensorEntity) WithValueTemplate(t string) *entity

WithValueTemplate configures the passed in template to be used to extract the value of the entity in Home Assistant.

type ButtonEntity

type ButtonEntity struct {
	// contains filtered or unexported fields
}

ButtonEntity represents an entity which can perform some action or event in response to being "pushed". For more details, see https://www.home-assistant.io/integrations/button.mqtt/

func AsButton

func AsButton(entity *entity) *ButtonEntity

AsButton converts the given entity into a ButtonEntity. Additional builders can potentially be applied to customise it further.

func (ButtonEntity) AsDiagnostic

func (e ButtonEntity) AsDiagnostic() *entity

AsDiagnostic will mark this entity as a diagnostic entity in Home Assistant.

func (ButtonEntity) GetTopics

func (e ButtonEntity) GetTopics() *Topics

GetTopics returns a Topic struct containing the topics configured for this entity. If an entity does not have a particular topic (due to not having some functionality), the topic value will be an empty string.

func (ButtonEntity) MarshalAttributes

func (e ButtonEntity) MarshalAttributes(args ...any) (*mqttapi.Msg, error)

MarshalAttributes will generate an *mqtt.Msg for the attributes of an entity, that can be used for updating the entity's attributes.

func (ButtonEntity) MarshalConfig

func (e ButtonEntity) MarshalConfig() (*mqttapi.Msg, error)

func (ButtonEntity) MarshalState

func (e ButtonEntity) MarshalState(args ...any) (*mqttapi.Msg, error)

MarshalState will generate an *mqtt.Msg for a given entity, that can be used to publish the entity's state to the MQTT bus.

func (ButtonEntity) MarshalSubscription

func (e ButtonEntity) MarshalSubscription() (*mqttapi.Subscription, error)

MarshallSubscription will generate an *mqtt.Subscription for a given entity, which can be used to subscribe to an entity's command topic and execute a callback on messages.

func (ButtonEntity) WithAttributesCallback

func (e ButtonEntity) WithAttributesCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithAttributesCallback will add the passed in function as the callback action to be run whenever the attributes of the entity are needed. If this callback is to be used, then the WithAttributesTopic() builder function should also be called to set-up the attributes topic.

func (ButtonEntity) WithAttributesTemplate

func (e ButtonEntity) WithAttributesTemplate(t string) *entity

WithAttributesTemplate configures the passed in template to be used to extract the value of the attributes in Home Assistant.

func (ButtonEntity) WithCommandCallback

func (e ButtonEntity) WithCommandCallback(c func(p *paho.Publish)) *entity

WithCommandCallback will add the passed in function as the callback action to be run when a message is received on the command topic of the entity. It doesn't make sense to add this for entities that don't have a command topic, like regular sensors.

func (ButtonEntity) WithDefaultOriginInfo

func (e ButtonEntity) WithDefaultOriginInfo() *entity

WithOriginInfo adds a pre-filled origin that references go-hass-agent to the entity config.

func (ButtonEntity) WithDeviceClass

func (e ButtonEntity) WithDeviceClass(d string) *entity

WithDeviceClass configures the Device Class for the entity.

func (ButtonEntity) WithDeviceInfo

func (e ButtonEntity) WithDeviceInfo(d *Device) *entity

WithDeviceInfo adds the passed in device info to the entity config.

func (ButtonEntity) WithIcon

func (e ButtonEntity) WithIcon(i string) *entity

WithIcon adds an icon to the entity.

func (ButtonEntity) WithNodeID

func (e ButtonEntity) WithNodeID(id string) *entity

WithNodeID adds an additional section to the topics of the entity in MQTT. It can be used to help structure various entities being provided.

func (ButtonEntity) WithOriginInfo

func (e ButtonEntity) WithOriginInfo(o *Origin) *entity

WithOriginInfo adds the passed in origin info to the entity config.

func (ButtonEntity) WithStateCallback

func (e ButtonEntity) WithStateCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithStateCallback will add the passed in function as the callback action to be run whenever the state of the entity is needed. It doesn't make sense to add this for entities that don't report a state, like buttons. It might not be useful to use this where you have a single state that represents many entities. In such cases, it would be better to manually send the state in your own code.

func (ButtonEntity) WithStateClassMeasurement

func (e ButtonEntity) WithStateClassMeasurement() *entity

WithStateClassMeasurement configures the State Class for the entity to be "measurement".

func (ButtonEntity) WithStateClassTotal

func (e ButtonEntity) WithStateClassTotal() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total".

func (ButtonEntity) WithStateClassTotalIncreasing

func (e ButtonEntity) WithStateClassTotalIncreasing() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total_increasing".

func (ButtonEntity) WithStateExpiry

func (e ButtonEntity) WithStateExpiry(i int) *entity

WithStateExpiry defines the number of seconds after the sensor’s state expires, if it’s not updated. After expiry, the sensor’s state becomes "unavailable".

func (ButtonEntity) WithUnits

func (e ButtonEntity) WithUnits(u string) *entity

WithUnits adds a unit of measurement to the entity.

func (ButtonEntity) WithValueTemplate

func (e ButtonEntity) WithValueTemplate(t string) *entity

WithValueTemplate configures the passed in template to be used to extract the value of the entity in Home Assistant.

type CameraEntity added in v11.1.0

type CameraEntity struct {
	Encoding      string `json:"encoding,omitempty"`
	ImageEncoding string `json:"image_encoding,omitempty"`
	Topic         string `json:"topic"`
	// contains filtered or unexported fields
}

CameraEntity represents an entity which sends image files through MQTT. For more details, see https://www.home-assistant.io/integrations/camera.mqtt/

func AsCamera added in v11.1.0

func AsCamera(entity *entity) *CameraEntity

AsCamera converts the given entity into a CameraEntity. The min, max parameters do not need to be specified (default min: 0, default max: 255).

func (CameraEntity) AsDiagnostic added in v11.1.0

func (e CameraEntity) AsDiagnostic() *entity

AsDiagnostic will mark this entity as a diagnostic entity in Home Assistant.

func (CameraEntity) GetTopics added in v11.1.0

func (e CameraEntity) GetTopics() *Topics

GetTopics returns a Topic struct containing the topics configured for this entity. If an entity does not have a particular topic (due to not having some functionality), the topic value will be an empty string.

func (CameraEntity) MarshalAttributes added in v11.1.0

func (e CameraEntity) MarshalAttributes(args ...any) (*mqttapi.Msg, error)

MarshalAttributes will generate an *mqtt.Msg for the attributes of an entity, that can be used for updating the entity's attributes.

func (*CameraEntity) MarshalConfig added in v11.1.0

func (entity *CameraEntity) MarshalConfig() (*mqttapi.Msg, error)

func (CameraEntity) MarshalState added in v11.1.0

func (e CameraEntity) MarshalState(args ...any) (*mqttapi.Msg, error)

MarshalState will generate an *mqtt.Msg for a given entity, that can be used to publish the entity's state to the MQTT bus.

func (CameraEntity) MarshalSubscription added in v11.1.0

func (e CameraEntity) MarshalSubscription() (*mqttapi.Subscription, error)

MarshallSubscription will generate an *mqtt.Subscription for a given entity, which can be used to subscribe to an entity's command topic and execute a callback on messages.

func (CameraEntity) WithAttributesCallback added in v11.1.0

func (e CameraEntity) WithAttributesCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithAttributesCallback will add the passed in function as the callback action to be run whenever the attributes of the entity are needed. If this callback is to be used, then the WithAttributesTopic() builder function should also be called to set-up the attributes topic.

func (CameraEntity) WithAttributesTemplate added in v11.1.0

func (e CameraEntity) WithAttributesTemplate(t string) *entity

WithAttributesTemplate configures the passed in template to be used to extract the value of the attributes in Home Assistant.

func (CameraEntity) WithCommandCallback added in v11.1.0

func (e CameraEntity) WithCommandCallback(c func(p *paho.Publish)) *entity

WithCommandCallback will add the passed in function as the callback action to be run when a message is received on the command topic of the entity. It doesn't make sense to add this for entities that don't have a command topic, like regular sensors.

func (CameraEntity) WithDefaultOriginInfo added in v11.1.0

func (e CameraEntity) WithDefaultOriginInfo() *entity

WithOriginInfo adds a pre-filled origin that references go-hass-agent to the entity config.

func (CameraEntity) WithDeviceClass added in v11.1.0

func (e CameraEntity) WithDeviceClass(d string) *entity

WithDeviceClass configures the Device Class for the entity.

func (CameraEntity) WithDeviceInfo added in v11.1.0

func (e CameraEntity) WithDeviceInfo(d *Device) *entity

WithDeviceInfo adds the passed in device info to the entity config.

func (*CameraEntity) WithEncoding added in v11.1.0

func (entity *CameraEntity) WithEncoding(encoding string) *CameraEntity

WithEncoding sets the encoding of the payloads. By default, a CameraEntity publishes raw binary data on the topic.

func (CameraEntity) WithIcon added in v11.1.0

func (e CameraEntity) WithIcon(i string) *entity

WithIcon adds an icon to the entity.

func (*CameraEntity) WithImageEncoding added in v11.1.0

func (entity *CameraEntity) WithImageEncoding(encoding string) *CameraEntity

WithImageEncoding sets the image encoding of the payloads. By default, a CameraEntity publishes images as raw binary data on the topic. Setting a special value of "b64" is used by Home Assistant to represent base64 encoding of images.

func (CameraEntity) WithNodeID added in v11.1.0

func (e CameraEntity) WithNodeID(id string) *entity

WithNodeID adds an additional section to the topics of the entity in MQTT. It can be used to help structure various entities being provided.

func (CameraEntity) WithOriginInfo added in v11.1.0

func (e CameraEntity) WithOriginInfo(o *Origin) *entity

WithOriginInfo adds the passed in origin info to the entity config.

func (CameraEntity) WithStateCallback added in v11.1.0

func (e CameraEntity) WithStateCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithStateCallback will add the passed in function as the callback action to be run whenever the state of the entity is needed. It doesn't make sense to add this for entities that don't report a state, like buttons. It might not be useful to use this where you have a single state that represents many entities. In such cases, it would be better to manually send the state in your own code.

func (CameraEntity) WithStateClassMeasurement added in v11.1.0

func (e CameraEntity) WithStateClassMeasurement() *entity

WithStateClassMeasurement configures the State Class for the entity to be "measurement".

func (CameraEntity) WithStateClassTotal added in v11.1.0

func (e CameraEntity) WithStateClassTotal() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total".

func (CameraEntity) WithStateClassTotalIncreasing added in v11.1.0

func (e CameraEntity) WithStateClassTotalIncreasing() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total_increasing".

func (CameraEntity) WithStateExpiry added in v11.1.0

func (e CameraEntity) WithStateExpiry(i int) *entity

WithStateExpiry defines the number of seconds after the sensor’s state expires, if it’s not updated. After expiry, the sensor’s state becomes "unavailable".

func (CameraEntity) WithUnits added in v11.1.0

func (e CameraEntity) WithUnits(u string) *entity

WithUnits adds a unit of measurement to the entity.

func (CameraEntity) WithValueTemplate added in v11.1.0

func (e CameraEntity) WithValueTemplate(t string) *entity

WithValueTemplate configures the passed in template to be used to extract the value of the entity in Home Assistant.

type Device

type Device struct {
	Name          string   `json:"name"`
	Manufacturer  string   `json:"manufacturer,omitempty"`
	Model         string   `json:"model,omitempty"`
	HWVersion     string   `json:"hw_version,omitempty"`
	SWVersion     string   `json:"sw_version,omitempty"`
	URL           string   `json:"configuration_url,omitempty"`
	SuggestedArea string   `json:"suggested_area,omitempty"`
	Identifiers   []string `json:"identifiers"`
	Connections   []string `json:"connections,omitempty"`
}

Device contains information about the device an entity is a part of to tie it into the device registry in Home Assistant.

type EntityConstraint

type EntityConstraint[T constraints.Ordered] interface {
	~*SensorEntity | ~*BinarySensorEntity | ~*ButtonEntity | ~*NumberEntity[T] | ~*SwitchEntity
}

type EntityType

type EntityType int
const (
	Unknown EntityType = iota // unknown
	// An entity with some kind of value, numeric or string.
	Sensor // sensor
	// An entity with a boolean value.
	BinarySensor // binary_sensor
	// An entity that changes state when activated.
	Button // button
	// An entity that is a number (float or int) with a range of values.
	Number // number
	// An entity that changes state between ON and OFF.
	Switch // switch
	// An entity that can show/set a string of text.
	Text // text
	// Any entity that can send images.
	Camera // camera
	// Any entity that can send images.
	Image // image
)

func (EntityType) String

func (i EntityType) String() string

type ImageEntity added in v11.1.0

type ImageEntity struct {
	Encoding      string `json:"encoding,omitempty"`
	ImageEncoding string `json:"image_encoding,omitempty"`
	ImageTopic    string `json:"image_topic,omitempty"`
	ContentType   string `json:"content_type,omitempty"`
	URLTopic      string `json:"url_topic,omitempty"`
	URLTemplate   string `json:"url_template,omitempty"`
	// contains filtered or unexported fields
}

ImageEntity represents an entity which sends image files through MQTT. For more details, see https://www.home-assistant.io/integrations/image.mqtt/

func AsImage added in v11.1.0

func AsImage(entity *entity, mode ImageMode) *ImageEntity

AsImage converts the given entity into a ImageEntity. A mode can be specified that controls how the entity will be handled by Home Assistant. Mode "Image" expects an image file as the contents of the entity's state topic. Mode "URL" expects a URL. The default value of mode is "Image".

func (ImageEntity) AsDiagnostic added in v11.1.0

func (e ImageEntity) AsDiagnostic() *entity

AsDiagnostic will mark this entity as a diagnostic entity in Home Assistant.

func (*ImageEntity) GetImageTopic added in v11.1.0

func (entity *ImageEntity) GetImageTopic() string

GetImageTopic returns the topic on which images will appear on MQTT.

func (ImageEntity) GetTopics added in v11.1.0

func (e ImageEntity) GetTopics() *Topics

GetTopics returns a Topic struct containing the topics configured for this entity. If an entity does not have a particular topic (due to not having some functionality), the topic value will be an empty string.

func (ImageEntity) MarshalAttributes added in v11.1.0

func (e ImageEntity) MarshalAttributes(args ...any) (*mqttapi.Msg, error)

MarshalAttributes will generate an *mqtt.Msg for the attributes of an entity, that can be used for updating the entity's attributes.

func (*ImageEntity) MarshalConfig added in v11.1.0

func (entity *ImageEntity) MarshalConfig() (*mqttapi.Msg, error)

func (ImageEntity) MarshalState added in v11.1.0

func (e ImageEntity) MarshalState(args ...any) (*mqttapi.Msg, error)

MarshalState will generate an *mqtt.Msg for a given entity, that can be used to publish the entity's state to the MQTT bus.

func (ImageEntity) MarshalSubscription added in v11.1.0

func (e ImageEntity) MarshalSubscription() (*mqttapi.Subscription, error)

MarshallSubscription will generate an *mqtt.Subscription for a given entity, which can be used to subscribe to an entity's command topic and execute a callback on messages.

func (ImageEntity) WithAttributesCallback added in v11.1.0

func (e ImageEntity) WithAttributesCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithAttributesCallback will add the passed in function as the callback action to be run whenever the attributes of the entity are needed. If this callback is to be used, then the WithAttributesTopic() builder function should also be called to set-up the attributes topic.

func (ImageEntity) WithAttributesTemplate added in v11.1.0

func (e ImageEntity) WithAttributesTemplate(t string) *entity

WithAttributesTemplate configures the passed in template to be used to extract the value of the attributes in Home Assistant.

func (ImageEntity) WithCommandCallback added in v11.1.0

func (e ImageEntity) WithCommandCallback(c func(p *paho.Publish)) *entity

WithCommandCallback will add the passed in function as the callback action to be run when a message is received on the command topic of the entity. It doesn't make sense to add this for entities that don't have a command topic, like regular sensors.

func (*ImageEntity) WithContentType added in v11.1.0

func (entity *ImageEntity) WithContentType(ctype string) *ImageEntity

WithContentType defines what kind of image format the message body is using. For example, "image/png" or "image/jpeg".

func (ImageEntity) WithDefaultOriginInfo added in v11.1.0

func (e ImageEntity) WithDefaultOriginInfo() *entity

WithOriginInfo adds a pre-filled origin that references go-hass-agent to the entity config.

func (ImageEntity) WithDeviceClass added in v11.1.0

func (e ImageEntity) WithDeviceClass(d string) *entity

WithDeviceClass configures the Device Class for the entity.

func (ImageEntity) WithDeviceInfo added in v11.1.0

func (e ImageEntity) WithDeviceInfo(d *Device) *entity

WithDeviceInfo adds the passed in device info to the entity config.

func (*ImageEntity) WithEncoding added in v11.1.0

func (entity *ImageEntity) WithEncoding(encoding string) *ImageEntity

WithEncoding sets the encoding of the payloads. By default, a ImageEntity publishes raw binary data on the topic.

func (ImageEntity) WithIcon added in v11.1.0

func (e ImageEntity) WithIcon(i string) *entity

WithIcon adds an icon to the entity.

func (*ImageEntity) WithImageEncoding added in v11.1.0

func (entity *ImageEntity) WithImageEncoding(encoding string) *ImageEntity

WithImageEncoding sets the image encoding of the payloads. By default, a ImageEntity publishes images as raw binary data on the topic. Setting a special value of "b64" is used by Home Assistant to represent base64 encoding of images.

func (ImageEntity) WithNodeID added in v11.1.0

func (e ImageEntity) WithNodeID(id string) *entity

WithNodeID adds an additional section to the topics of the entity in MQTT. It can be used to help structure various entities being provided.

func (ImageEntity) WithOriginInfo added in v11.1.0

func (e ImageEntity) WithOriginInfo(o *Origin) *entity

WithOriginInfo adds the passed in origin info to the entity config.

func (ImageEntity) WithStateCallback added in v11.1.0

func (e ImageEntity) WithStateCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithStateCallback will add the passed in function as the callback action to be run whenever the state of the entity is needed. It doesn't make sense to add this for entities that don't report a state, like buttons. It might not be useful to use this where you have a single state that represents many entities. In such cases, it would be better to manually send the state in your own code.

func (ImageEntity) WithStateClassMeasurement added in v11.1.0

func (e ImageEntity) WithStateClassMeasurement() *entity

WithStateClassMeasurement configures the State Class for the entity to be "measurement".

func (ImageEntity) WithStateClassTotal added in v11.1.0

func (e ImageEntity) WithStateClassTotal() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total".

func (ImageEntity) WithStateClassTotalIncreasing added in v11.1.0

func (e ImageEntity) WithStateClassTotalIncreasing() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total_increasing".

func (ImageEntity) WithStateExpiry added in v11.1.0

func (e ImageEntity) WithStateExpiry(i int) *entity

WithStateExpiry defines the number of seconds after the sensor’s state expires, if it’s not updated. After expiry, the sensor’s state becomes "unavailable".

func (*ImageEntity) WithURLTemplate added in v11.1.0

func (entity *ImageEntity) WithURLTemplate(template string) *ImageEntity

WithURLTemplate defines a template to use to extract the URL to the image from the response received. See https://www.home-assistant.io/docs/configuration/templating/#using-templates-with-the-mqtt-integration for template configuration.

func (ImageEntity) WithUnits added in v11.1.0

func (e ImageEntity) WithUnits(u string) *entity

WithUnits adds a unit of measurement to the entity.

func (ImageEntity) WithValueTemplate added in v11.1.0

func (e ImageEntity) WithValueTemplate(t string) *entity

WithValueTemplate configures the passed in template to be used to extract the value of the entity in Home Assistant.

type ImageMode added in v11.1.0

type ImageMode int

ImageMode reflects how this image entity is handled by Home Assistant.

const (
	// ModeImage is an image entity which publishes an image file.
	ModeImage ImageMode = iota
	// ModeURL is an image entity which publishes a URL to an image file.
	ModeURL
)

type NumberEntity

type NumberEntity[T constraints.Ordered] struct {
	Min  T      `json:"min,omitempty"`
	Max  T      `json:"max,omitempty"`
	Step T      `json:"step,omitempty"`
	Mode string `json:"mode,omitempty"`
	// contains filtered or unexported fields
}

NumberEntity represents an entity that is a number that has a given range of values and can be set to any value in that range, with a precision by the given step. For more details, see https://www.home-assistant.io/integrations/number.mqtt/

func AsNumber

func AsNumber[T constraints.Ordered](entity *entity, step, min, max T, mode NumberMode) *NumberEntity[T]

AsNumber converts the given entity into a NumberEntity. Additional builders can potentially be applied to customise it further.

func (NumberEntity) AsDiagnostic

func (e NumberEntity) AsDiagnostic() *entity

AsDiagnostic will mark this entity as a diagnostic entity in Home Assistant.

func (NumberEntity) GetTopics

func (e NumberEntity) GetTopics() *Topics

GetTopics returns a Topic struct containing the topics configured for this entity. If an entity does not have a particular topic (due to not having some functionality), the topic value will be an empty string.

func (NumberEntity) MarshalAttributes

func (e NumberEntity) MarshalAttributes(args ...any) (*mqttapi.Msg, error)

MarshalAttributes will generate an *mqtt.Msg for the attributes of an entity, that can be used for updating the entity's attributes.

func (*NumberEntity[T]) MarshalConfig

func (e *NumberEntity[T]) MarshalConfig() (*mqttapi.Msg, error)

func (NumberEntity) MarshalState

func (e NumberEntity) MarshalState(args ...any) (*mqttapi.Msg, error)

MarshalState will generate an *mqtt.Msg for a given entity, that can be used to publish the entity's state to the MQTT bus.

func (NumberEntity) MarshalSubscription

func (e NumberEntity) MarshalSubscription() (*mqttapi.Subscription, error)

MarshallSubscription will generate an *mqtt.Subscription for a given entity, which can be used to subscribe to an entity's command topic and execute a callback on messages.

func (NumberEntity) WithAttributesCallback

func (e NumberEntity) WithAttributesCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithAttributesCallback will add the passed in function as the callback action to be run whenever the attributes of the entity are needed. If this callback is to be used, then the WithAttributesTopic() builder function should also be called to set-up the attributes topic.

func (NumberEntity) WithAttributesTemplate

func (e NumberEntity) WithAttributesTemplate(t string) *entity

WithAttributesTemplate configures the passed in template to be used to extract the value of the attributes in Home Assistant.

func (NumberEntity) WithCommandCallback

func (e NumberEntity) WithCommandCallback(c func(p *paho.Publish)) *entity

WithCommandCallback will add the passed in function as the callback action to be run when a message is received on the command topic of the entity. It doesn't make sense to add this for entities that don't have a command topic, like regular sensors.

func (NumberEntity) WithDefaultOriginInfo

func (e NumberEntity) WithDefaultOriginInfo() *entity

WithOriginInfo adds a pre-filled origin that references go-hass-agent to the entity config.

func (NumberEntity) WithDeviceClass

func (e NumberEntity) WithDeviceClass(d string) *entity

WithDeviceClass configures the Device Class for the entity.

func (NumberEntity) WithDeviceInfo

func (e NumberEntity) WithDeviceInfo(d *Device) *entity

WithDeviceInfo adds the passed in device info to the entity config.

func (NumberEntity) WithIcon

func (e NumberEntity) WithIcon(i string) *entity

WithIcon adds an icon to the entity.

func (NumberEntity) WithNodeID

func (e NumberEntity) WithNodeID(id string) *entity

WithNodeID adds an additional section to the topics of the entity in MQTT. It can be used to help structure various entities being provided.

func (NumberEntity) WithOriginInfo

func (e NumberEntity) WithOriginInfo(o *Origin) *entity

WithOriginInfo adds the passed in origin info to the entity config.

func (NumberEntity) WithStateCallback

func (e NumberEntity) WithStateCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithStateCallback will add the passed in function as the callback action to be run whenever the state of the entity is needed. It doesn't make sense to add this for entities that don't report a state, like buttons. It might not be useful to use this where you have a single state that represents many entities. In such cases, it would be better to manually send the state in your own code.

func (NumberEntity) WithStateClassMeasurement

func (e NumberEntity) WithStateClassMeasurement() *entity

WithStateClassMeasurement configures the State Class for the entity to be "measurement".

func (NumberEntity) WithStateClassTotal

func (e NumberEntity) WithStateClassTotal() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total".

func (NumberEntity) WithStateClassTotalIncreasing

func (e NumberEntity) WithStateClassTotalIncreasing() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total_increasing".

func (NumberEntity) WithStateExpiry

func (e NumberEntity) WithStateExpiry(i int) *entity

WithStateExpiry defines the number of seconds after the sensor’s state expires, if it’s not updated. After expiry, the sensor’s state becomes "unavailable".

func (NumberEntity) WithUnits

func (e NumberEntity) WithUnits(u string) *entity

WithUnits adds a unit of measurement to the entity.

func (NumberEntity) WithValueTemplate

func (e NumberEntity) WithValueTemplate(t string) *entity

WithValueTemplate configures the passed in template to be used to extract the value of the entity in Home Assistant.

type NumberMode

type NumberMode int

NumberMode reflects how this number entity is displayed in Home Assistant. It can be either automatically chosen or explicitly set to display as a slider or box.

const (
	// NumberAuto will tell Home Assistant to automatically select how the number is displayed.
	NumberAuto NumberMode = 0 // auto
	// NumberBox will tell Home Assistant to display this number as a box.
	NumberBox NumberMode = 1 // box
	// NumberSlider will tell Home Assistant to display this number as a slider.
	NumberSlider NumberMode = 2 // slider
)

func (NumberMode) String

func (i NumberMode) String() string

type Origin

type Origin struct {
	Name    string `json:"name"`
	Version string `json:"sw_version,omitempty"`
	URL     string `json:"support_url,omitempty"`
}

Origin contains information about the app that is responsible for the entity. It is used by Home Assistant for logging and display purposes.

type SensorEntity

type SensorEntity struct {
	// contains filtered or unexported fields
}

SensorEntity represents an entity which has some kind of value. For more details, see https://www.home-assistant.io/integrations/sensor.mqtt/

func AsSensor

func AsSensor(entity *entity) *SensorEntity

AsSensor converts the given entity into a SensorEntity. Additional builders can potentially be applied to customise it further.

func (SensorEntity) AsDiagnostic

func (e SensorEntity) AsDiagnostic() *entity

AsDiagnostic will mark this entity as a diagnostic entity in Home Assistant.

func (SensorEntity) GetTopics

func (e SensorEntity) GetTopics() *Topics

GetTopics returns a Topic struct containing the topics configured for this entity. If an entity does not have a particular topic (due to not having some functionality), the topic value will be an empty string.

func (SensorEntity) MarshalAttributes

func (e SensorEntity) MarshalAttributes(args ...any) (*mqttapi.Msg, error)

MarshalAttributes will generate an *mqtt.Msg for the attributes of an entity, that can be used for updating the entity's attributes.

func (SensorEntity) MarshalConfig

func (e SensorEntity) MarshalConfig() (*mqttapi.Msg, error)

func (SensorEntity) MarshalState

func (e SensorEntity) MarshalState(args ...any) (*mqttapi.Msg, error)

MarshalState will generate an *mqtt.Msg for a given entity, that can be used to publish the entity's state to the MQTT bus.

func (SensorEntity) MarshalSubscription

func (e SensorEntity) MarshalSubscription() (*mqttapi.Subscription, error)

MarshallSubscription will generate an *mqtt.Subscription for a given entity, which can be used to subscribe to an entity's command topic and execute a callback on messages.

func (SensorEntity) WithAttributesCallback

func (e SensorEntity) WithAttributesCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithAttributesCallback will add the passed in function as the callback action to be run whenever the attributes of the entity are needed. If this callback is to be used, then the WithAttributesTopic() builder function should also be called to set-up the attributes topic.

func (SensorEntity) WithAttributesTemplate

func (e SensorEntity) WithAttributesTemplate(t string) *entity

WithAttributesTemplate configures the passed in template to be used to extract the value of the attributes in Home Assistant.

func (SensorEntity) WithCommandCallback

func (e SensorEntity) WithCommandCallback(c func(p *paho.Publish)) *entity

WithCommandCallback will add the passed in function as the callback action to be run when a message is received on the command topic of the entity. It doesn't make sense to add this for entities that don't have a command topic, like regular sensors.

func (SensorEntity) WithDefaultOriginInfo

func (e SensorEntity) WithDefaultOriginInfo() *entity

WithOriginInfo adds a pre-filled origin that references go-hass-agent to the entity config.

func (SensorEntity) WithDeviceClass

func (e SensorEntity) WithDeviceClass(d string) *entity

WithDeviceClass configures the Device Class for the entity.

func (SensorEntity) WithDeviceInfo

func (e SensorEntity) WithDeviceInfo(d *Device) *entity

WithDeviceInfo adds the passed in device info to the entity config.

func (SensorEntity) WithIcon

func (e SensorEntity) WithIcon(i string) *entity

WithIcon adds an icon to the entity.

func (SensorEntity) WithNodeID

func (e SensorEntity) WithNodeID(id string) *entity

WithNodeID adds an additional section to the topics of the entity in MQTT. It can be used to help structure various entities being provided.

func (SensorEntity) WithOriginInfo

func (e SensorEntity) WithOriginInfo(o *Origin) *entity

WithOriginInfo adds the passed in origin info to the entity config.

func (SensorEntity) WithStateCallback

func (e SensorEntity) WithStateCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithStateCallback will add the passed in function as the callback action to be run whenever the state of the entity is needed. It doesn't make sense to add this for entities that don't report a state, like buttons. It might not be useful to use this where you have a single state that represents many entities. In such cases, it would be better to manually send the state in your own code.

func (SensorEntity) WithStateClassMeasurement

func (e SensorEntity) WithStateClassMeasurement() *entity

WithStateClassMeasurement configures the State Class for the entity to be "measurement".

func (SensorEntity) WithStateClassTotal

func (e SensorEntity) WithStateClassTotal() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total".

func (SensorEntity) WithStateClassTotalIncreasing

func (e SensorEntity) WithStateClassTotalIncreasing() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total_increasing".

func (SensorEntity) WithStateExpiry

func (e SensorEntity) WithStateExpiry(i int) *entity

WithStateExpiry defines the number of seconds after the sensor’s state expires, if it’s not updated. After expiry, the sensor’s state becomes "unavailable".

func (SensorEntity) WithUnits

func (e SensorEntity) WithUnits(u string) *entity

WithUnits adds a unit of measurement to the entity.

func (SensorEntity) WithValueTemplate

func (e SensorEntity) WithValueTemplate(t string) *entity

WithValueTemplate configures the passed in template to be used to extract the value of the entity in Home Assistant.

type SwitchEntity

type SwitchEntity struct {
	Optimistic bool `json:"optimistic,omitempty"`
	// contains filtered or unexported fields
}

SwitchEntity represents an entity that can be turned on or off. For more details see https://www.home-assistant.io/integrations/switch.mqtt/

func AsSwitch

func AsSwitch(entity *entity, optimistic bool) *SwitchEntity

AsSwitch converts the given entity into a SwitchEntity. Additional builders can potentially be applied to customise it further.

func (SwitchEntity) AsDiagnostic

func (e SwitchEntity) AsDiagnostic() *entity

AsDiagnostic will mark this entity as a diagnostic entity in Home Assistant.

func (*SwitchEntity) AsTypeOutlet

func (e *SwitchEntity) AsTypeOutlet() *SwitchEntity

AsTypeSwitch sets the SwitchEntity device class as an "outlet". This primarily affects how it will be displayed in Home Assistant.

func (*SwitchEntity) AsTypeSwitch

func (e *SwitchEntity) AsTypeSwitch() *SwitchEntity

AsTypeSwitch sets the SwitchEntity device class as a "switch". This primarily affects how it will be displayed in Home Assistant.

func (SwitchEntity) GetTopics

func (e SwitchEntity) GetTopics() *Topics

GetTopics returns a Topic struct containing the topics configured for this entity. If an entity does not have a particular topic (due to not having some functionality), the topic value will be an empty string.

func (SwitchEntity) MarshalAttributes

func (e SwitchEntity) MarshalAttributes(args ...any) (*mqttapi.Msg, error)

MarshalAttributes will generate an *mqtt.Msg for the attributes of an entity, that can be used for updating the entity's attributes.

func (*SwitchEntity) MarshalConfig

func (e *SwitchEntity) MarshalConfig() (*mqttapi.Msg, error)

func (SwitchEntity) MarshalState

func (e SwitchEntity) MarshalState(args ...any) (*mqttapi.Msg, error)

MarshalState will generate an *mqtt.Msg for a given entity, that can be used to publish the entity's state to the MQTT bus.

func (SwitchEntity) MarshalSubscription

func (e SwitchEntity) MarshalSubscription() (*mqttapi.Subscription, error)

MarshallSubscription will generate an *mqtt.Subscription for a given entity, which can be used to subscribe to an entity's command topic and execute a callback on messages.

func (SwitchEntity) WithAttributesCallback

func (e SwitchEntity) WithAttributesCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithAttributesCallback will add the passed in function as the callback action to be run whenever the attributes of the entity are needed. If this callback is to be used, then the WithAttributesTopic() builder function should also be called to set-up the attributes topic.

func (SwitchEntity) WithAttributesTemplate

func (e SwitchEntity) WithAttributesTemplate(t string) *entity

WithAttributesTemplate configures the passed in template to be used to extract the value of the attributes in Home Assistant.

func (SwitchEntity) WithCommandCallback

func (e SwitchEntity) WithCommandCallback(c func(p *paho.Publish)) *entity

WithCommandCallback will add the passed in function as the callback action to be run when a message is received on the command topic of the entity. It doesn't make sense to add this for entities that don't have a command topic, like regular sensors.

func (SwitchEntity) WithDefaultOriginInfo

func (e SwitchEntity) WithDefaultOriginInfo() *entity

WithOriginInfo adds a pre-filled origin that references go-hass-agent to the entity config.

func (SwitchEntity) WithDeviceClass

func (e SwitchEntity) WithDeviceClass(d string) *entity

WithDeviceClass configures the Device Class for the entity.

func (SwitchEntity) WithDeviceInfo

func (e SwitchEntity) WithDeviceInfo(d *Device) *entity

WithDeviceInfo adds the passed in device info to the entity config.

func (SwitchEntity) WithIcon

func (e SwitchEntity) WithIcon(i string) *entity

WithIcon adds an icon to the entity.

func (SwitchEntity) WithNodeID

func (e SwitchEntity) WithNodeID(id string) *entity

WithNodeID adds an additional section to the topics of the entity in MQTT. It can be used to help structure various entities being provided.

func (SwitchEntity) WithOriginInfo

func (e SwitchEntity) WithOriginInfo(o *Origin) *entity

WithOriginInfo adds the passed in origin info to the entity config.

func (SwitchEntity) WithStateCallback

func (e SwitchEntity) WithStateCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithStateCallback will add the passed in function as the callback action to be run whenever the state of the entity is needed. It doesn't make sense to add this for entities that don't report a state, like buttons. It might not be useful to use this where you have a single state that represents many entities. In such cases, it would be better to manually send the state in your own code.

func (SwitchEntity) WithStateClassMeasurement

func (e SwitchEntity) WithStateClassMeasurement() *entity

WithStateClassMeasurement configures the State Class for the entity to be "measurement".

func (SwitchEntity) WithStateClassTotal

func (e SwitchEntity) WithStateClassTotal() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total".

func (SwitchEntity) WithStateClassTotalIncreasing

func (e SwitchEntity) WithStateClassTotalIncreasing() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total_increasing".

func (SwitchEntity) WithStateExpiry

func (e SwitchEntity) WithStateExpiry(i int) *entity

WithStateExpiry defines the number of seconds after the sensor’s state expires, if it’s not updated. After expiry, the sensor’s state becomes "unavailable".

func (SwitchEntity) WithUnits

func (e SwitchEntity) WithUnits(u string) *entity

WithUnits adds a unit of measurement to the entity.

func (SwitchEntity) WithValueTemplate

func (e SwitchEntity) WithValueTemplate(t string) *entity

WithValueTemplate configures the passed in template to be used to extract the value of the entity in Home Assistant.

type TextEntity

type TextEntity struct {
	Mode string `json:"mode,omitempty"`
	Min  int    `json:"min,omitempty"`
	Max  int    `json:"max,omitempty"`
	// contains filtered or unexported fields
}

TextEntity represents an entity that can display a string of text and set the string remotely. For more details see https://www.home-assistant.io/integrations/text.mqtt/

func AsText

func AsText(entity *entity, min, max int) *TextEntity

AsText converts the given entity into a TextEntity. The min, max parameters do not need to be specified (default min: 0, default max: 255).

func (TextEntity) AsDiagnostic

func (e TextEntity) AsDiagnostic() *entity

AsDiagnostic will mark this entity as a diagnostic entity in Home Assistant.

func (*TextEntity) AsPassword

func (e *TextEntity) AsPassword() *TextEntity

AsPassword sets the mode for this text entity to a password.

func (*TextEntity) AsPlainText

func (e *TextEntity) AsPlainText() *TextEntity

AsPlainText sets the mode for this text entity to (the default) plain text.

func (TextEntity) GetTopics

func (e TextEntity) GetTopics() *Topics

GetTopics returns a Topic struct containing the topics configured for this entity. If an entity does not have a particular topic (due to not having some functionality), the topic value will be an empty string.

func (TextEntity) MarshalAttributes

func (e TextEntity) MarshalAttributes(args ...any) (*mqttapi.Msg, error)

MarshalAttributes will generate an *mqtt.Msg for the attributes of an entity, that can be used for updating the entity's attributes.

func (*TextEntity) MarshalConfig

func (e *TextEntity) MarshalConfig() (*mqttapi.Msg, error)

func (TextEntity) MarshalState

func (e TextEntity) MarshalState(args ...any) (*mqttapi.Msg, error)

MarshalState will generate an *mqtt.Msg for a given entity, that can be used to publish the entity's state to the MQTT bus.

func (TextEntity) MarshalSubscription

func (e TextEntity) MarshalSubscription() (*mqttapi.Subscription, error)

MarshallSubscription will generate an *mqtt.Subscription for a given entity, which can be used to subscribe to an entity's command topic and execute a callback on messages.

func (TextEntity) WithAttributesCallback

func (e TextEntity) WithAttributesCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithAttributesCallback will add the passed in function as the callback action to be run whenever the attributes of the entity are needed. If this callback is to be used, then the WithAttributesTopic() builder function should also be called to set-up the attributes topic.

func (TextEntity) WithAttributesTemplate

func (e TextEntity) WithAttributesTemplate(t string) *entity

WithAttributesTemplate configures the passed in template to be used to extract the value of the attributes in Home Assistant.

func (TextEntity) WithCommandCallback

func (e TextEntity) WithCommandCallback(c func(p *paho.Publish)) *entity

WithCommandCallback will add the passed in function as the callback action to be run when a message is received on the command topic of the entity. It doesn't make sense to add this for entities that don't have a command topic, like regular sensors.

func (TextEntity) WithDefaultOriginInfo

func (e TextEntity) WithDefaultOriginInfo() *entity

WithOriginInfo adds a pre-filled origin that references go-hass-agent to the entity config.

func (TextEntity) WithDeviceClass

func (e TextEntity) WithDeviceClass(d string) *entity

WithDeviceClass configures the Device Class for the entity.

func (TextEntity) WithDeviceInfo

func (e TextEntity) WithDeviceInfo(d *Device) *entity

WithDeviceInfo adds the passed in device info to the entity config.

func (TextEntity) WithIcon

func (e TextEntity) WithIcon(i string) *entity

WithIcon adds an icon to the entity.

func (TextEntity) WithNodeID

func (e TextEntity) WithNodeID(id string) *entity

WithNodeID adds an additional section to the topics of the entity in MQTT. It can be used to help structure various entities being provided.

func (TextEntity) WithOriginInfo

func (e TextEntity) WithOriginInfo(o *Origin) *entity

WithOriginInfo adds the passed in origin info to the entity config.

func (TextEntity) WithStateCallback

func (e TextEntity) WithStateCallback(c func(args ...any) (json.RawMessage, error)) *entity

WithStateCallback will add the passed in function as the callback action to be run whenever the state of the entity is needed. It doesn't make sense to add this for entities that don't report a state, like buttons. It might not be useful to use this where you have a single state that represents many entities. In such cases, it would be better to manually send the state in your own code.

func (TextEntity) WithStateClassMeasurement

func (e TextEntity) WithStateClassMeasurement() *entity

WithStateClassMeasurement configures the State Class for the entity to be "measurement".

func (TextEntity) WithStateClassTotal

func (e TextEntity) WithStateClassTotal() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total".

func (TextEntity) WithStateClassTotalIncreasing

func (e TextEntity) WithStateClassTotalIncreasing() *entity

WithStateClassMeasurement configures the State Class for the entity to be "total_increasing".

func (TextEntity) WithStateExpiry

func (e TextEntity) WithStateExpiry(i int) *entity

WithStateExpiry defines the number of seconds after the sensor’s state expires, if it’s not updated. After expiry, the sensor’s state becomes "unavailable".

func (TextEntity) WithUnits

func (e TextEntity) WithUnits(u string) *entity

WithUnits adds a unit of measurement to the entity.

func (TextEntity) WithValueTemplate

func (e TextEntity) WithValueTemplate(t string) *entity

WithValueTemplate configures the passed in template to be used to extract the value of the entity in Home Assistant.

type TextEntityMode

type TextEntityMode int
const (
	PlainText TextEntityMode = iota // text
	Password                        // password
)

func (TextEntityMode) String

func (i TextEntityMode) String() string

type Topics

type Topics struct {
	Config     string
	Command    string
	State      string
	Attributes string
}

Topics contains the names of important topics on the MQTT bus related to the entity. Apps can store these topics for later retrieval and usage (for example, to update state topics or listen to command topics).

Jump to

Keyboard shortcuts

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