---
title: "Generic thermostat"
description: "Spook adds an action to the generic thermostat helper that changes the temperature of one of its presets, so an automation can move a preset without a trip to the helper's options."
canonical_url: "https://spook.boo/generic-thermostat"
---
# Generic thermostat

> Spook adds an action to the generic thermostat helper that changes the temperature of one of its presets, so an automation can move a preset without a trip to the helper's options.

The generic thermostat helper turns a heater or an air conditioner on and off, by a temperature sensor. Any switch can be the heater: a smart plug on an electric radiator, a relay on the boiler.

It can have presets: away, comfort, eco, home, sleep and activity, each with a temperature of its own. Pick away, and the thermostat heats to the away temperature. Those temperatures are set on the second page of the helper's options, and only there. An automation cannot change them: not a lower away temperature in the middle of winter, not a sleep temperature you set on your dashboard.

Spook adds an action for that: set preset temperature.

## Actions

Spook adds one action to the generic thermostat integration. You find it wherever you add an action, marked with a 👻.

### Set preset temperature

Changes the temperature of one preset of one or more generic thermostats, like the options of the helper do. Everything else stays as it is: the sensor, the heater, the tolerances, the minimum and maximum, and the other presets.

The change goes through the helper's own options, both pages of them, so Home Assistant checks it the same way it checks what you fill in there. Then Home Assistant reloads the thermostat, as it does after you save its options. The action returns once the thermostat is reloaded, so the next step of your automation already sees its new presets. A thermostat that already has the temperature you give is left alone, without a reload.

A preset the thermostat does not have yet is added, as filling it in on the options does. To take a preset away, give it `null` in YAML: `temperature: null` removes the preset, the way leaving it empty in the options does.

Every entity is checked before the first thermostat changes. An entity that is not a generic thermostat, or one set up in YAML, is refused with an error, and nothing changes. The thermostats change one at a time, in the order you give them.

Run by hand, the action takes an administrator, like the options of a helper do. Your automations can always run it. So can your scripts, unless a user who is not an administrator starts one.

**How to use it**

1. Open the automation or script that should change the preset, and select **Add action**.
2. Search for **set preset temperature**, and select **Generic thermostat: Set preset temperature 👻**.
3. Choose the generic thermostats.
4. Pick the preset, and fill in its new temperature.
5. Select **Save**.

To take a preset away, switch the action to YAML with the three dots menu, and set the temperature to `null`.

**Technical details**

| Action properties |
| --- |
| Action | Generic thermostat: Set preset temperature 👻 |
| Action name | `generic_thermostat.set_preset_temperature` |
| Action targets | No targets |
| Action response | No |
| Spook's influence | Newly added action |
| Tools | [Try this action](https://my.home-assistant.io/redirect/developer_call_service/?service=generic_thermostat.set_preset_temperature) [![Open your Home Assistant instance and show the Actions tool with a specific action selected.](https://my.home-assistant.io/badges/developer_call_service.svg)](https://my.home-assistant.io/redirect/developer_call_service/?service=generic_thermostat.set_preset_temperature) |

| Action data parameters |
| --- |
| Attribute | Type | Required | Default / Example |
| `entity_id` | string or list | Yes | `climate.living_room` |
| `preset` | string | Yes | `away` |
| `temperature` | float or `null` | Yes | `16` |

The preset is one of `away`, `comfort`, `eco`, `home`, `sleep` and `activity`: the presets the options offer. `null` as the temperature takes the preset away.

**Example actions in YAML**

Lower the away temperature:

```yaml
action: generic_thermostat.set_preset_temperature
data:
  entity_id: climate.living_room
  preset: away
  temperature: 14
```

Take the eco preset away:

```yaml
action: generic_thermostat.set_preset_temperature
data:
  entity_id: climate.living_room
  preset: eco
  temperature: null
```

The sleep temperature from a number helper on your dashboard. The automation waits until the number has stayed put for five seconds, so somebody tapping the plus a few times reloads the thermostat once, not five times:

```yaml
alias: Sleep temperature from the dashboard
triggers:
  - trigger: state
    entity_id: input_number.sleep_temperature
    for: "00:00:05"
actions:
  - action: generic_thermostat.set_preset_temperature
    data:
      entity_id: climate.bedroom
      preset: sleep
      temperature: "{{ trigger.to_state.state | float }}"
```

Away keeps the house at 16 °C, so it is not cold when you come back. In December, January and February, heating an empty house to 16 °C costs a lot more, and 14 °C will do. The automation checks every night, and when Home Assistant starts. On the nights the season does not change, the thermostat is left alone. When the house is away right then, the thermostat keeps heating to the old away temperature until away is picked again, so the automation sets the new one straight away:

```yaml
alias: Away temperature for the season
triggers:
  - trigger: time
    at: "00:05:00"
  - trigger: homeassistant
    event: start
variables:
  away: "{{ 14 if now().month in [12, 1, 2] else 16 }}"
actions:
  - action: generic_thermostat.set_preset_temperature
    data:
      entity_id: climate.living_room
      preset: away
      temperature: "{{ away }}"
  - if:
      - condition: state
        entity_id: climate.living_room
        attribute: preset_mode
        state: away
    then:
      - action: climate.set_temperature
        target:
          entity_id: climate.living_room
        data:
          temperature: "{{ away }}"
```

**Known limitations**

- Every change reloads the thermostat. While it reloads, its state is `unavailable` for a moment. Do not drive a preset from something that changes every few seconds, like the temperature outside.
- A thermostat in the preset you change comes back from the reload in that preset, still heating to the old temperature. The new one counts the next time the preset is picked. Picking the preset it is already in does nothing; set the new temperature with `climate.set_temperature` instead, and the thermostat stays in that preset, because the temperature matches it.
- Take away the preset a thermostat is in, and it comes back with no preset, still heating to the temperature of the preset that is gone.
- After a reload in a preset, picking no preset again sets the temperature of the first preset the thermostat has, not the temperature it had before. That is how Home Assistant restores a generic thermostat, with or without Spook.
- Generic thermostats set up in YAML are refused. Their presets are in your configuration: change them there.


## Sitemap

See the full [sitemap](https://spook.boo/sitemap.md) for all pages.
