added devicename tagging

This commit is contained in:
Nicolas Trimborn 2023-07-18 18:25:12 +02:00
parent 3877e91c1b
commit 2d16d728ab
1 changed files with 2 additions and 1 deletions

View File

@ -10,6 +10,7 @@ from prometheus_client import start_http_server
class TasmotaCollector(object):
def __init__(self):
self.ip = getenv('DEVICE_IP')
self.device_name = getenv("DEVICE_NAME").lower()
if not self.ip:
self.ip = "192.168.4.1"
self.user = getenv('USER')
@ -20,7 +21,7 @@ class TasmotaCollector(object):
response = self.fetch()
for key in response:
metric_name = "tasmota_" + key.lower().replace(" ", "_")
metric_name = self.device_name + "_" + key.lower().replace(" ", "_")
metric = response[key].split()[0]
unit = None
if len(response[key].split()) > 1: