Skip to content

Commit

Permalink
Update error handling for compatibility with latest pyModbusTCP
Browse files Browse the repository at this point in the history
The newer version converted the `last_error` method to a @Property.
There's also a new helper @Property that converts error codes to strings for
us, so I just opted to use that.
  • Loading branch information
peplin committed Feb 28, 2024
1 parent 5d83510 commit e4a1965
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions solaredge.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,10 @@ def decode_value(data, scalefactor):

await solar_client.write(datapoint)
else:
# Error during data receive
if client.last_error() == 2:
logger.error(
f"Failed to connect to SolarEdge inverter {client.host()}!"
)
elif client.last_error() == 3 or client.last_error() == 4:
logger.error("Send or receive error!")
elif client.last_error() == 5:
logger.error("Timeout during send or receive operation!")
logger.error(
"Failed while connecting or receiving data from "
f"SolarEdge inverter {client.host}: {client.last_error_as_txt}"
)
except InfluxDBWriteError as e:
logger.error(f"Failed to write to InfluxDb: {e}")
except IOError as e:
Expand Down

0 comments on commit e4a1965

Please sign in to comment.