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 providers in "real-time".
Some data sources (energy, water or gas providers mainly) 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 store states "from the past".
Current projects using this module:
Historical sensors can't provide the current state, Home Assistant will show "undefined" state forever, it's OK and intentional. See technical details.
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 ofDatedState
s which are, basically, astate
+datetime
tuple, 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.
Licenses
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.1.tar.gz
.
File metadata
- Download URL: homeassistant-historical-sensor-0.0.1.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 749b8193673827f8ae24db1a5e3b4da587ffc55a0f0d8da8355372ecd7e027fc |
|
MD5 | db6507fa202e389ea29234b300f47ee1 |
|
BLAKE2b-256 | 6c79aaad0566580786bda4e4863a948ba0148f07d61f8edf00d3c03b8fe28ad8 |
File details
Details for the file homeassistant_historical_sensor-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: homeassistant_historical_sensor-0.0.1-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 662e86caad3c3fb6670a7fece1c8a0991485dd5b10db746f8f40b707747303f5 |
|
MD5 | f1262e46647d4743a1e4bc8ac8a6eed4 |
|
BLAKE2b-256 | 8fb39f6f157ba7be04fc9151d3b94601a6366e9933f993d1bbdef318a62637db |