Skip to main content

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:

  1. A new property for sensors: historical_states. This property holds a list of DatedStates which are, basically, a state+datetime tuple, so… the data we want.

  2. A new hook for sensor: async_update_historical_states. This method is responsible to update historical_states property.
    This is the only function that needs to be implemented.

  3. 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 the recorder component of Home Assistant core.

Licenses

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

homeassistant-historical-sensor-0.0.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file homeassistant-historical-sensor-0.0.1.tar.gz.

File metadata

File hashes

Hashes for homeassistant-historical-sensor-0.0.1.tar.gz
Algorithm Hash digest
SHA256 749b8193673827f8ae24db1a5e3b4da587ffc55a0f0d8da8355372ecd7e027fc
MD5 db6507fa202e389ea29234b300f47ee1
BLAKE2b-256 6c79aaad0566580786bda4e4863a948ba0148f07d61f8edf00d3c03b8fe28ad8

See more details on using hashes here.

File details

Details for the file homeassistant_historical_sensor-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for homeassistant_historical_sensor-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 662e86caad3c3fb6670a7fece1c8a0991485dd5b10db746f8f40b707747303f5
MD5 f1262e46647d4743a1e4bc8ac8a6eed4
BLAKE2b-256 8fb39f6f157ba7be04fc9151d3b94601a6366e9933f993d1bbdef318a62637db

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page