Skip to content

Commit

Permalink
Fix Handled % before first message being received (division by zero)
Browse files Browse the repository at this point in the history
  • Loading branch information
elad-bar committed Apr 21, 2022
1 parent 50bbe33 commit 643518c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.2.2

- Hotfix for `Handled %` before first message is being received (division by zero)

## 1.2.1

- Fixed incorrect lookup value for Rate (Sent / Received) per device
Expand Down
5 changes: 4 additions & 1 deletion custom_components/edgeos/clients/web_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ def is_initialized(self):

@property
def messages_handled_percentage(self):
percentage = (self.messages_received - self.messages_ignored) / self.messages_received
received = self.messages_received
ignored = self.messages_ignored

percentage = 0 if received == 0 else (received - ignored) / received
result = f"{percentage:.3%}"

return result
Expand Down
2 changes: 1 addition & 1 deletion custom_components/edgeos/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"codeowners": ["@elad-bar"],
"requirements": ["aiohttp"],
"config_flow": true,
"version": "1.2.1",
"version": "1.2.2",
"iot_class": "local_polling"
}

0 comments on commit 643518c

Please sign in to comment.