Skip to content

Commit 330f77c

Browse files
committed
1 parent b9789a4 commit 330f77c

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

homeassistant/components/netdata/sensor.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Support gathering system information of hosts which are running netdata."""
22
from datetime import timedelta
3-
import json
43
import logging
54

65
from netdata import Netdata
@@ -187,15 +186,13 @@ def available(self):
187186
async def async_update(self):
188187
"""Get the latest alarms from Netdata REST API."""
189188
await self.netdata.async_update()
190-
info = json.loads(self.netdata.api.alarms)
189+
alarms = self.netdata.api.alarms["alarms"]
191190
self._state = None
192-
number_of_alarms = len(info["alarms"])
191+
number_of_alarms = len(alarms)
192+
n = number_of_alarms
193193

194194
_LOGGER.debug("Host %s has %s alarms", self.name, number_of_alarms)
195195

196-
alarms = info["alarms"]
197-
n = number_of_alarms
198-
199196
for alarm in alarms:
200197
if alarms[alarm]["recipient"] == "silent":
201198
n = n - 1
@@ -217,14 +214,10 @@ def __init__(self, api):
217214
async def async_update(self):
218215
"""Get the latest data from the Netdata REST API."""
219216

220-
original_endpoint = self.api.endpoint
221217
try:
222218
await self.api.get_allmetrics()
223-
# Overwrite endpoint to receive alarms and later restore it again.
224-
self.api.endpoint = "alarms?format=json"
225219
await self.api.get_alarms()
226220
self.available = True
227221
except NetdataError:
228222
_LOGGER.error("Unable to retrieve data from Netdata")
229223
self.available = False
230-
self.api.endpoint = original_endpoint

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy