Add /display API route

This commit is contained in:
Tanner Collin 2021-12-17 00:34:49 +00:00
parent c52268be2c
commit 8b5643d57d

View File

@ -12,7 +12,7 @@ import pytz
from APSystemsECUR import APSystemsECUR from APSystemsECUR import APSystemsECUR
ECU_IP = '192.168.69.103' ECU_IP = '192.168.69.153'
LISTEN_IP = '192.168.69.100' LISTEN_IP = '192.168.69.100'
ecu = APSystemsECUR(ECU_IP) ecu = APSystemsECUR(ECU_IP)
app = web.Application() app = web.Application()
@ -137,6 +137,10 @@ async def index(request):
async def data(request): async def data(request):
return web.json_response(solar_data) return web.json_response(solar_data)
async def display(request):
res = dict(power=solar_data['actual_total'], brightness=5)
return web.json_response(res)
async def history(request): async def history(request):
try: try:
date = datetime.strptime(request.match_info['date'], '%Y-%m-%d') date = datetime.strptime(request.match_info['date'], '%Y-%m-%d')
@ -157,6 +161,7 @@ async def history(request):
if __name__ == '__main__': if __name__ == '__main__':
app.router.add_get('/', index) app.router.add_get('/', index)
app.router.add_get('/data', data) app.router.add_get('/data', data)
app.router.add_get('/display', display)
app.router.add_get('/history/{date}', history) app.router.add_get('/history/{date}', history)
loop = asyncio.get_event_loop() loop = asyncio.get_event_loop()