climate

Go types for Home Assistant's climate domain: control over HTTP and MQTT, serve over MQTT discovery.

Control: HTTP Control: MQTT Serve a device Discovery config
import "github.com/taumatix/homeassistant-go/domains/climate"

Overview

Package climate is Home Assistant's climate domain: its types and its MQTT discovery config.

Entity controls one climate entity over HTTP or MQTT. Device serves one over MQTT.

Home Assistant documents the domain here:

Integration: https://www.home-assistant.io/integrations/climate/

MQTT discovery: https://www.home-assistant.io/integrations/climate.mqtt/

Entity model (developers): https://contributors.home-assistant.io/core/entities/climate/

Control

// client is an *api.Client or a connected *mqtt.Client
target := climate.Get(client, "my_climate")
state, err := target.State(ctx)
err = target.Toggle(ctx)

Serve

// mqttClient is a connected *mqtt.Client
device, err := climate.NewDevice(ctx, mqttClient, "my-climate",
	climate.WithName("My climate"),
)

Commands

What each Entity method does on each transport. MQTT publishes to the topic the entity's discovery config names in that option.

MethodOver HTTP, callsOver MQTT, publishes to
SetFanMode climate.set_fan_mode fan_mode_command_topic
SetHVACMode climate.set_hvac_mode mode_command_topic
SetPresetMode climate.set_preset_mode preset_mode_command_topic
SetSwingHorizontalMode climate.set_swing_horizontal_mode swing_horizontal_mode_command_topic
SetSwingMode climate.set_swing_mode swing_mode_command_topic
SetHumidity climate.set_humidity target_humidity_command_topic
SetTemperature climate.set_temperature temperature_command_topic
SetTemperatureRange climate.set_temperature temperature_low_command_topic, temperature_high_command_topic
Toggle climate.toggle not available
TurnOff climate.turn_off power_command_topic
TurnOn climate.turn_on power_command_topic

Control

type Entity struct

Entity controls one climate entity over HTTP (api.Client) or MQTT (mqtt.Client). State and Subscribe come from the embedded Handle.

Embeds entity.Handle[Attributes], whose methods it has too.

func Get(transport entity.Transport, id string) *Entity

Get returns the climate entity with the given id: an entity id over HTTP (the "climate." prefix may be omitted), a discovery object path or unique id over MQTT. It does no I/O.

func List(ctx context.Context, transport entity.Transport) ([]*Entity, error)

List returns every climate entity the transport can see: all of Home Assistant's over HTTP, the discovered ones over MQTT.

func (e *Entity) SetFanMode(ctx context.Context, mode FanMode) error

SetFanMode calls climate.set_fan_mode, or publishes to fan_mode_command_topic. Core describes the service: Sets the fan mode of a thermostat.

func (e *Entity) SetHVACMode(ctx context.Context, mode HVACMode) error

SetHVACMode calls climate.set_hvac_mode, or publishes to mode_command_topic. Core describes the service: Sets the HVAC mode of a thermostat.

func (e *Entity) SetHumidity(ctx context.Context, humidity float64) error

SetHumidity calls climate.set_humidity, or publishes to target_humidity_command_topic. Core describes the service: Sets the target humidity of a thermostat.

func (e *Entity) SetPresetMode(ctx context.Context, mode PresetMode) error

SetPresetMode calls climate.set_preset_mode, or publishes to preset_mode_command_topic. Core describes the service: Sets the preset mode of a thermostat.

func (e *Entity) SetSwingHorizontalMode(ctx context.Context, mode SwingHorizontalMode) error

SetSwingHorizontalMode calls climate.set_swing_horizontal_mode, or publishes to swing_horizontal_mode_command_topic. Core describes the service: Sets the horizontal swing mode of a thermostat.

func (e *Entity) SetSwingMode(ctx context.Context, mode SwingMode) error

SetSwingMode calls climate.set_swing_mode, or publishes to swing_mode_command_topic. Core describes the service: Sets the swing mode of a thermostat.

