def connect_igrill(addr): while True: try: return IGrillV2Peripheral(addr) except: log.warn("Failed to connect, will retry") time.sleep(RECONNECT_INTERVAL)
import json import time import requests from igrill import IGrillV2Peripheral ADDRESS = 'D4:81:CA:23:67:A1' INTERVAL = 15 url = 'https://your-api/bbq/' if __name__ == '__main__': periph = IGrillV2Peripheral(ADDRESS) while True: temperature = periph.read_temperature() # Probe 1 if temperature[1] != 63536.0: mytemp = {'probe1': temperature[1]} requests.post(url, data=mytemp) # Probe 2 if temperature[2] != 63536.0: mytemp = {'probe1': temperature[2]} requests.post(url, data=mytemp) # Probe 3 if temperature[3] != 63536.0: mytemp = {'probe1': temperature[3]} requests.post(url, data=mytemp) # Probe 4 if temperature[4] != 63536.0:
registry = CollectorRegistry() probe_one = Gauge('bbq_probe_one_temp', 'Temp of probe one', registry=registry) probe_two = Gauge('bbq_probe_two_temp', 'Temp of probe two', registry=registry) probe_three = Gauge('bbq_probe_three_temp', 'Temp of probe three', registry=registry) probe_four = Gauge('bbq_probe_four_temp', 'Temp of probe four', registry=registry) probes = [probe_one, probe_two, probe_three, probe_four] battery = Gauge('bbq_battery', 'Battery of the iGrill', registry=registry) if __name__ == '__main__': periph = IGrillV2Peripheral('70:91:8f:0c:24:cf') while True: temperature = periph.read_temperature() # Probe 1 if temperature[1] != 63536.0: print("bbq/probe1", temperature[1]) probe_one.set(temperature[1]) # Probe 2 if temperature[2] != 63536.0: print("bbq/probe2", temperature[2]) probe_two.set(temperature[2]) # Probe 3 if temperature[3] != 63536.0:
def connect(self, addr): self.periph = IGrillV2Peripheral(addr) return "ok"
from igrill import IGrillV2Peripheral periph = IGrillV2Peripheral("d4:81:ca:20:4e:8e")