developers.home-assistant/blog/2024-02-25-Climate-toggle-service.md
Artur Pragacz a3fd00696a
Add turn on/off methods to climate entity (#2057)
* Add methods to climate entity.

Add turn_on, turn_off, toggle to climate entity.

* Mods

* blog

* Mods

* style

* link to doc

* Fix link

* Mod date

* Update docs/core/entity/climate.md

---------

Co-authored-by: G Johansson <goran.johansson@shiftit.se>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
2024-02-26 19:39:51 +01:00

693 B

author authorURL title
G Johansson https://github.com/gjohansson-ST New Climate entity toggle method

As of Home Assistant Core 2024.3 we have added a new toggle method to ClimateEntity and users can now call climate.toggle in their service calls.

Integrations that support turn_on and turn_off implicitly also support the toggle method.

Read more about the toggle method in our documentation

Example (default implementation):

async def async_toggle(self) -> None:
    """Toggle the entity."""
    if self.hvac_mode == HVACMode.OFF:
        await self.async_turn_on()
    else:
        await self.async_turn_off()