func (e *Entity) SetTemperature(ctx context.Context, temperature float64) error

SetTemperature calls climate.set_temperature, or publishes to temperature_command_topic. Core describes the service: Sets the target temperature of a thermostat.

func (e *Entity) SetTemperatureRange(ctx context.Context, low, high float64) error

SetTemperatureRange calls climate.set_temperature, or publishes to temperature_low_command_topic and temperature_high_command_topic. Core describes the service: Sets the target temperature of a thermostat.

func (e *Entity) Toggle(ctx context.Context) error

Toggle calls climate.toggle. It has no MQTT equivalent. Core describes the service: Toggles a thermostat on/off.

func (e *Entity) TurnOff(ctx context.Context) error

TurnOff calls climate.turn_off, or publishes payload_off to power_command_topic. Core describes the service: Turns off a thermostat.

func (e *Entity) TurnOn(ctx context.Context) error

TurnOn calls climate.turn_on, or publishes payload_on to power_command_topic. Core describes the service: Turns on a thermostat.

type State = entity.State[Attributes]

State is a snapshot of one climate entity. Its State field holds a value of HVACMode, "unavailable" or "unknown"; see HVACModeOf.

Serve over MQTT

type Device struct

Device is one climate entity served by this process over MQTT. Close, Delete and ReportAvailability come from the embedded mqtt.Device.

Commands from Home Assistant arrive through the On*Command callbacks. A callback's ctx is cancelled when the client closes; an error it returns goes to the client's error path (mqtt.WithLogger, mqtt.WithOnError).

Embeds *mqtt.Device, whose methods it has too.

func NewDevice(ctx context.Context, client *mqtt.Client, objectID string, options ...DeviceOption) (*Device, error)

NewDevice announces a climate entity through MQTT discovery and returns the device serving it. objectID may carry one "node_id/" prefix. Command, state and availability topics default to <topic root>/climate/<objectID>/... and the options can override them. The client must be connected.

func (d *Device) Config() Config

Config returns the discovery config announced to Home Assistant.

func (d *Device) OnFanModeCommand(fn func(ctx context.Context, mode FanMode) error)

OnFanModeCommand registers the callback for Home Assistant requesting a change of fan_mode.

func (d *Device) OnHVACModeCommand(fn func(ctx context.Context, mode HVACMode) error)

OnHVACModeCommand registers the callback for Home Assistant requesting a change of hvac_mode.

func (d *Device) OnHumidityCommand(fn func(ctx context.Context, humidity float64) error)

OnHumidityCommand registers the callback for Home Assistant requesting a change of humidity.

func (d *Device) OnPowerCommand(fn func(ctx context.Context, on bool) error)

OnPowerCommand registers the callback for Home Assistant turning the device on or off.

func (d *Device) OnPresetModeCommand(fn func(ctx context.Context, mode PresetMode) error)

OnPresetModeCommand registers the callback for Home Assistant requesting a change of preset_mode.

func (d *Device) OnSwingHorizontalModeCommand(fn func(ctx context.Context, mode SwingHorizontalMode) error)

OnSwingHorizontalModeCommand registers the callback for Home Assistant requesting a change of swing_horizontal_mode.

func (d *Device) OnSwingModeCommand(fn func(ctx context.Context, mode SwingMode) error)

OnSwingModeCommand registers the callback for Home Assistant requesting a change of swing_mode.

func (d *Device) OnTemperatureCommand(fn func(ctx context.Context, temperature float64) error)

OnTemperatureCommand registers the callback for Home Assistant requesting a change of temperature.

func (d *Device) ReportCurrentHumidity(ctx context.Context, currentHumidity float64, opts ...mqtt.StateOption) error

ReportCurrentHumidity reports the current_humidity on current_humidity_topic. opts override the client's state QoS and retain defaults for this publish.

func (d *Device) ReportCurrentTemperature(ctx context.Context, currentTemperature float64, opts ...mqtt.StateOption) error

ReportCurrentTemperature reports the current_temperature on current_temperature_topic. opts override the client's state QoS and retain defaults for this publish.

