0bbf01e0077160f4982c4b826cf0d73485cdbf92
Home Assistant Logger
This script connects to a Home Assistant instance, fetches temperature and humidity data, stores it, and generates an HTML report.
Prerequisites
- Docker
How to Use
1. Build the Docker Image
docker build -t ha-logger .
2. Run the Docker Container
You need to provide your Home Assistant URL and a Long-Lived Access Token as environment variables.
docker run --rm -v $(pwd):/app
-e HA_URL="http://your-home-assistant-ip:8123"
-e HA_TOKEN="your-long-lived-access-token"
ha-logger
- Replace
"http://your-home-assistant-ip:8123"with the URL of your Home Assistant instance. - Replace
"your-long-lived-access-token"with your token.
The -v $(pwd):/app command mounts the current directory into the container, so the output files (index.html and sensor_data.json) are created and updated in your project folder.
How it Works
- The script connects to your Home Assistant instance using the provided URL and token.
- It fetches all devices and filters for sensors that have a unit of
°C(Celsius) or%(for humidity). - The new readings are appended to the
sensor_data.jsonfile. - An
index.htmlfile is generated, displaying the latest readings and a searchable, sortable history of all readings.
Generated Files
sensor_data.json: Stores the historical data for all sensor readings.index.html: The generated HTML report. Open this file in your browser to see the sensor data.
Description
Languages
HTML
79.7%
Python
9.8%
Jinja
9.2%
Dockerfile
1.3%