use correct timezone

This commit is contained in:
T
2026-06-13 14:08:00 +02:00
parent 23e126a08b
commit 9aa480a348
3 changed files with 11 additions and 6 deletions
+9 -4
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
# vim: ts=2 sw=2 et
import datetime
import grp
import json
import os
@@ -12,7 +13,7 @@ import threading
import time
from configparser import ConfigParser
from dataclasses import dataclass
from datetime import datetime
from zoneinfo import ZoneInfo
import paho.mqtt.client as mqtt
import pifacedigitalio
@@ -148,9 +149,13 @@ class Foodoord:
self.pifacedigital.leds[gpio].turn_off()
def doorbell(self, event):
day = datetime.now().weekday()
# NOTE: Monday is 0; do not unlock on Wednesday
if self.status_open and day != 2:
# ignore doorbell button on Wednesdays
now = datetime.datetime.now(ZoneInfo("Europe/Berlin"))
if ((now.isoweekday() == 3 and now.time() >= datetime.time(14))
or (now.isoweekday() == 4 and now.time() < datetime.time(2))):
return
if self.status_open:
self.pifacedigital.relays[self.RELAYS_UNLOCK].toggle()
time.sleep(2)
self.pifacedigital.relays[self.RELAYS_UNLOCK].toggle()