func (d *Device) ReportFanMode(ctx context.Context, mode FanMode, opts ...mqtt.StateOption) error

ReportFanMode reports the fan_mode on fan_mode_state_topic. opts override the client's state QoS and retain defaults for this publish.

func (d *Device) ReportHVACMode(ctx context.Context, mode HVACMode, opts ...mqtt.StateOption) error

ReportHVACMode reports the hvac_mode on mode_state_topic. opts override the client's state QoS and retain defaults for this publish.

func (d *Device) ReportPresetMode(ctx context.Context, mode PresetMode, opts ...mqtt.StateOption) error

ReportPresetMode reports the preset_mode on preset_mode_state_topic. opts override the client's state QoS and retain defaults for this publish.

func (d *Device) ReportSwingHorizontalMode(ctx context.Context, mode SwingHorizontalMode, opts ...mqtt.StateOption) error

ReportSwingHorizontalMode reports the swing_horizontal_mode on swing_horizontal_mode_state_topic. opts override the client's state QoS and retain defaults for this publish.

func (d *Device) ReportSwingMode(ctx context.Context, mode SwingMode, opts ...mqtt.StateOption) error

ReportSwingMode reports the swing_mode on swing_mode_state_topic. opts override the client's state QoS and retain defaults for this publish.

func (d *Device) ReportTargetHumidity(ctx context.Context, humidity float64, opts ...mqtt.StateOption) error

ReportTargetHumidity reports the target_humidity on target_humidity_state_topic. opts override the client's state QoS and retain defaults for this publish.

func (d *Device) ReportTargetTemperature(ctx context.Context, temperature float64, opts ...mqtt.StateOption) error

ReportTargetTemperature reports the target_temperature on temperature_state_topic. opts override the client's state QoS and retain defaults for this publish.

type DeviceOption func(config *Config)

DeviceOption customizes the discovery config of a device before it is announced. Options run before the default topics are derived, so a topic they set is kept.

func WithConfig(fn func(config *Config)) DeviceOption

WithConfig applies fn to the discovery config for adjustments not covered by the other options.

func WithDeviceDetails(details ha.MQTTDeviceDetails) DeviceOption

WithDeviceDetails ties the entity to a device in the Home Assistant device registry.

func WithFanModes(modes ...FanMode) DeviceOption

WithFanModes declares the supported fan_mode options and enables their topics.

func WithHVACModes(modes ...HVACMode) DeviceOption

WithHVACModes declares the supported hvac_mode options.

func WithHumidity(min, max float64) DeviceOption

WithHumidity sets min_humidity and max_humidity.

func WithName(name string) DeviceOption

WithName sets the friendly name announced to Home Assistant.

func WithPresetModes(modes ...PresetMode) DeviceOption

WithPresetModes declares the supported preset_mode options and enables their topics.

func WithSwingHorizontalModes(modes ...SwingHorizontalMode) DeviceOption

WithSwingHorizontalModes declares the supported swing_horizontal_mode options and enables their topics.

func WithSwingModes(modes ...SwingMode) DeviceOption

WithSwingModes declares the supported swing_mode options and enables their topics.

func WithTemperatureLimits(min, max float64) DeviceOption

WithTemperatureLimits sets min_temp and max_temp.

State and values

type Attributes struct

Attributes are the state attributes of a climate entity, under the names Home Assistant publishes them with.

See: https://www.home-assistant.io/integrations/climate/

FieldTypeWire keyDescription
CurrentHumidity*float64current_humidity

Current humidity. Over MQTT it comes from current_humidity_topic.

CurrentTemperature*float64current_temperature

Current temperature. Over MQTT it comes from current_temperature_topic.

FanMode*stringfan_mode

Fan mode. Over MQTT it comes from fan_mode_state_topic.

FanModes*[]stringfan_modes

Fan modes. Over MQTT it comes from the fan_modes option.

TargetHumidity*float64humidity

Target humidity. Over MQTT it comes from target_humidity_state_topic.

