Hey everyone, I wanted to share a helpful tip I discovered recently about tracking how long Home Assistant has been running. If you’re like me and rely heavily on your smart home setup, knowing the uptime can be really useful for troubleshooting or just keeping tabs on system health.
I stumbled upon a neat solution using Home Assistant’s built-in sensors. By enabling the sensor integration, you can create an uptime sensor that tracks how long your instance has been running without a reboot. This is super handy because it gives you a clear view of your system’s stability over time.
Here’s how you can set it up:
- Enable the Sensor Integration: Go to your
configuration.yamlfile and make sure the sensor integration is enabled. If it’s not there, just add it:
yaml
sensor:
- platform: uptime
- Create a Custom Sensor: You can also create a custom uptime sensor using a template. This allows you to format the output in a way that’s most useful for you. For example:
yaml
sensor:
- platform: template
sensors:
home_assistant_uptime:
value_template: ‘{{ as_timestamp(states.homeassistant.start_time) | timestamp_custom(“%H:%M:%S”) }}’
friendly_name: “Home Assistant Uptime”
icon: mdi:clock-outline
- Visualize the Data: Once the sensor is set up, you can add it to your dashboard. I created a simple card that displays the uptime in hours, minutes, and seconds. It gives me a quick glance at how long my system has been running without any issues.
I also wanted to share a tip for keeping Home Assistant running smoothly. I’ve been using a cron job to reboot my system every week. This helps prevent any potential memory leaks or performance issues that might creep up over time. Here’s how you can set it up:
-
Access Your System’s Crontab: SSH into your Home Assistant machine and open the crontab editor:
bash
crontab -e -
Add the Reboot Schedule: Add this line to reboot your system every Sunday at 2 AM:
bash
0 2 * * Sun reboot
This has been a lifesaver for me. It ensures that my system is always fresh and running optimally. Plus, the uptime sensor lets me know exactly how long it’s been since the last reboot!
I hope this helps someone out there. If you have any questions or tips of your own, feel free to drop them below. Happy automating! ![]()