There are several snippets of code that poll the door sensor and the lights, checking their status.
Even though we are not using a button, sensors act as if they were buttons as they simulate the same "signal of holding down a button" when they are active (i.e., detecting something). There are several snippets of code that poll the door sensor and the lights, checking their status. If the sensor is active, a message is published back to the client letting it know whether the sensor is on or off. Similar principles can be applied to other smart home products, such as SmartThings, Apple HomeKit devices, or even your HomePod, significantly extending the capabilities of your smart home.