bootshorn better temp logging
This commit is contained in:
parent
c1917d51a0
commit
6f86abd997
3 changed files with 15 additions and 6 deletions
|
@ -3,13 +3,15 @@
|
||||||
import requests
|
import requests
|
||||||
import urllib3
|
import urllib3
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import csv
|
||||||
urllib3.disable_warnings()
|
urllib3.disable_warnings()
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
HUE_IP = "10.0.0.134" # replace with your bridge IP
|
HUE_IP = "10.0.0.134" # replace with your bridge IP
|
||||||
HUE_APP_KEY = "${hue_app_key}" # local only
|
HUE_APP_KEY = "${hue_app_key}" # local only
|
||||||
HUE_DEVICE_ID = "31f58786-3242-4e88-b9ce-23f44ba27bbe"
|
HUE_DEVICE_ID = "31f58786-3242-4e88-b9ce-23f44ba27bbe"
|
||||||
TEMPERATURE_LOGFILE = "/opt/bootshorn/temperature.log"
|
TEMPERATURE_LOG_DIR = "/opt/bootshorn/temperatures"
|
||||||
|
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
f"https://{HUE_IP}/clip/v2/resource/temperature",
|
f"https://{HUE_IP}/clip/v2/resource/temperature",
|
||||||
|
@ -28,6 +30,9 @@ for item in data["data"]:
|
||||||
|
|
||||||
print(f"@{temperature_date}: {temperature}°C")
|
print(f"@{temperature_date}: {temperature}°C")
|
||||||
|
|
||||||
with open(TEMPERATURE_LOGFILE, "a+") as logfile:
|
filename = temperature_date.strftime("%Y-%m-%d_00-00-00.000000%z") + ".log"
|
||||||
json.dump([temperature_date.isoformat(), temperature], logfile)
|
logpath = os.path.join(TEMPERATURE_LOG_DIR, filename)
|
||||||
logfile.write("\n")
|
|
||||||
|
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])
|
|
@ -11,6 +11,10 @@ directories = {
|
||||||
'owner': 'ckn',
|
'owner': 'ckn',
|
||||||
'group': 'ckn',
|
'group': 'ckn',
|
||||||
},
|
},
|
||||||
|
'/opt/bootshorn/temperatures': {
|
||||||
|
'owner': 'ckn',
|
||||||
|
'group': 'ckn',
|
||||||
|
},
|
||||||
'/opt/bootshorn/recordings/processed': {
|
'/opt/bootshorn/recordings/processed': {
|
||||||
'owner': 'ckn',
|
'owner': 'ckn',
|
||||||
'group': 'ckn',
|
'group': 'ckn',
|
||||||
|
|
|
@ -25,7 +25,7 @@ defaults = {
|
||||||
'systemd-timers': {
|
'systemd-timers': {
|
||||||
'bootshorn-temperature': {
|
'bootshorn-temperature': {
|
||||||
'command': '/opt/bootshorn/temperature',
|
'command': '/opt/bootshorn/temperature',
|
||||||
'when': '*:0/15',
|
'when': '*:0/5',
|
||||||
'working_dir': '/opt/bootshorn',
|
'working_dir': '/opt/bootshorn',
|
||||||
'user': 'ckn',
|
'user': 'ckn',
|
||||||
'group': 'ckn',
|
'group': 'ckn',
|
||||||
|
|
Loading…
Reference in a new issue