HVACAction*HVACActionhvac_action

Current action. Over MQTT it comes from action_topic.

HVACModes[]HVACModehvac_modes

HVAC modes. Over MQTT it comes from the modes option.

MaxHumidityfloat64max_humidity

Max target humidity. Over MQTT it comes from the max_humidity option.

MaxTempfloat64max_temp

Max target temperature. Over MQTT it comes from the max_temp option.

MinHumidityfloat64min_humidity

Min target humidity. Over MQTT it comes from the min_humidity option.

MinTempfloat64min_temp

Min target temperature. Over MQTT it comes from the min_temp option.

PresetMode*stringpreset_mode

Preset. Over MQTT it comes from preset_mode_state_topic.

PresetModes*[]stringpreset_modes

Presets. Over MQTT it comes from the preset_modes option.

SupportedFeaturesFeaturesupported_features

A set of Feature flags.

SwingHorizontalMode*stringswing_horizontal_mode

Horizontal swing mode. Over MQTT it comes from swing_horizontal_mode_state_topic.

SwingHorizontalModes*[]stringswing_horizontal_modes

Horizontal swing modes. Over MQTT it comes from the swing_horizontal_modes option.

SwingMode*stringswing_mode

Swing mode. Over MQTT it comes from swing_mode_state_topic.

SwingModes*[]stringswing_modes

Swing modes. Over MQTT it comes from the swing_modes option.

TargetHumidityStep*inttarget_humidity_step
TargetTemperatureHigh*float64target_temp_high

Upper target temperature.

TargetTemperatureLow*float64target_temp_low

Lower target temperature.

TargetTemperatureStep*float64target_temp_step

Target temperature step. Over MQTT it comes from the temp_step option.

TargetTemperature*float64temperature

Target temperature. Over MQTT it comes from temperature_state_topic.

TemperatureUnitstringtemperature_unit

Over MQTT it comes from the temperature_unit option.

FanMode

type FanMode string

FanMode lists the built-in values of the fan_mode attribute, as Home Assistant translates them. Integrations may use others, which are kept as they are.

ConstantValue
FanModeUnknown"Unknown"
FanModeAuto"auto"
FanModeDiffuse"diffuse"
FanModeFocus"focus"
FanModeHigh"high"
FanModeLow"low"
FanModeMedium"medium"
FanModeMiddle"middle"
FanModeOff"off"
FanModeOn"on"
FanModeTop"top"
func FanModeFromString(s string) FanMode

FanModeFromString returns s as a FanMode.

func (v *FanMode) UnmarshalJSON(data []byte) error

UnmarshalJSON reads any spelling FanModeFromString accepts.

Feature

type Feature uint64

Feature is a set of climate supported features, with the values of core's ClimateEntityFeature: the supported_features attribute decodes into it.

ConstantValue
FeatureUnknown0
FeatureTargetTemperature1 << 0
FeatureTargetTemperatureRange1 << 1
FeatureTargetHumidity1 << 2
FeatureFanMode1 << 3
FeaturePresetMode1 << 4
FeatureSwingMode1 << 5
FeatureTurnOff1 << 7
FeatureTurnOn1 << 8
FeatureSwingHorizontalMode1 << 9
func FeatureFromString(s string) Feature

FeatureFromString returns the Feature spelled s, by its value or by the name of core's member, and FeatureUnknown for anything else.

HVACAction

type HVACAction string

HVACAction is core's HVACAction.

ConstantValue
HVACActionUnknown"Unknown"
HVACActionCooling"cooling"
HVACActionDefrosting"defrosting"
HVACActionDrying"drying"
HVACActionFan"fan"
HVACActionHeating"heating"
HVACActionIdle"idle"
HVACActionOff"off"
HVACActionPreheating"preheating"
func HVACActionFromString(s string) HVACAction

HVACActionFromString returns the HVACAction spelled s, by its value or by the name of core's member, and HVACActionUnknown for anything else.

func (v *HVACAction) UnmarshalJSON(data []byte) error

