Something went wrong. Try again.
Blink some lights when the back door is open
Something went wrong. Try again.
Files
- Python 100%
README.md
Doggie Doorwatch #
Provides visual cues to remind me that (a) the back door is open, and (b) for about how long it has been open. I'm using micropython to program an Arduino Nano w/ ESP32.
Thanks to my two dogs, Pippin and Sonny. If I could wish for anything, I would wish for the contentment of a dog basking in the sun.
HOT GIRLS DO HOT GIRL SHIT #
Fun features:
- Async implementations for MQTT and WLAN
- Each features a
connectedevent for easy state querying - Because
umqtt.simple2does not handle aconnectedstate, I put in a wrapper for each MQTT call to check for and update the state - Each also features a default reconnect behavior that begins with staggered backoff times before falling back to once every five minutes
- Each features a
- Robust MQTT Connection
- MQTT defaults to pinging the broker for
(1/2 * keepalive (seconds))to help persist connection - MQTTHandler reads the timestamp on the last received message to force a reconnect if we've exceeded the keepalive interval
- Since Mosquitto uses
(1.5 * keepalive)before forcing disconnect, we should be good to go
- MQTT defaults to pinging the broker for
- LEDSets
- Wrapper for making the LED behavior a little clearer, and for implementing custom colors (more or less)
- Since it's an Arduino ESP32, the low means "ON" and the high means "OFF", when typically it's supposed to be other way around. This wrapper just replaces these usual signals with on/off wrappers to obscure this behavior.
- Use a
secrets.pyfor passwords
What does it do:
- Connects to Wifi, then connects to local MQTT broker
- When HomeAssistant (HASS) determines the back door has been opened, it'll send an MQTT message which can be intercepted by the Arduino
- Arduino then blinks its onboard LEDs as a function of total time elapsed
- Green for < 10 minutes
- Blue for > 10 but < 20 minutes
- Red for >= 20 minutes, because by then the door should definitely be closed
- When the door is closed, HASS sends an MQTT message that can be intercepted by the board to update its state
- And then the blinking should stop