예제 #1
0
'''
api_key = cred.pihole_key

pifetch = ApiFetcher.PiholeApi(cred.pihole_key, cred.pihole_ip)

commands = ['get_dailystats()', 'get_summary()', 'get_topitems()', 'get_topclients()', 'get_forwarddestinations()', 'get_querytypes()', 'get_allqueries("yes")', 'get_recentblocked()']
for command in commands:
    print('\n', command)
    print(eval(f'pifetch.{command}'))


data = pifetch.get_topitems(3)

print('\n',data['top_queries'], '\n', data['top_ads'])

print('\n',pifetch.get_recentblocked())

allqueries = pifetch.get_allqueries()
print(allqueries)
#print(allqueries[0], datetime.fromtimestamp(int(allqueries[0])).strftime('%Y-%m-%d %H:%M:%S'))
'''
weather_api = ApiFetcher.WeatherApi(cred.weather_key)

#weather = weather_api.get_weather_hourly(info = False)
#weather = weather_api.get_weather_daily(info = False)

weather = weather_api.get_weather_onecall()

print(weather[1])
##Setting up the Display, Buttons and Temperature Reader
button_a = Button(23)
button_b = Button(24)
#button_c = Button(13)
#button_d = Button(5)
disp = gpio_settup.displaysettup()
draw_st7789.clearimage(disp)
temp_reader_power = OutputDevice(21)  #temperature reader GPIO Pin Power
temp_reader_power.on()
dhtDevice = adafruit_dht.DHT22(board.D20,
                               use_pulseio=False)  #temperature reader data pin
time.sleep(1)  #letting the sensor initialize, otherwise error may occur

#Setting up the Class Objects
dht22 = ModuleFetcher.ModuleFetcher(dht22=dhtDevice)
apidat = ApiFetcher.ApiFetcher(apikey=str(cred.weather_key))
fun = FunStuff.FunStuff()
pistat = SysStat.SysStat()

##Setting up some Variables
#sleeping time between 0 and hoursasleep
hoursasleep = 6
sleepy = hoursasleep * 60 * 60
#refreshrate
refreshrate_tempreader = 30  #because it is slow
refreshratelist_tempreader = list(range(0, 61, refreshrate_tempreader))
#fonts
font_1 = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf',
                            22)
font_2 = ImageFont.truetype('/home/pi/Desktop/PythonCode/Fonts/Filxgirl.TTF',
                            25)
#DHT22 sensor library
import adafruit_dht
import board
#other
import time
from PIL import Image, ImageDraw, ImageFont

##Setting up the Display, Buttons and Temperature Reader
button_a = Button(23)  #displaybutton up
button_b = Button(24)  #displaybutton down

disp = gpio_settup.displaysettup()
draw_st7789.clearimage(disp)

#Setting up the Class Objects
weather_api = ApiFetcher.WeatherApi(cred.weather_key)
pihole_api = ApiFetcher.PiholeApi(cred.pihole_key, cred.pihole_ip)
fun = FunStuff.FunStuff()
pistat = SysStat.SysStat()

##Setting up some Variables
#sleeping time between 0 and hoursasleep
hoursasleep = 6
sleepy = hoursasleep * 60 * 60
temp = [1, 2]
script_start = time.time()
#refreshrate
refreshrate_tempreader = 30  #because it is slow
refreshratelist_tempreader = list(range(0, 61, refreshrate_tempreader))
#fonts
font_1 = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf',