Skip to content

Commit

Permalink
0.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
lolouk44 committed Sep 18, 2022
1 parent b4ca057 commit 9af75a1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.2.3] - 2022-09-18
### Changed
- Gracefully handle when unable to read serial port ([fixes #17](https://github.com/lolouk44/CurrentCost_HA_CC/issues/17))

## [0.2.2] - 2021-12-14
### Changed
- Updated Sensor definition: replace deprecated device_state_attributes with extra_state_attributes
Expand Down
2 changes: 1 addition & 1 deletion custom_components/currentcost/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "currentcost",
"name": "Current Cost",
"version": "0.2.2",
"version": "0.2.3",
"documentation": "https://github.com/lolouk44/CurrentCost_HA_CC",
"requirements": [
"pyserial-asyncio==0.4",
Expand Down
11 changes: 7 additions & 4 deletions custom_components/currentcost/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ async def serial_read(self, device, rate, **kwargs):
url=device, baudrate=rate, **kwargs
)
while True:
line = await reader.readline()
line = line.decode("utf-8").strip()
_LOGGER.debug("Line Received: %s", line)

try:
line = await reader.readline()
line = line.decode("utf-8").strip()
_LOGGER.debug("Line Received: %s", line)
except Exception as error:
_LOGGER.error("Error Reading From Serial Port: %s", error)
pass
try:
data = xmltodict.parse(line)
# Data can be parsed from line, continuing
Expand Down

0 comments on commit 9af75a1

Please sign in to comment.