aboutsummaryrefslogtreecommitdiff
path: root/bin/gathertemps.py
blob: 70952e1ac141cdaba2f8d87baecbc17f55b60341 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/python3
#-------------------------------------------------------------------gathertemps.py
# pull temperature sensor data from prometheus server
# 
# (C) D Delmar Davis 2023 
#
# Note: POC lots of hard coded foo here....

import requests
import json

response = requests.get('{0}/api/v1/query'.format('http://bunnyfoofoo:9090'),
                        params={'query': 'home_temperature_farenheit'})
results = response.json()['data']['result']
for r in results:
   print("{0}:{1:.1f}F ".format(r['metric']['instance'][0].upper(),
                               float(r['value'][1])),end='')