Skip to content

Commit

Permalink
Merge pull request #20 from Tvalley71/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Tvalley71 authored Apr 28, 2024
2 parents df60594 + f21878d commit a2b4f0c
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
10 changes: 2 additions & 8 deletions custom_components/dantherm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
)

PLATFORMS = [
# "button", "cover", # left out for now
"button",
"cover",
"number",
"select",
"sensor",
Expand All @@ -48,13 +49,6 @@ async def async_setup(hass: HomeAssistant, config):
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Set up the Dantherm device."""

# Assign the HA configured log level of this module to the dantherm module
this_logger: logging.Logger = logging.getLogger(__name__)
dantherm_logger: logging.Logger = logging.getLogger(DOMAIN)
log_level: int = this_logger.getEffectiveLevel()
dantherm_logger.setLevel(log_level)
this_logger.info("Logging at level: {log_level}")

hass.data.setdefault(DOMAIN, {})
hass.data[DOMAIN][entry.entry_id] = entry.data

Expand Down
2 changes: 1 addition & 1 deletion custom_components/dantherm/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class DanthermSwitchEntityDescription(SwitchEntityDescription):
"alarm": DanthermSensorEntityDescription(
key="alarm",
icon="mdi:alert-circle-outline",
data_address=516,
data_getinternal="get_alarm",
data_zero_icon="mdi:alert-circle-check-outline",
),
"fan_level": DanthermSensorEntityDescription(
Expand Down
17 changes: 12 additions & 5 deletions custom_components/dantherm/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def __init__(
self._current_unit_mode = 0
self._active_unit_mode = 0
self._fan_level = 0
self._alarm = 0
self._entities = []
self.data = {}

Expand All @@ -133,11 +134,6 @@ async def setup(self):
_LOGGER.error("Modbus setup was unsuccessful")
raise ValueError("Modbus setup was unsuccessful")

self._device_installed_components = await self._read_holding_uint16(2)
_LOGGER.debug(
"Installed components (2) = %s",
hex(self._device_installed_components),
)
self._device_installed_components = await self._read_holding_uint16(610)
_LOGGER.debug(
"Installed components (610) = %s",
Expand Down Expand Up @@ -209,6 +205,9 @@ async def async_refresh_entities(self, _now: int | None = None) -> None:
self._fan_level = await self._read_holding_uint32(324)
_LOGGER.debug("Fan level = %s", self._fan_level)

self._alarm = await self._read_holding_uint32(516)
_LOGGER.debug("Alarm = %s", self._alarm)

for entity in self._entities:
await self.async_refresh_entity(entity)

Expand Down Expand Up @@ -266,6 +265,8 @@ def get_fan_level(self):
def get_fan_icon(self) -> str:
"""Get current fan icon."""

if self._alarm != 0:
return "mdi:fan-alert"
result = self.get_op_selection
if result == 0:
return "mdi:fan-off"
Expand All @@ -275,6 +276,12 @@ def get_fan_icon(self) -> str:
return "mdi:fan-clock"
return "mdi:fan"

@property
def get_alarm(self):
"""Get alarm."""

return self._alarm

async def set_active_unit_mode(self, value):
"""Set active unit mode."""

Expand Down
10 changes: 5 additions & 5 deletions custom_components/dantherm/translations/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
"fan_level_selection": {
"name": "Ventilatorindstilling",
"state": {
"0": "Hastighed 0",
"1": "Hastighed 1",
"2": "Hastighed 2",
"3": "Hastighed 3",
"4": "Hastighed 4"
"0": "Niveau 0",
"1": "Niveau 1",
"2": "Niveau 2",
"3": "Niveau 3",
"4": "Niveau 4"
}
},
"week_program_selection": {
Expand Down
2 changes: 1 addition & 1 deletion custom_components/dantherm/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"fan_level_selection": {
"name": "Vitesse ventilation",
"state": {
"0": "Arrêt",
"0": "Niveau 0",
"1": "Niveau 1",
"2": "Niveau 2",
"3": "Niveau 3",
Expand Down

0 comments on commit a2b4f0c

Please sign in to comment.