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.
| Method | Over HTTP, calls | Over 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/
| Field | Type | Wire key | Description |
|---|---|---|---|
CurrentHumidity | *float64 | current_humidity | Current humidity. Over MQTT it comes from current_humidity_topic. |
CurrentTemperature | *float64 | current_temperature | Current temperature. Over MQTT it comes from current_temperature_topic. |
FanMode | *string | fan_mode | Fan mode. Over MQTT it comes from fan_mode_state_topic. |
FanModes | *[]string | fan_modes | Fan modes. Over MQTT it comes from the fan_modes option. |
TargetHumidity | *float64 | humidity | Target humidity. Over MQTT it comes from target_humidity_state_topic. |
HVACAction | *HVACAction | hvac_action | Current action. Over MQTT it comes from action_topic. |
HVACModes | []HVACMode | hvac_modes | HVAC modes. Over MQTT it comes from the modes option. |
MaxHumidity | float64 | max_humidity | Max target humidity. Over MQTT it comes from the max_humidity option. |
MaxTemp | float64 | max_temp | Max target temperature. Over MQTT it comes from the max_temp option. |
MinHumidity | float64 | min_humidity | Min target humidity. Over MQTT it comes from the min_humidity option. |
MinTemp | float64 | min_temp | Min target temperature. Over MQTT it comes from the min_temp option. |
PresetMode | *string | preset_mode | Preset. Over MQTT it comes from preset_mode_state_topic. |
PresetModes | *[]string | preset_modes | Presets. Over MQTT it comes from the preset_modes option. |
SupportedFeatures | Feature | supported_features | A set of Feature flags. |
SwingHorizontalMode | *string | swing_horizontal_mode | Horizontal swing mode. Over MQTT it comes from swing_horizontal_mode_state_topic. |
SwingHorizontalModes | *[]string | swing_horizontal_modes | Horizontal swing modes. Over MQTT it comes from the swing_horizontal_modes option. |
SwingMode | *string | swing_mode | Swing mode. Over MQTT it comes from swing_mode_state_topic. |
SwingModes | *[]string | swing_modes | Swing modes. Over MQTT it comes from the swing_modes option. |
TargetHumidityStep | *int | target_humidity_step | |
TargetTemperatureHigh | *float64 | target_temp_high | Upper target temperature. |
TargetTemperatureLow | *float64 | target_temp_low | Lower target temperature. |
TargetTemperatureStep | *float64 | target_temp_step | Target temperature step. Over MQTT it comes from the temp_step option. |
TargetTemperature | *float64 | temperature | Target temperature. Over MQTT it comes from temperature_state_topic. |
TemperatureUnit | string | temperature_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.
| Constant | Value |
|---|---|
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.
| Constant | Value |
|---|---|
FeatureUnknown | 0 |
FeatureTargetTemperature | 1 << 0 |
FeatureTargetTemperatureRange | 1 << 1 |
FeatureTargetHumidity | 1 << 2 |
FeatureFanMode | 1 << 3 |
FeaturePresetMode | 1 << 4 |
FeatureSwingMode | 1 << 5 |
FeatureTurnOff | 1 << 7 |
FeatureTurnOn | 1 << 8 |
FeatureSwingHorizontalMode | 1 << 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.
| Constant | Value |
|---|---|
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.
| Constant | Value |
|---|---|
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.
| Constant | Value |
|---|---|
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.
| Constant | Value |
|---|---|
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.
| Constant | Value |
|---|---|
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/
| Field | Type | Wire key | Description |
|---|---|---|---|
ActionTemplate | *ha.Template | action_template | Only Home Assistant renders templates: with it set, Entity skips action_topic when reading state. |
ActionTopic | *string | action_topic | Over MQTT, Entity reads the "hvac_action" attribute from it. |
Availability | []ha.MQTTAvailability | availability | |
AvailabilityMode | *string | availability_mode | Allowed: "all", "any", "latest". Default: "latest" |
AvailabilityTemplate | *ha.Template | availability_template | |
AvailabilityTopic | *string | availability_topic | Topic to receive the availability payload on. NewDevice defaults it to <base>/availability. |
CurrentHumidityTemplate | *ha.Template | current_humidity_template | Only Home Assistant renders templates: with it set, Entity skips current_humidity_topic when reading state. |
CurrentHumidityTopic | *string | current_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.Template | current_temperature_template | Only Home Assistant renders templates: with it set, Entity skips current_temperature_topic when reading state. |
CurrentTemperatureTopic | *string | current_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 | *string | default_entity_id | |
Device | *ha.MQTTDeviceDetails | device | |
EnabledByDefault | *bool | enabled_by_default | Default: true |
Encoding | *string | encoding | Default: "utf-8" |
EntityCategory | *string | entity_category | Allowed: "config", "diagnostic". |
EntityPicture | *string | entity_picture | An URL to a picture to be assigned. |
FanModeCommandTemplate | *ha.Template | fan_mode_command_template | Only Home Assistant renders templates: with it set, Entity refuses to publish to fan_mode_command_topic. |
FanModeCommandTopic | *string | fan_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.Template | fan_mode_state_template | Only Home Assistant renders templates: with it set, Entity skips fan_mode_state_topic when reading state. |
FanModeStateTopic | *string | fan_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 | []string | fan_modes | List of fan modes this climate is
capable of running at. Common fan modes that offer translations are Default: [ "auto", "low", "medium", "high" ] |
Group | []string | group | |
Icon | *ha.Icon | icon | |
Initial | *float64 | initial | The device initializes with this target temperature. |
JsonAttributesTemplate | *ha.Template | json_attributes_template | |
JsonAttributesTopic | *string | json_attributes_topic | The library does not use it: extra attributes in a JSON document, which is not offered yet. |
MaxHumidity | *float64 | max_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 | *float64 | max_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]any | message_expiry_interval | Retention time interval for published message. |
MinHumidity | *float64 | min_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 | *float64 | min_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.Template | mode_command_template | Only Home Assistant renders templates: with it set, Entity refuses to publish to mode_command_topic. |
ModeCommandTopic | *string | mode_command_topic | Entity.SetHVACMode publishes to it. Device.OnHVACModeCommand receives what is published to it. NewDevice defaults it to <base>/mode/set. |
ModeStateTemplate | *ha.Template | mode_state_template | Only Home Assistant renders templates: with it set, Entity skips mode_state_topic when reading state. |
ModeStateTopic | *string | mode_state_topic | Over MQTT, Entity reads the entity state from it. Device.ReportHVACMode publishes to it. NewDevice defaults it to <base>/mode/state. |
Modes | []string | modes | Over MQTT, Entity reports it as the "hvac_modes" attribute. Set it with WithHVACModes. Default: [ "auto", "off", "cool", "heat", "dry", "fan_only" ] |
Name | *string | name | |
Optimistic | *bool | optimistic | Default: false |
Origin | *ha.DeviceOrigin | origin | |
PayloadAvailable | *string | payload_available | The payload that indicates the device is available (defaults to 'online'). Default: "online" |
PayloadNotAvailable | *string | payload_not_available | The payload that indicates the device is not available (defaults to 'offline'). Default: "offline" |
PayloadOff | *string | payload_off | The payload that represents the "off" state. Entity.TurnOff publishes it. Device.OnPowerCommand matches the received payload against it. Default: "OFF" |
PayloadOn | *string | payload_on | The payload that represents the "on" state. Entity.TurnOn publishes it. Device.OnPowerCommand matches the received payload against it. Default: "ON" |
PowerCommandTemplate | *ha.Template | power_command_template | Only Home Assistant renders templates: with it set, Entity refuses to publish to power_command_topic. |
PowerCommandTopic | *string | power_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 | *float64 | precision | The precision in degrees the thermostat is working at. Allowed: 0.1, 0.5, 1. |
PresetModeCommandTemplate | *ha.Template | preset_mode_command_template | Only Home Assistant renders templates: with it set, Entity refuses to publish to preset_mode_command_topic. |
PresetModeCommandTopic | *string | preset_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 | *string | preset_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.Template | preset_mode_value_template | Only Home Assistant renders templates: with it set, Entity skips preset_mode_state_topic when reading state. |
PresetModes | []string | preset_modes | Over MQTT, Entity reports it as the "preset_modes" attribute. Set it with WithPresetModes. |
Qos | *int | qos | Default: 0 |
Retain | *bool | retain | Default: false |
SwingHorizontalModeCommandTemplate | *ha.Template | swing_horizontal_mode_command_template | Only Home Assistant renders templates: with it set, Entity refuses to publish to swing_horizontal_mode_command_topic. |
SwingHorizontalModeCommandTopic | *string | swing_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.Template | swing_horizontal_mode_state_template | Only Home Assistant renders templates: with it set, Entity skips swing_horizontal_mode_state_topic when reading state. |
SwingHorizontalModeStateTopic | *string | swing_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 | []string | swing_horizontal_modes | List of
horizontal swing modes this climate is capable of running at. Common
horizontal swing modes that offer translations are Default: [ "on", "off" ] |
SwingModeCommandTemplate | *ha.Template | swing_mode_command_template | Only Home Assistant renders templates: with it set, Entity refuses to publish to swing_mode_command_topic. |
SwingModeCommandTopic | *string | swing_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.Template | swing_mode_state_template | Only Home Assistant renders templates: with it set, Entity skips swing_mode_state_topic when reading state. |
SwingModeStateTopic | *string | swing_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 | []string | swing_modes | List of swing modes this climate is
capable of running at. Common swing modes that offer translations are
Default: [ "on", "off" ] |
TargetHumidityCommandTemplate | *ha.Template | target_humidity_command_template | Only Home Assistant renders templates: with it set, Entity refuses to publish to target_humidity_command_topic. |
TargetHumidityCommandTopic | *string | target_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.Template | target_humidity_state_template | Only Home Assistant renders templates: with it set, Entity skips target_humidity_state_topic when reading state. |
TargetHumidityStateTopic | *string | target_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 | *float64 | temp_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.Template | temperature_command_template | Only Home Assistant renders templates: with it set, Entity refuses to publish to temperature_command_topic. |
TemperatureCommandTopic | *string | temperature_command_topic | Entity.SetTemperature publishes to it. Device.OnTemperatureCommand receives what is published to it. NewDevice defaults it to <base>/temperature/set. |
TemperatureHighCommandTemplate | *ha.Template | temperature_high_command_template | |
TemperatureHighCommandTopic | *string | temperature_high_command_topic | Entity.SetTemperatureRange publishes to it. |
TemperatureHighStateTemplate | *ha.Template | temperature_high_state_template | |
TemperatureHighStateTopic | *string | temperature_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.Template | temperature_low_command_template | |
TemperatureLowCommandTopic | *string | temperature_low_command_topic | Entity.SetTemperatureRange publishes to it. |
TemperatureLowStateTemplate | *ha.Template | temperature_low_state_template | |
TemperatureLowStateTopic | *string | temperature_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.Template | temperature_state_template | Only Home Assistant renders templates: with it set, Entity skips temperature_state_topic when reading state. |
TemperatureStateTopic | *string | temperature_state_topic | Over MQTT, Entity reads the "temperature" attribute from it. Device.ReportTargetTemperature publishes to it. NewDevice defaults it to <base>/temperature/state. |
TemperatureUnit | *string | temperature_unit | This determines the native unit of measurement the MQTT device works with. Over MQTT, Entity reports it as the "temperature_unit" attribute. |
UniqueId | *string | unique_id | |
ValueTemplate | *ha.Template | value_template | It applies to every state topic without a template of its own; Entity skips those topics when reading state. |
VisibleByDefault | *bool | visible_by_default | Default: true |
func (*Config) IsMQTTDiscoverySchema()
IsMQTTDiscoverySchema marks Config as a discovery payload (ha.MQTTDiscoverySchema).