Historical sensors for HomeAssistant
Project description
Historical sensors for Home Assistant
Feed historical data into Home Assistant database.
HomeAssistant architecture is built around polling (or pushing) data from devices, or data providers, in "real-time". Some data sources (e.g, energy, water or gas providers) can't be polled in real-time or readings are not accurate. However reading historical data, like last month consumption, it's possible and accurate. This module adds support to this.
This module uses the recoder
component and custom state creation to store states "from the past".
Current projects using this module:
Technical details
Q. How it's accomplished?.
A. It's a relatively easy answer but needs to be broken into some pieces:
-
A new property for sensors:
historical_states
. This property holds a list ofHistoricalState
s which are, basically, astate
+datetime
(with tzinfo), so… the data we want. -
A new hook for sensor:
async_update_historical_states
. This method is responsible to updatehistorical_states
property.
This is the only function that needs to be implemented. -
A new method, implemented by HistoricalSensor class:
async_write_ha_historical_states
. This method handles the details of creating tweaked states in the past and write them into the database using therecorder
component of Home Assistant core.
Q. Something else?
A. Historical sensors can't provide the current state, Home Assistant will show "undefined" state forever, it's OK and intentional.
External vs. internal statistics
Importing CSV files
Licenses
- Logo by Danny Allen (Public domain license) https://publicdomainvectors.org/es/vectoriales-gratuitas/Icono-de-configuraci%C3%B3n-del-reloj/88901.html
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file homeassistant-historical-sensor-0.0.6.tar.gz
.
File metadata
- Download URL: homeassistant-historical-sensor-0.0.6.tar.gz
- Upload date:
- Size: 9.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50ec6e9ce373d66e20159f015c864bb52bdbd2697ed9ed4b9e494d0ba3aa668c |
|
MD5 | 637375c39f1880987a20c49356894ec8 |
|
BLAKE2b-256 | 3af99441e49cd2fa9f371a5c639eaba265eea17baccf9233e28a4633fcb18b14 |
File details
Details for the file homeassistant_historical_sensor-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: homeassistant_historical_sensor-0.0.6-py3-none-any.whl
- Upload date:
- Size: 12.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.17
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69a7ab28df4fcac9af2cd2355032ad4edb7a8a6b24b38dca5491c21d4ed3dcdf |
|
MD5 | 6d5ab770fbc7aacea6b21013e86689e5 |
|
BLAKE2b-256 | c26e2a0adfadc85c07a28d69997f7a7034333d001558b9025918a45dcde3ee2f |