DIY Doorbell integration

Hi All

I am brand new to home assistant and have been playing with it for the last few days. My doorbell project consists of a raspberry pi (original b model), switch, motion sensor and a camera. I have already designed and 3d printed the enclosure that fits in besides my front door. I also have been learning python basics and have the project working to a point its publishing to my local mqtt server on button press.

Here is a quick demo

My question is how do I get home assist to show the last time the button was pressed and possibly how long ago? Currently when the doorbell is pressed its publishing “pressed” to “stat/doorbell” home assist is seeing this when I add the doorbell in as a sensor and creating an entity card. Its just showing doorbell and pressed.

many thanks


In case of Binary Sensor HA automatically show last time tripped (minutes) and create graph showing On/0ff over time

Switches show in same way

Are you not seeing this in HA?

You can also access the value of last_changed using macro. For example as described in this thread Formatting template sensor state last changed.

Thanks Im getting there
have changed it to a binary_sensor in my configuration.yaml, changed my python script to publish “ON” and “OFF”.

My card now shows the stats Off, and how long ago the last change was. Now to just figure out how to get it to show a timestamp instead of “Off” will be perfect :slight_smile: pretty sure its to do with value_template in the configuration.yaml but i dont understand why i cant configure it in the card. so much to learn!

Is that Cover Component showing?

Maybe try template switch component
Template binary sensor