Postal mail delivery notification using  Hue Motion Sensor

Update 06/06/2024: Philips Hue now also has a contact sensor which may work better depending on your mailbox type.

Update 04/06/2024: I suddenly stopped receiving notifications, and replaced the sensor with the outdoor model. Later I found switching my Google Home Assistant to Gemini also stopped the notifications, so in hindsight that may not have been necessary. But seems a better fit as it is outdoor anyway (and will repurpose the sensor for my security system).

Update 23/01/2023: The article below is now (fortunately) out of date. Using e.g. Alexa or Google Home you can now trigger an action on Philips Hue motion activity, so there is no longer a need to poll the local API yourself.

Update 28/03/2022: I did it all wrong! There is no need (anymore?) to activate a light using the sensor and read the state. Instead you can pull the sensor state straight from the API every 10 seconds and set the result in a global variable. Using a second macro monitoring for the variable to change (indicating an activated sensor) you can trigger your action. It works great! See screenshots.

Update 15/07/2021: I decided to leave an old Android phone active in my house for automation. It is set to check the light every 4 minutes. The motion sensor is configured to revert the light to the o