Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
OStrama committed Oct 28, 2024
1 parent 3d732d0 commit 5ae3ede
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion custom_components/weishaupt_modbus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
try:
hass.data[CONST.DOMAIN].pop(entry.entry_id)
except KeyError:
warnings.warn("KeyError: " + CONST.DOMAIN)
warnings.warn("KeyError: " + str(CONST.DOMAIN))

return unload_ok
15 changes: 9 additions & 6 deletions custom_components/weishaupt_modbus/entities.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Build entitiy List and Update Coordinator."""

import asyncio
from datetime import timedelta
import logging
import warnings

Expand All @@ -14,7 +13,7 @@
SensorEntity,
SensorStateClass,
)
from homeassistant.const import CONF_PORT, CONF_PREFIX, CONF_DOMAIN
from homeassistant.const import CONF_PORT, CONF_PREFIX
from homeassistant.core import callback
from homeassistant.helpers.device_registry import DeviceInfo

Expand Down Expand Up @@ -61,7 +60,8 @@ async def build_entity_list(entries, config_entry, modbusitems, item_type, coord
is True
):
match item_type:
# here the entities are created with the parameters provided by the ModbusItem object
# here the entities are created with the parameters provided
# by the ModbusItem object
case TYPES.SENSOR | TYPES.NUMBER_RO:
entries.append(
MySensorEntity(
Expand Down Expand Up @@ -157,7 +157,8 @@ async def fetch_data(self, idx=None):
for index in to_update:
item = self._modbusitems[index]
match item.type:
# here the entities are created with the parameters provided by the ModbusItem object
# here the entities are created with the parameters provided
# by the ModbusItem object
case TYPES.SENSOR | TYPES.NUMBER_RO | TYPES.NUMBER | TYPES.SELECT:
await self.get_value(item)
case TYPES.SENSOR_CALC:
Expand Down Expand Up @@ -242,11 +243,13 @@ def __init__(self, config_entry, modbus_item, modbus_api) -> None:

dev_postfix = ""
try:
dev_postfix = self._config_entry.data[CONF_DEVICE_POSTFIX]
dev_postfix = "_" + dev_postfix
dev_postfix = "_" + self._config_entry.data[CONF_DEVICE_POSTFIX]
except KeyError:
warnings.warn("Device postfix not defined, use default: ")

if dev_postfix == "_":
dev_postfix = ""

dev_prefix = CONST.DEF_PREFIX
try:
dev_prefix = self._config_entry.data[CONF_PREFIX]
Expand Down

0 comments on commit 5ae3ede

Please sign in to comment.