Add velbus HVAC options (#106570)

* Added HVAC options

* Update manifest.json

required aio to 2023.12.0

* Update manifest.json

* Add files via upload

* Update homeassistant/components/velbus/climate.py

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>

* Update climate.py

removed unused variables for cool and heat

* Update climate.py

removed unused functions

* Update homeassistant/components/velbus/climate.py

Co-authored-by: Erik Montnemery <erik@montnemery.com>

* Update climate.py

accepted changes

* Update climate.py

remove state None for HVAC-MODE

* Update climate.py

changed set_hvac_mode to remove none and only switch when state /= requested mode

* Update climate.py

indent on line 94/95

* Update climate.py

changed set_hvac_mode attribute type to match superclass ClimateEntity (HVACMode)

* Update climate.py

changed def hvac_mode to 2 return options (to avoid any)

* Update climate.py

ruff formatting

* Update climate.py

added serviceValidationError section in hvac_mode setting

* Update climate.py

* Update climate.py

* Update climate.py

* Update climate.py

* Update climate.py

* Update climate.py

* Update climate.py

* Update climate.py

* Update strings.json

* Update strings.json

* Apply suggestions from code review

---------

Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
Co-authored-by: Erik Montnemery <erik@montnemery.com>
This commit is contained in:
Roelf Zomerman 2024-09-10 20:10:52 +04:00 committed by GitHub
parent 3e8fe57fc1
commit 457cb7ace0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 2 deletions

View file

@ -14,6 +14,7 @@ from homeassistant.components.climate import (
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ServiceValidationError
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN, PRESET_MODES
@ -39,8 +40,7 @@ class VelbusClimate(VelbusEntity, ClimateEntity):
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
)
_attr_temperature_unit = UnitOfTemperature.CELSIUS
_attr_hvac_mode = HVACMode.HEAT
_attr_hvac_modes = [HVACMode.HEAT]
_attr_hvac_modes = [HVACMode.HEAT, HVACMode.COOL]
_attr_preset_modes = list(PRESET_MODES)
_enable_turn_on_off_backwards_compatibility = False
@ -66,6 +66,11 @@ class VelbusClimate(VelbusEntity, ClimateEntity):
"""Return the current temperature."""
return self._channel.get_state()
@property
def hvac_mode(self) -> HVACMode:
"""Return the current hvac mode based on cool_mode message."""
return HVACMode.COOL if self._channel.get_cool_mode() else HVACMode.HEAT
@api_call
async def async_set_temperature(self, **kwargs: Any) -> None:
"""Set new target temperatures."""
@ -79,3 +84,15 @@ class VelbusClimate(VelbusEntity, ClimateEntity):
"""Set the new preset mode."""
await self._channel.set_preset(PRESET_MODES[preset_mode])
self.async_write_ha_state()
@api_call
async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set the new hvac mode."""
if hvac_mode not in self._attr_hvac_modes:
raise ServiceValidationError(
translation_domain=DOMAIN,
translation_key="invalid_hvac_mode",
translation_placeholders={"hvac_mode": str(hvac_mode)},
)
await self._channel.set_mode(hvac_mode)
self.async_write_ha_state()

View file

@ -17,6 +17,11 @@
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
}
},
"exceptions": {
"invalid_hvac_mode": {
"message": "Climate mode {hvac_mode} is not supported."
}
},
"services": {
"sync_clock": {
"name": "Sync clock",