UnmarshalJSON reads any spelling HVACActionFromString accepts.

HVACMode

type HVACMode string

HVACMode is core's HVACMode.

ConstantValue
HVACModeUnknown"Unknown"
HVACModeOff"off"
HVACModeHeat"heat"
HVACModeCool"cool"
HVACModeHeatCool"heat_cool"
HVACModeAuto"auto"
HVACModeDry"dry"
HVACModeFanOnly"fan_only"
func HVACModeFromString(s string) HVACMode

HVACModeFromString returns the HVACMode spelled s, by its value or by the name of core's member, and HVACModeUnknown for anything else.

func HVACModeOf(state *State) HVACMode

HVACModeOf returns the entity state as HVACMode. Unavailable and unknown states are HVACModeUnknown.

func (v *HVACMode) UnmarshalJSON(data []byte) error

UnmarshalJSON reads any spelling HVACModeFromString accepts.

PresetMode

type PresetMode string

PresetMode lists the built-in values of the preset_mode attribute, as Home Assistant translates them. Integrations may use others, which are kept as they are.

ConstantValue
PresetModeUnknown"Unknown"
PresetModeActivity"activity"
PresetModeAway"away"
PresetModeBoost"boost"
PresetModeComfort"comfort"
PresetModeEco"eco"
PresetModeHome"home"
PresetModeNone"none"
PresetModeSleep"sleep"
func PresetModeFromString(s string) PresetMode

PresetModeFromString returns s as a PresetMode.

func (v *PresetMode) UnmarshalJSON(data []byte) error

UnmarshalJSON reads any spelling PresetModeFromString accepts.

SwingHorizontalMode

type SwingHorizontalMode string

SwingHorizontalMode lists the built-in values of the swing_horizontal_mode attribute, as Home Assistant translates them. Integrations may use others, which are kept as they are.

ConstantValue
SwingHorizontalModeUnknown"Unknown"
SwingHorizontalModeOff"off"
SwingHorizontalModeOn"on"
func SwingHorizontalModeFromString(s string) SwingHorizontalMode

SwingHorizontalModeFromString returns s as a SwingHorizontalMode.

func (v *SwingHorizontalMode) UnmarshalJSON(data []byte) error

UnmarshalJSON reads any spelling SwingHorizontalModeFromString accepts.

SwingMode

type SwingMode string

SwingMode lists the built-in values of the swing_mode attribute, as Home Assistant translates them. Integrations may use others, which are kept as they are.

ConstantValue
SwingModeUnknown"Unknown"
SwingModeBoth"both"
SwingModeHorizontal"horizontal"
SwingModeOff"off"
SwingModeOn"on"
SwingModeVertical"vertical"
func SwingModeFromString(s string) SwingMode

SwingModeFromString returns s as a SwingMode.

func (v *SwingMode) UnmarshalJSON(data []byte) error

UnmarshalJSON reads any spelling SwingModeFromString accepts.

MQTT discovery config

type Config struct

Config is the MQTT discovery config of climate.

See: https://www.home-assistant.io/integrations/climate.mqtt/

FieldTypeWire keyDescription
ActionTemplate*ha.Templateaction_template

Only Home Assistant renders templates: with it set, Entity skips action_topic when reading state.

ActionTopic*stringaction_topic

Over MQTT, Entity reads the "hvac_action" attribute from it.

Availability[]ha.MQTTAvailabilityavailability
AvailabilityMode*stringavailability_mode

Allowed: "all", "any", "latest".

Default: "latest"

AvailabilityTemplate*ha.Templateavailability_template
AvailabilityTopic*stringavailability_topic

Topic to receive the availability payload on. NewDevice defaults it to <base>/availability.

CurrentHumidityTemplate*ha.Templatecurrent_humidity_template

Only Home Assistant renders templates: with it set, Entity skips current_humidity_topic when reading state.

CurrentHumidityTopic*stringcurrent_humidity_topic

