Skip to content

Commit

Permalink
Add HEATING_COOLING translations
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ committed Aug 21, 2024
1 parent 565d852 commit 2d98d4b
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- Clear cache on schema migration
- Load al paramset descriptions into cache
- Refactor config flow. some options are now on the advanced page.
- Add HEATING_COOLING translations

# Version 1.64.0 (2024-08-05)

Expand Down
11 changes: 11 additions & 0 deletions custom_components/homematicip_local/entity_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
HmEntityDescription,
HmGenericEntity,
HmNumberEntityDescription,
HmSelectEntityDescription,
HmSensorEntityDescription,
)

Expand Down Expand Up @@ -95,6 +96,15 @@
),
}

_SELECT_DESCRIPTIONS_BY_PARAM: Mapping[str | tuple[str, ...], EntityDescription] = {
"HEATING_COOLING": HmSelectEntityDescription(
key="HEATING_COOLING",
entity_category=EntityCategory.CONFIG,
entity_registry_enabled_default=False,
translation_key="heating_cooling",
)
}

_SENSOR_DESCRIPTIONS_BY_PARAM: Mapping[str | tuple[str, ...], EntityDescription] = {
"AIR_PRESSURE": HmSensorEntityDescription(
key="AIR_PRESSURE",
Expand Down Expand Up @@ -734,6 +744,7 @@
HmPlatform.BINARY_SENSOR: _BINARY_SENSOR_DESCRIPTIONS_BY_PARAM,
HmPlatform.BUTTON: _BUTTOM_DESCRIPTIONS_BY_PARAM,
HmPlatform.NUMBER: _NUMBER_DESCRIPTIONS_BY_PARAM,
HmPlatform.SELECT: _SELECT_DESCRIPTIONS_BY_PARAM,
HmPlatform.SENSOR: _SENSOR_DESCRIPTIONS_BY_PARAM,
HmPlatform.SWITCH: _SWITCH_DESCRIPTIONS_BY_PARAM,
}
Expand Down
6 changes: 3 additions & 3 deletions custom_components/homematicip_local/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ class HaHomematicSelect(HaHomematicGenericRestoreEntity[HmSelect], SelectEntity)
def options(self) -> list[str]:
"""Return the options."""
if options := self._hm_entity.values:
return list(options)
return [option.lower() for option in options]
return []

@property
def current_option(self) -> str | None:
"""Return the currently selected option."""
if self._hm_entity.is_valid:
return self._hm_entity.value
return self._hm_entity.value.lower() if self._hm_entity.value is not None else None
if (
self.is_restored
and self._restored_state
Expand All @@ -104,7 +104,7 @@ def current_option(self) -> str | None:

async def async_select_option(self, option: str) -> None:
"""Select an option."""
await self._hm_entity.send_value(option)
await self._hm_entity.send_value(option.upper())


class HaHomematicSysvarSelect(HaHomematicGenericSysvarEntity[HmSysvarSelect], SelectEntity):
Expand Down
9 changes: 9 additions & 0 deletions custom_components/homematicip_local/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@
"name": "valve opening"
}
},
"select": {
"heating_cooling": {
"name": "Operating mode",
"state": {
"heating": "heating",
"cooling": "cooling"
}
}
},
"sensor": {
"activity_state": {
"name": "Activity State"
Expand Down
6 changes: 6 additions & 0 deletions custom_components/homematicip_local/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from homeassistant.components.binary_sensor import BinarySensorEntityDescription
from homeassistant.components.button import ButtonEntityDescription
from homeassistant.components.number import NumberEntityDescription
from homeassistant.components.select import SelectEntityDescription
from homeassistant.components.sensor import SensorEntityDescription
from homeassistant.const import CONF_TYPE
from homeassistant.exceptions import HomeAssistantError
Expand Down Expand Up @@ -138,6 +139,11 @@ class HmNumberEntityDescription(HmEntityDescription, NumberEntityDescription):
multiplier: int | None = None


@dataclass(frozen=True, kw_only=True)
class HmSelectEntityDescription(HmEntityDescription, SelectEntityDescription):
"""Class describing Homematic(IP) Local select entities."""


@dataclass(frozen=True, kw_only=True)
class HmSensorEntityDescription(HmEntityDescription, SensorEntityDescription):
"""Class describing Homematic(IP) Local sensor entities."""
Expand Down
9 changes: 9 additions & 0 deletions custom_components/homematicip_local/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@
"name": "Ventilöffnung"
}
},
"select": {
"heating_cooling": {
"name": "Betriebsmodus",
"state": {
"heating": "Heizung",
"cooling": "Kühlung"
}
}
},
"sensor": {
"activity_state": {
"name": "Aktivitätszustand"
Expand Down
9 changes: 9 additions & 0 deletions custom_components/homematicip_local/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,15 @@
"name": "valve opening"
}
},
"select": {
"heating_cooling": {
"name": "Operating mode",
"state": {
"heating": "heating",
"cooling": "cooling"
}
}
},
"sensor": {
"activity_state": {
"name": "Activity State"
Expand Down

0 comments on commit 2d98d4b

Please sign in to comment.