Skip to content

Commit

Permalink
Updated some logging strings
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdelprete committed Feb 6, 2024
1 parent eafb8ff commit 0b92777
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion custom_components/abb_powerone_pvi_sunspec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
hass.data.setdefault(DOMAIN, {})
_LOGGER.info(STARTUP_MESSAGE)

_LOGGER.debug("Setup config_entry for ABB")
_LOGGER.debug(f"Setup config_entry for {DOMAIN}")
coordinator = ABBPowerOneFimerCoordinator(hass, config_entry)
# If the refresh fails, async_config_entry_first_refresh() will
# raise ConfigEntryNotReady and setup will try again later
Expand Down
14 changes: 7 additions & 7 deletions custom_components/abb_powerone_pvi_sunspec/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def read_sunspec_modbus(self):
result = True
_LOGGER.debug(f"read_sunspec_modbus: success {result}")
except Exception as modbus_error:
_LOGGER.debug(f"Error in read_sunspec_modbus: {modbus_error}")
_LOGGER.debug(f"read_sunspec_modbus: failed with error: {modbus_error}")
result = False
raise ModbusError() from modbus_error
return result
Expand All @@ -246,7 +246,7 @@ def read_sunspec_modbus_model_1(self):
_LOGGER.debug("(read_rt_1) Slave ID: %s", self._slave_id)
_LOGGER.debug("(read_rt_1) Base Address: %s", self._base_addr)
except ModbusException as modbus_error:
_LOGGER.debug(f"Read M1 modbus_error: {modbus_error}")
_LOGGER.debug(f"ReadM1 modbus_error: {modbus_error}")
raise ModbusError() from modbus_error

# No connection errors, we can start scraping registers
Expand Down Expand Up @@ -540,7 +540,7 @@ def read_sunspec_modbus_model_160(self):
# need to check and try the specific offset address (start address is 41104)
if multi_mppt_id != 160:
_LOGGER.debug(
"(read_rt_160) Model not 160 try another offset - multi_mppt_id: %d",
"(read_rt_160) Model not 160 try another offset - multi_mppt_id: %s",
multi_mppt_id,
)
try:
Expand All @@ -563,18 +563,18 @@ def read_sunspec_modbus_model_160(self):

if multi_mppt_id != 160:
_LOGGER.debug(
"(read_rt_160) Model not 160 (UNO-DM/REACT2) - multi_mppt_id: %d",
"(read_rt_160) Model not 160 (UNO-DM/REACT2) - multi_mppt_id: %s",
multi_mppt_id,
)
return False
else:
_LOGGER.debug(
"(read_rt_160) Model is 160 (UNO-DM/REACT2) - multi_mppt_id: %d",
"(read_rt_160) Model is 160 (UNO-DM/REACT2) - multi_mppt_id: %s",
multi_mppt_id,
)
else:
_LOGGER.debug(
"(read_rt_160) Model is 160 - multi_mppt_id: %d", multi_mppt_id
"(read_rt_160) Model is 160 - multi_mppt_id: %s", multi_mppt_id
)

# skip register 123
Expand All @@ -591,7 +591,7 @@ def read_sunspec_modbus_model_160(self):
# register 130 (# of DC modules)
multi_mppt_nr = decoder.decode_16bit_int()
self.data["mppt_nr"] = multi_mppt_nr
_LOGGER.debug("(read_rt_160) mppt_nr %d", multi_mppt_nr)
_LOGGER.debug("(read_rt_160) mppt_nr %s", multi_mppt_nr)

# if we have at least one DC module
if multi_mppt_nr >= 1:
Expand Down
6 changes: 4 additions & 2 deletions custom_components/abb_powerone_pvi_sunspec/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ def __init__(self, hass: HomeAssistant, config_entry: ConfigEntry) -> None:

async def async_update_data(self):
"""Update data method."""
_LOGGER.debug("ABB SunSpec Update data coordinator update")
_LOGGER.debug(f"Data Coordinator: Update started at {datetime.now()}")
try:
self.last_update_status = await self.api.async_get_data()
self.last_update_time = datetime.now()
_LOGGER.debug(f"Coordinator update completed at {self.last_update_time}")
_LOGGER.debug(
f"Data Coordinator: Update completed at {self.last_update_time}"
)
return self.last_update_status
except Exception as ex:
self.last_update_status = False
Expand Down
7 changes: 1 addition & 6 deletions custom_components/abb_powerone_pvi_sunspec/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry, async_add_entitie
)

_LOGGER.debug(
"(sensor) DC Voltages : single=%d dc1=%d dc2=%d",
"(sensor) DC Voltages : single=%s dc1=%s dc2=%s",
coordinator.api.data["dcvolt"],
coordinator.api.data["dc1volt"],
coordinator.api.data["dc2volt"],
Expand Down Expand Up @@ -100,13 +100,8 @@ def __init__(self, coordinator, config_entry, sensor_data):
self._icon = sensor_data["icon"]
self._device_class = sensor_data["device_class"]
self._state_class = sensor_data["state_class"]
# self._device_name = config_entry.data.get(CONF_NAME)
# self._device_host = config_entry.data.get(CONF_HOST)
self._device_name = self.coordinator.api.name
self._device_host = self.coordinator.api.host
_LOGGER.debug(
f"Sensor - DevName: {self._device_name} DevHost: {self._device_host}"
)
self._device_model = self.coordinator.api.data["comm_model"]
self._device_manufact = self.coordinator.api.data["comm_manufact"]
self._device_sn = self.coordinator.api.data["comm_sernum"]
Expand Down

0 comments on commit 0b92777

Please sign in to comment.