poll data from real BT device

This commit is contained in:
Hendrik Schutter 2022-12-17 20:50:44 +01:00
parent df9447eee4
commit cccfbf589c
2 changed files with 14 additions and 11 deletions

View File

@ -11,11 +11,12 @@ import threading
from datetime import datetime from datetime import datetime
from urllib.parse import urlsplit, parse_qs from urllib.parse import urlsplit, parse_qs
from random import randrange from random import randrange
from eq3bt import Thermostat
hostName = "127.0.0.1" hostName = "10.10.3.3"
serverPort = 9100 serverPort = 9101
exporter_prefix = "eq3bt_" exporter_prefix = "eq3bt_"
eq3bt_max = "00:1A:22:0F:20:CA" eq3bt_mac = "00:1A:22:0F:20:CA"
request_count = 0 request_count = 0
scrape_healthy = True scrape_healthy = True
@ -73,11 +74,13 @@ def update_metrics():
scrape_healthy = True scrape_healthy = True
eq3bt_metrics.clear() eq3bt_metrics.clear()
try: try:
eq3bt_metrics.append("target_temperature " + str(int(12.2))) thermostat = Thermostat(eq3bt_mac)
eq3bt_metrics.append("valve " + str(int(12.2))) thermostat.update()
eq3bt_metrics.append("low_battery " + str(int(False))) eq3bt_metrics.append("target_temperature " + str(int(thermostat.target_temperature)))
eq3bt_metrics.append("window_open " + str(int(False))) eq3bt_metrics.append("valve " + str(int(thermostat.valve_state)))
eq3bt_metrics.append("low_battery " + str(int(thermostat.low_battery)))
eq3bt_metrics.append("window_open " + str(int(thermostat.window_open)))
except Exception as ex: except Exception as ex:
print("unable to poll data from eq3bt! error: " + str(ex)) print("unable to poll data from eq3bt! error: " + str(ex))
scrape_healthy = False scrape_healthy = False

View File

@ -1,6 +1,6 @@
[Unit] [Unit]
Description=Prometheus gas station exporter for fuel prices Description=Prometheus gas station exporter for fuel prices
Documentation=https://git.mosad.xyz/localhorst/gas-station-exporter Documentation=https://git.mosad.xyz/localhorst/eq3bt-exporter
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
After=wg-quick@wg0.service After=wg-quick@wg0.service
@ -8,8 +8,8 @@ After=wg-quick@wg0.service
[Service] [Service]
Restart=always Restart=always
User=prometheus User=prometheus
WorkingDirectory=/usr/bin/gas-station-exporter/ WorkingDirectory=/usr/bin/eq3bt-exporter/
ExecStart=/usr/bin/python3 gas-station-exporter.py ExecStart=/usr/bin/python3 eq3bt-exporter.py
ExecReload=/bin/kill -HUP $MAINPID ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s TimeoutStopSec=20s
SendSIGKILL=no SendSIGKILL=no