Over MQTT, Entity reads the "current_humidity" attribute from it. Device.ReportCurrentHumidity publishes to it. NewDevice defaults it to <base>/current_humidity/state when min_humidity or max_humidity is set.

CurrentTemperatureTemplate*ha.Templatecurrent_temperature_template

Only Home Assistant renders templates: with it set, Entity skips current_temperature_topic when reading state.

CurrentTemperatureTopic*stringcurrent_temperature_topic

Over MQTT, Entity reads the "current_temperature" attribute from it. Device.ReportCurrentTemperature publishes to it. NewDevice defaults it to <base>/current_temperature/state.

DefaultEntityId*stringdefault_entity_id
Device*ha.MQTTDeviceDetailsdevice
EnabledByDefault*boolenabled_by_default

Default: true

Encoding*stringencoding

Default: "utf-8"

EntityCategory*stringentity_category

Allowed: "config", "diagnostic".

EntityPicture*stringentity_picture

An URL to a picture to be assigned.

FanModeCommandTemplate*ha.Templatefan_mode_command_template

Only Home Assistant renders templates: with it set, Entity refuses to publish to fan_mode_command_topic.

FanModeCommandTopic*stringfan_mode_command_topic

Entity.SetFanMode publishes to it. Device.OnFanModeCommand receives what is published to it. NewDevice defaults it to <base>/fan_mode/set when fan_modes is set.

FanModeStateTemplate*ha.Templatefan_mode_state_template

Only Home Assistant renders templates: with it set, Entity skips fan_mode_state_topic when reading state.

FanModeStateTopic*stringfan_mode_state_topic

Over MQTT, Entity reads the "fan_mode" attribute from it. Device.ReportFanMode publishes to it. NewDevice defaults it to <base>/fan_mode/state when fan_modes is set.

FanModes[]stringfan_modes

List of fan modes this climate is capable of running at. Common fan modes that offer translations are off, on, auto, low, medium, high, middle, focus and diffuse. Over MQTT, Entity reports it as the "fan_modes" attribute. Set it with WithFanModes.

Default: [ "auto", "low", "medium", "high" ]

Group[]stringgroup
Icon*ha.Iconicon
Initial*float64initial

The device initializes with this target temperature.

JsonAttributesTemplate*ha.Templatejson_attributes_template
JsonAttributesTopic*stringjson_attributes_topic

The library does not use it: extra attributes in a JSON document, which is not offered yet.

MaxHumidity*float64max_humidity

The maximum target humidity that can be set. Over MQTT, Entity reports it as the "max_humidity" attribute. Set it with WithHumidity.

Default: 99

MaxTemp*float64max_temp

The maximum target temperature that can be set. Over MQTT, Entity reports it as the "max_temp" attribute. Set it with WithTemperatureLimits.

MessageExpiryInterval*map[string]anymessage_expiry_interval

Retention time interval for published message.

MinHumidity*float64min_humidity

The minimum target humidity that can be set. Over MQTT, Entity reports it as the "min_humidity" attribute. Set it with WithHumidity.

Default: 30

MinTemp*float64min_temp

The minimum target temperature that can be set. Over MQTT, Entity reports it as the "min_temp" attribute. Set it with WithTemperatureLimits.

ModeCommandTemplate*ha.Templatemode_command_template

Only Home Assistant renders templates: with it set, Entity refuses to publish to mode_command_topic.

ModeCommandTopic*stringmode_command_topic

Entity.SetHVACMode publishes to it. Device.OnHVACModeCommand receives what is published to it. NewDevice defaults it to <base>/mode/set.

ModeStateTemplate*ha.Templatemode_state_template

Only Home Assistant renders templates: with it set, Entity skips mode_state_topic when reading state.

ModeStateTopic*stringmode_state_topic

Over MQTT, Entity reads the entity state from it. Device.ReportHVACMode publishes to it. NewDevice defaults it to <base>/mode/state.

Modes[]stringmodes

Over MQTT, Entity reports it as the "hvac_modes" attribute. Set it with WithHVACModes.

Default: [ "auto", "off", "cool", "heat", "dry", "fan_only" ]

Name*stringname
Optimistic*booloptimistic

Default: false

Origin*ha.DeviceOriginorigin
PayloadAvailable*stringpayload_available

The payload that indicates the device is available (defaults to 'online').

Default: "online"

PayloadNotAvailable*stringpayload_not_available

The payload that indicates the device is not available (defaults to 'offline').

Default: "offline"

PayloadOff*stringpayload_off

The payload that represents the "off" state. Entity.TurnOff publishes it. Device.OnPowerCommand matches the received payload against it.

Default: "OFF"

PayloadOn*stringpayload_on

The payload that represents the "on" state. Entity.TurnOn publishes it. Device.OnPowerCommand matches the received payload against it.

Default: "ON"

PowerCommandTemplate*ha.Templatepower_command_template

Only Home Assistant renders templates: with it set, Entity refuses to publish to power_command_topic.

PowerCommandTopic*stringpower_command_topic

Entity.TurnOff publishes to it. Entity.TurnOn publishes to it. Device.OnPowerCommand receives what is published to it. NewDevice defaults it to <base>/power/set.

Precision*float64precision

The precision in degrees the thermostat is working at. Allowed: 0.1, 0.5, 1.

PresetModeCommandTemplate*ha.Templatepreset_mode_command_template

Only Home Assistant renders templates: with it set, Entity refuses to publish to preset_mode_command_topic.

PresetModeCommandTopic*stringpreset_mode_command_topic

Entity.SetPresetMode publishes to it. Device.OnPresetModeCommand receives what is published to it. NewDevice defaults it to <base>/preset_mode/set when preset_modes is set.

PresetModeStateTopic*stringpreset_mode_state_topic

Over MQTT, Entity reads the "preset_mode" attribute from it. Device.ReportPresetMode publishes to it. NewDevice defaults it to <base>/preset_mode/state when preset_modes is set.

PresetModeValueTemplate*ha.Templatepreset_mode_value_template

Only Home Assistant renders templates: with it set, Entity skips preset_mode_state_topic when reading state.

PresetModes[]stringpreset_modes

Over MQTT, Entity reports it as the "preset_modes" attribute. Set it with WithPresetModes.

Qos*intqos

Default: 0

Retain*boolretain

Default: false

SwingHorizontalModeCommandTemplate*ha.Templateswing_horizontal_mode_command_template

Only Home Assistant renders templates: with it set, Entity refuses to publish to swing_horizontal_mode_command_topic.

SwingHorizontalModeCommandTopic*stringswing_horizontal_mode_command_topic

Entity.SetSwingHorizontalMode publishes to it. Device.OnSwingHorizontalModeCommand receives what is published to it. NewDevice defaults it to <base>/swing_horizontal_mode/set when swing_horizontal_modes is set.

SwingHorizontalModeStateTemplate*ha.Templateswing_horizontal_mode_state_template

Only Home Assistant renders templates: with it set, Entity skips swing_horizontal_mode_state_topic when reading state.

SwingHorizontalModeStateTopic*stringswing_horizontal_mode_state_topic

Over MQTT, Entity reads the "swing_horizontal_mode" attribute from it. Device.ReportSwingHorizontalMode publishes to it. NewDevice defaults it to <base>/swing_horizontal_mode/state when swing_horizontal_modes is set.

SwingHorizontalModes[]stringswing_horizontal_modes

List of horizontal swing modes this climate is capable of running at. Common horizontal swing modes that offer translations are off and on. Over MQTT, Entity reports it as the "swing_horizontal_modes" attribute. Set it with WithSwingHorizontalModes.

Default: [ "on", "off" ]

SwingModeCommandTemplate*ha.Templateswing_mode_command_template

Only Home Assistant renders templates: with it set, Entity refuses to publish to swing_mode_command_topic.

SwingModeCommandTopic*stringswing_mode_command_topic

Entity.SetSwingMode publishes to it. Device.OnSwingModeCommand receives what is published to it. NewDevice defaults it to <base>/swing_mode/set when swing_modes is set.

