From 5fc8b04986192141a8e32a145f8f6c2d661d4533 Mon Sep 17 00:00:00 2001 From: Mike Cifelli <1836280-mike-cifelli@users.noreply.gitlab.com> Date: Fri, 30 Dec 2022 14:16:17 -0500 Subject: [PATCH] Initialize state correctly --- garage.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/garage.py b/garage.py index 754f09b..ed56df9 100644 --- a/garage.py +++ b/garage.py @@ -22,11 +22,14 @@ topic = config['push'].get('topic') def main(): - persistState() - eastButton = Button(eastPin) westButton = Button(westPin) + state['east-door'] = 'closed' if eastButton.is_pressed else 'open' + state['west-door'] = 'closed' if westButton.is_pressed else 'open' + + persistState() + eastButton.when_pressed = eastDoorClosed eastButton.when_released = eastDoorOpened westButton.when_pressed = westDoorClosed