„main.py“ ändern

This commit is contained in:
Manuel Kamper 2023-04-09 18:28:41 +00:00
parent f56176e137
commit f66274cd1d
1 changed files with 13 additions and 5 deletions

18
main.py
View File

@ -8,6 +8,7 @@ import uasyncio as asyncio
import utime as time
import Keypad
import usocket as socket
import urequests as requests
from machine import ADC, Pin
from secrets import secrets
@ -324,7 +325,7 @@ async def TCSBusReader():
if not writerActive:
busValue = busline.read_u16()
val = 1
if (busValue >= 50000): #voltage on TCS:Bus 0...65535
if (busValue >= 30000): #voltage on TCS:Bus 0...65535
val = 1
else:
val = 0
@ -408,9 +409,16 @@ async def TCSBusWriter(message):
writerActive = False
# Main method for external API (=FHEM)
async def ExternalAPI(action):
#todo implement the damn thing!
print(action)
await def ExternalAPI(action):
Logger.LogMessage("External API action: " + action)
if (action == "doorbell"):
response = requests.get(configs['fhem_door_ringed'])
response.close()
elif (action == "frontdoorbell"):
response = requests.get(configs['fhem_frontdoor_ringed'])
response.close()
else:
Logger.LogMessage("Error: Unknown ExternalAPI action!")
pass
# Main method for daily housekeeping
@ -467,4 +475,4 @@ except KeyboardInterrupt:
Oled.fill(0x0000)
Oled.show()
finally:
asyncio.new_event_loop()
asyncio.new_event_loop()