mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
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:
parent
3e8fe57fc1
commit
457cb7ace0
@ -14,6 +14,7 @@ from homeassistant.components.climate import (
|
|||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
from homeassistant.exceptions import ServiceValidationError
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN, PRESET_MODES
|
from .const import DOMAIN, PRESET_MODES
|
||||||
@ -39,8 +40,7 @@ class VelbusClimate(VelbusEntity, ClimateEntity):
|
|||||||
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
|
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.PRESET_MODE
|
||||||
)
|
)
|
||||||
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||||
_attr_hvac_mode = HVACMode.HEAT
|
_attr_hvac_modes = [HVACMode.HEAT, HVACMode.COOL]
|
||||||
_attr_hvac_modes = [HVACMode.HEAT]
|
|
||||||
_attr_preset_modes = list(PRESET_MODES)
|
_attr_preset_modes = list(PRESET_MODES)
|
||||||
_enable_turn_on_off_backwards_compatibility = False
|
_enable_turn_on_off_backwards_compatibility = False
|
||||||
|
|
||||||
@ -66,6 +66,11 @@ class VelbusClimate(VelbusEntity, ClimateEntity):
|
|||||||
"""Return the current temperature."""
|
"""Return the current temperature."""
|
||||||
return self._channel.get_state()
|
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
|
@api_call
|
||||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||||
"""Set new target temperatures."""
|
"""Set new target temperatures."""
|
||||||
@ -79,3 +84,15 @@ class VelbusClimate(VelbusEntity, ClimateEntity):
|
|||||||
"""Set the new preset mode."""
|
"""Set the new preset mode."""
|
||||||
await self._channel.set_preset(PRESET_MODES[preset_mode])
|
await self._channel.set_preset(PRESET_MODES[preset_mode])
|
||||||
self.async_write_ha_state()
|
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()
|
||||||
|
@ -17,6 +17,11 @@
|
|||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"exceptions": {
|
||||||
|
"invalid_hvac_mode": {
|
||||||
|
"message": "Climate mode {hvac_mode} is not supported."
|
||||||
|
}
|
||||||
|
},
|
||||||
"services": {
|
"services": {
|
||||||
"sync_clock": {
|
"sync_clock": {
|
||||||
"name": "Sync clock",
|
"name": "Sync clock",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user