bootshorn better temp logging

This commit is contained in:
CroneKorkN 2025-07-13 10:08:52 +02:00
parent c1917d51a0
commit 6f86abd997
Signed by: cronekorkn
SSH key fingerprint: SHA256:v0410ZKfuO1QHdgKBsdQNF64xmTxOF8osF1LIqwTcVw
3 changed files with 15 additions and 6 deletions

View file

@ -3,13 +3,15 @@
import requests
import urllib3
import datetime
import json
import csv
urllib3.disable_warnings()
import os
HUE_IP = "10.0.0.134" # replace with your bridge IP
HUE_APP_KEY = "${hue_app_key}" # local only
HUE_DEVICE_ID = "31f58786-3242-4e88-b9ce-23f44ba27bbe"
TEMPERATURE_LOGFILE = "/opt/bootshorn/temperature.log"
TEMPERATURE_LOG_DIR = "/opt/bootshorn/temperatures"
response = requests.get(
f"https://{HUE_IP}/clip/v2/resource/temperature",
@ -28,6 +30,9 @@ for item in data["data"]:
print(f"@{temperature_date}: {temperature}°C")
with open(TEMPERATURE_LOGFILE, "a+") as logfile:
json.dump([temperature_date.isoformat(), temperature], logfile)
logfile.write("\n")
filename = temperature_date.strftime("%Y-%m-%d_00-00-00.000000%z") + ".log"
logpath = os.path.join(TEMPERATURE_LOG_DIR, filename)
with open(logpath, "a+", newline="") as logfile:
writer = csv.writer(logfile)
writer.writerow([temperature_date.strftime('%Y-%m-%d_%H-%M-%S.%f%z'), temperature])

View file

@ -11,6 +11,10 @@ directories = {
'owner': 'ckn',
'group': 'ckn',
},
'/opt/bootshorn/temperatures': {
'owner': 'ckn',
'group': 'ckn',
},
'/opt/bootshorn/recordings/processed': {
'owner': 'ckn',
'group': 'ckn',

View file

@ -25,7 +25,7 @@ defaults = {
'systemd-timers': {
'bootshorn-temperature': {
'command': '/opt/bootshorn/temperature',
'when': '*:0/15',
'when': '*:0/5',
'working_dir': '/opt/bootshorn',
'user': 'ckn',
'group': 'ckn',