SwingModeStateTemplate*ha.Templateswing_mode_state_template

Only Home Assistant renders templates: with it set, Entity skips swing_mode_state_topic when reading state.

SwingModeStateTopic*stringswing_mode_state_topic

Over MQTT, Entity reads the "swing_mode" attribute from it. Device.ReportSwingMode publishes to it. NewDevice defaults it to <base>/swing_mode/state when swing_modes is set.

SwingModes[]stringswing_modes

List of swing modes this climate is capable of running at. Common swing modes that offer translations are off, on, vertical, horizontal and both. Over MQTT, Entity reports it as the "swing_modes" attribute. Set it with WithSwingModes.

Default: [ "on", "off" ]

TargetHumidityCommandTemplate*ha.Templatetarget_humidity_command_template

Only Home Assistant renders templates: with it set, Entity refuses to publish to target_humidity_command_topic.

TargetHumidityCommandTopic*stringtarget_humidity_command_topic

Entity.SetHumidity publishes to it. Device.OnHumidityCommand receives what is published to it. NewDevice defaults it to <base>/target_humidity/set when min_humidity or max_humidity is set.

TargetHumidityStateTemplate*ha.Templatetarget_humidity_state_template

Only Home Assistant renders templates: with it set, Entity skips target_humidity_state_topic when reading state.

TargetHumidityStateTopic*stringtarget_humidity_state_topic

Over MQTT, Entity reads the "humidity" attribute from it. Device.ReportTargetHumidity publishes to it. NewDevice defaults it to <base>/target_humidity/state when min_humidity or max_humidity is set.

TempStep*float64temp_step

The target temperature step in degrees Celsius or Fahrenheit. Over MQTT, Entity reports it as the "target_temp_step" attribute.

Default: 1.0

TemperatureCommandTemplate*ha.Templatetemperature_command_template

Only Home Assistant renders templates: with it set, Entity refuses to publish to temperature_command_topic.

TemperatureCommandTopic*stringtemperature_command_topic

Entity.SetTemperature publishes to it. Device.OnTemperatureCommand receives what is published to it. NewDevice defaults it to <base>/temperature/set.

TemperatureHighCommandTemplate*ha.Templatetemperature_high_command_template
TemperatureHighCommandTopic*stringtemperature_high_command_topic

Entity.SetTemperatureRange publishes to it.

TemperatureHighStateTemplate*ha.Templatetemperature_high_state_template
TemperatureHighStateTopic*stringtemperature_high_state_topic

The library does not use it: it reports a value only a setter with several parameters sets, which is not decoded yet.

TemperatureLowCommandTemplate*ha.Templatetemperature_low_command_template
TemperatureLowCommandTopic*stringtemperature_low_command_topic

Entity.SetTemperatureRange publishes to it.

TemperatureLowStateTemplate*ha.Templatetemperature_low_state_template
TemperatureLowStateTopic*stringtemperature_low_state_topic

The library does not use it: it reports a value only a setter with several parameters sets, which is not decoded yet.

TemperatureStateTemplate*ha.Templatetemperature_state_template

Only Home Assistant renders templates: with it set, Entity skips temperature_state_topic when reading state.

TemperatureStateTopic*stringtemperature_state_topic

Over MQTT, Entity reads the "temperature" attribute from it. Device.ReportTargetTemperature publishes to it. NewDevice defaults it to <base>/temperature/state.

TemperatureUnit*stringtemperature_unit

This determines the native unit of measurement the MQTT device works with. Over MQTT, Entity reports it as the "temperature_unit" attribute.

UniqueId*stringunique_id
ValueTemplate*ha.Templatevalue_template

It applies to every state topic without a template of its own; Entity skips those topics when reading state.

VisibleByDefault*boolvisible_by_default

Default: true

func (*Config) IsMQTTDiscoverySchema()

IsMQTTDiscoverySchema marks Config as a discovery payload (ha.MQTTDiscoverySchema).