Class structure overview

main.py initially creates an instance of DoorOpenerPico which then instantiates one of three types of instance —

  • DoorOpenerPicoBase (button functionality only) if credentials.conf (login credentials) or discovery.conf (Home Assistant discovery payload) can’t be found.

  • DoorOpenerPicoWeb (web server) if the control panel button is held on startup.

  • DoorOpenerPicoNetwork (Home Assistant/MQTT) otherwise.

These three classes have an inheritance relationship in terms of progressive enhancement as such —

Inheritance diagram of dooropenerpico.dooropenerpicoweb

i.e. The majority of base functionality is implemented in DoorOpenerPicoBase, DoorOpenerPicoNetwork inherits from that and implements network/MQTT functionality, and DoorOpenerPicoWeb inherits from that and implements web server functionality.

Aside from this, there are two utility classes —

  • Conf which is used to retrieve and validate .conf files.

  • Print_debug which is used to print debug messages to the console with an optional timestamp.