Skip to content
b4dpxl edited this page Sep 24, 2019 · 4 revisions

The virtual_thermostat climate platform is a thermostat implemented in Home Assistant. It uses a sensor and a switch connected to a heater or air conditioning under the hood. When in heater mode, if the measured temperature is cooler than the target temperature, the heater will be turned on and turned off when the required temperature is reached. When in air conditioning mode, if the measured temperature is hotter than the target temperature, the air conditioning will be turned on and turned off when required temperature is reached. One Virtual Thermostat entity can only control one switch. If you need to activate two switches, one for a heater and one for an air conditioner, you will need two Virtual Thermostat entities.

In the event of the sensor device becoming unavailable, or optionally not updating for a configurable period of time, virtual_thermostat will turn off the switch. This is to prevent the heating running continuously in the event of a sensor malfunctioning (something that happened to me).

When set to away preset mode, virtual_thermostat will update a saved temperature, instead of the target temperature. This allows you to use automations to schedule heating changes without them overriding the current target temperature, as happens with generic_thermostat currently. Please note, currently this has a slightly odd behaviour in the UI; if you change the temperature in the UI and virtual_thermostat is in away preset mode, the temperature reverts to the configured away_temp. The saved temperature is also persisted, so will be retained in case Home Assistant restarts while in away preset mode.

# Example configuration.yaml entry
climate:
  - platform: virtual_thermostat
    name: Study
    heater: switch.study_heater
    target_sensor: sensor.study_temperature

CONFIGURATION VARIABLES

name

(string) (Required)

Name of thermostat.

Default value: Virtual Thermostat

heater

(string) (Required)

entity_id for heater switch, must be a toggle device. Becomes air conditioning switch when ac_mode is set to true."

target_sensor

(string) (Required)

entity_id for a temperature sensor, target_sensor.state must be temperature."

min_temp

(float) (Optional)

Set minimum set point available.

Default value: 7

max_temp

(float) (Optional)

Set maximum set point available.

Default value: 35

target_temp

(float) (Optional)

Set initial target temperature. Failure to set this variable will result in target temperature being set to null on startup. As of version 0.59, it will retain the target temperature set before restart if available.

ac_mode

(boolean) (Optional)

Set the switch specified in the heater option to be treated as a cooling device instead of a heating device.

Default value: false

min_cycle_duration

(time | integer) (Optional)

Set a minimum amount of time that the switch specified in the heater option must be in its current state prior to being switched either off or on.

min_cycle_switch

(string) (Optional)

entity_id for an alternative switch to check for the minimum cycle duration; default to the heater. Must be a toggle device. Useful if the heater indirectly controls another device, e.g. if the heater is one of several virtual_thermostat radiator valves which trigger a boiler to turn on via an automation.

cold_tolerance

(float) (Optional)

Set a minimum amount of difference between the temperature read by the sensor specified in the target_sensor option and the target temperature that must change prior to being switched on. For example, if the target temperature is 25 and the tolerance is 0.5 the heater will start when the sensor equals or goes below 24.5.

Default value: 0.3

hot_tolerance

(float) (Optional)

Set a minimum amount of difference between the temperature read by the sensor specified in the target_sensor option and the target temperature that must change prior to being switched off. For example, if the target temperature is 25 and the tolerance is 0.5 the heater will stop when the sensor equals or goes above 25.5.

Default value: 0.3

keep_alive

(time | integer) (Optional)

Set a keep-alive interval. If set, the switch specified in the heater option will be triggered every time the interval elapses. Use with heaters and A/C units that shut off if they don't receive a signal from their remote for a while. Use also with switches that might lose state. The keep-alive call is done with the current valid climate integration state (either on or off).

sensor_timeout

(time | integer) (Optional)

Set a time threshold for no updates from the sensor. If set, if this time is reached since the sensor last updated the switch specified in the heater option will be turned off. This is to prevent the heating/cooling running excessively in the event of a sensor malfunction.

initial_hvac_mode

(string) (Optional)

Set the initial HVAC mode. Valid values are off, heat or cool. Value has to be double quoted. If this parameter is not set, it is preferable to set a keep_alive value. This is helpful to align any discrepancies between virtual_thermostat and heater state.

away_temp

(float) (Optional)

Set the temperature used by preset_mode: away. If this is not specified, the preset mode feature will not be available."

precision

(float) (Optional)

The desired precision for this device. Can be used to match your actual thermostat's precision. Supported values are 0.1, 0.5 and 1.0."

Default value: 0.5 for Celsius and 1.0 for Fahrenheit.

A full configuration example looks like the one below. min_cycle_duration, keep_alive, and sensor_timeout must contain at least one of the following entries: days:, hours:, minutes:, seconds: or milliseconds:.

Currently the virtual_thermostat climate platform supports 'heat', 'cool' and 'off' hvac modes. You can force your virtual_thermostat to avoid starting by setting HVAC mode to 'off'.

Please note that when changing the preset mode to away, you will force a target temperature change as well that will get restored once the preset mode is set to none again.

# Full example configuration.yaml entry
climate:
  - platform: virtual_thermostat
    name: Study
    heater: switch.study_heater
    target_sensor: sensor.study_temperature
    min_temp: 15
    max_temp: 21
    ac_mode: false
    target_temp: 17
    cold_tolerance: 0.3
    hot_tolerance: 0
    min_cycle_duration:
      seconds: 5
    min_cycle_switch: switch.boiler
    keep_alive:
      minutes: 3
    sensor_timeout:
      minutes: 5
    initial_hvac_mode: "off"
    away_temp: 16
    precision: 0.1