Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add object type to debug logging #465

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 33 additions & 43 deletions custom_components/solaredge_modbus_multi/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,9 @@ async def init_device(self) -> None:
for name, value in iter(self.decoded_common.items()):
_LOGGER.debug(
(
f"Inverter {self.inverter_unit_id}: "
f"I{self.inverter_unit_id}: "
f"{name} {hex(value) if isinstance(value, int) else value}"
f"{type(value)}"
),
)

Expand Down Expand Up @@ -812,8 +813,9 @@ async def init_device(self) -> None:
for name, value in iter(self.decoded_mmppt.items()):
_LOGGER.debug(
(
f"Inverter {self.inverter_unit_id} MMPPT: "
f"{name} {hex(value) if isinstance(value, int) else value}"
f"I{self.inverter_unit_id} MMPPT: "
f"{name} {hex(value) if isinstance(value, int) else value} "
f"{type(value)}"
),
)

Expand All @@ -823,19 +825,19 @@ async def init_device(self) -> None:
or self.decoded_mmppt["mmppt_DID"] not in [160]
or self.decoded_mmppt["mmppt_Units"] not in [2, 3]
):
_LOGGER.debug(f"Inverter {self.inverter_unit_id} is NOT Multiple MPPT")
_LOGGER.debug(f"I{self.inverter_unit_id} is NOT Multiple MPPT")
self.decoded_mmppt = None

else:
_LOGGER.debug(f"Inverter {self.inverter_unit_id} is Multiple MPPT")
_LOGGER.debug(f"I{self.inverter_unit_id} is Multiple MPPT")

except ModbusIOError:
raise ModbusReadError(
f"No response from inverter ID {self.inverter_unit_id}"
)

except ModbusIllegalAddress:
_LOGGER.debug(f"Inverter {self.inverter_unit_id} is NOT Multiple MPPT")
_LOGGER.debug(f"I{self.inverter_unit_id} is NOT Multiple MPPT")
self.decoded_mmppt = None

self.hub.mmppt_common[self.inverter_unit_id] = self.decoded_mmppt
Expand Down Expand Up @@ -1039,10 +1041,7 @@ async def read_modbus_data(self) -> None:
except ModbusIllegalAddress:
self.global_power_control = False
_LOGGER.debug(
(
f"Inverter {self.inverter_unit_id}: "
"global power control NOT available"
)
(f"I{self.inverter_unit_id}: " "global power control NOT available")
)

except ModbusIOError:
Expand Down Expand Up @@ -1078,7 +1077,7 @@ async def read_modbus_data(self) -> None:
self.advanced_power_control = False
_LOGGER.debug(
(
f"Inverter {self.inverter_unit_id}: "
f"I{self.inverter_unit_id}: "
"advanced power control NOT available"
)
)
Expand Down Expand Up @@ -1120,10 +1119,7 @@ async def read_modbus_data(self) -> None:
except ModbusIllegalAddress:
self.site_limit_control = False
_LOGGER.debug(
(
f"Inverter {self.inverter_unit_id}: "
"site limit control NOT available"
)
(f"I{self.inverter_unit_id}: " "site limit control NOT available")
)

except ModbusIOError:
Expand Down Expand Up @@ -1157,9 +1153,7 @@ async def read_modbus_data(self) -> None:
except KeyError:
pass

_LOGGER.debug(
(f"Inverter {self.inverter_unit_id}: Ext_Prod_Max NOT available")
)
_LOGGER.debug((f"I{self.inverter_unit_id}: Ext_Prod_Max NOT available"))

except ModbusIOError:
raise ModbusReadError(
Expand All @@ -1171,7 +1165,9 @@ async def read_modbus_data(self) -> None:
display_value = float_to_hex(value)
else:
display_value = hex(value) if isinstance(value, int) else value
_LOGGER.debug(f"Inverter {self.inverter_unit_id}: {name} {display_value}")
_LOGGER.debug(
f"I{self.inverter_unit_id}: " f"{name} {display_value} {type(value)}"
)

""" Power Control Options: Storage Control """
if (
Expand Down Expand Up @@ -1215,16 +1211,14 @@ async def read_modbus_data(self) -> None:
else:
display_value = hex(value) if isinstance(value, int) else value
_LOGGER.debug(
f"Inverter {self.inverter_unit_id}: {name} {display_value}"
f"I{self.inverter_unit_id}: "
f"{name} {display_value} {type(value)}"
)

except ModbusIllegalAddress:
self.decoded_storage_control = False
_LOGGER.debug(
(
f"Inverter {self.inverter_unit_id}: "
"storage control NOT available"
)
(f"I{self.inverter_unit_id}: " "storage control NOT available")
)

except ModbusIOError:
Expand Down Expand Up @@ -1333,8 +1327,9 @@ async def init_device(self) -> None:
for name, value in iter(self.decoded_common.items()):
_LOGGER.debug(
(
f"Inverter {self.inverter_unit_id} meter {self.meter_id}: "
f"{name} {hex(value) if isinstance(value, int) else value}"
f"I{self.inverter_unit_id}M{self.meter_id}: "
f"{name} {hex(value) if isinstance(value, int) else value} "
f"{type(value)}"
),
)

Expand Down Expand Up @@ -1464,8 +1459,9 @@ async def read_modbus_data(self) -> None:
for name, value in iter(self.decoded_model.items()):
_LOGGER.debug(
(
f"Inverter {self.inverter_unit_id} meter {self.meter_id}: "
f"{name} {hex(value) if isinstance(value, int) else value}"
f"I{self.inverter_unit_id}M{self.meter_id}: "
f"{name} {hex(value) if isinstance(value, int) else value} "
f"{type(value)}"
),
)

Expand Down Expand Up @@ -1571,8 +1567,8 @@ async def init_device(self) -> None:
display_value = hex(value) if isinstance(value, int) else value
_LOGGER.debug(
(
f"Inverter {self.inverter_unit_id} batt {self.battery_id}: "
f"{name} {display_value}"
f"I{self.inverter_unit_id}B{self.battery_id}: "
f"{name} {display_value} {type(value)}"
),
)

Expand Down Expand Up @@ -1675,20 +1671,14 @@ async def read_modbus_data(self) -> None:

for name, value in iter(self.decoded_model.items()):
if isinstance(value, float):
_LOGGER.debug(
(
f"Inverter {self.inverter_unit_id} batt {self.battery_id}: "
f"{name} {float_to_hex(value)}"
),
)

display_value = float_to_hex(value)
else:
_LOGGER.debug(
(
f"Inverter {self.inverter_unit_id} batt {self.battery_id}: "
f"{name} {hex(value) if isinstance(value, int) else value}"
),
)
display_value = hex(value) if isinstance(value, int) else value

_LOGGER.debug(
f"I{self.inverter_unit_id}B{self.battery_id}: "
f"{name} {display_value} {type(value)}"
)

@property
def online(self) -> bool:
Expand Down