glances_api 0.6.0__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: glances_api
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Python API for interacting with Glances
5
5
  Home-page: https://github.com/home-assistant-ecosystem/python-glances-api
6
6
  License: MIT
@@ -155,10 +155,18 @@ class Glances:
155
155
  sensor_data["network"] = {}
156
156
  for network in networks:
157
157
  time_since_update = network["time_since_update"]
158
+ # New name of network sensors in Glances v4
159
+ rx = network.get("bytes_recv_rate_per_sec")
160
+ tx = network.get("bytes_sent_rate_per_sec")
161
+ # Compatibility with Glances v3
162
+ if rx is None and (rx_bytes := network.get("rx")) is not None:
163
+ rx = round(rx_bytes / time_since_update)
164
+ if tx is None and (tx_bytes := network.get("tx")) is not None:
165
+ tx = round(tx_bytes / time_since_update)
158
166
  sensor_data["network"][network["interface_name"]] = {
159
167
  "is_up": network.get("is_up"),
160
- "rx": round(network["rx"] / time_since_update),
161
- "tx": round(network["tx"] / time_since_update),
168
+ "rx": rx,
169
+ "tx": tx,
162
170
  "speed": round(network["speed"] / 1024**3, 1),
163
171
  }
164
172
  data = self.data.get("dockers") or self.data.get("containers")
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "glances_api"
3
- version = "0.6.0"
3
+ version = "0.7.0"
4
4
  description = "Python API for interacting with Glances"
5
5
  authors = ["Fabian Affolter <fabian@affolter-engineering.ch>"]
6
6
  homepage = "https://github.com/home-assistant-ecosystem/python-glances-api"
File without changes
File without changes