BottlecapDave / HomeAssistant-OctopusEnergy

Unofficial Home Assistant integration for interacting with Octopus Energy
https://bottlecapdave.github.io/HomeAssistant-OctopusEnergy/
MIT License
612 stars 61 forks source link

Missing a date entry #693

Closed ialexyi closed 10 months ago

ialexyi commented 10 months ago

Describe the feature

Hi, Would be lovely to add a sensor entry that indicates the date, as the last measurements has been shown could from two days back or so.

I mean there is no clarity on when the data from. Fir example on the pic the sensor data is from two days back. Sometimes the data is from yesterday.

Thanks

Expected behaviour

Just to add a date entry.

Use Case

To asign the sensor data to it's date.

Confirmation

ialexyi commented 10 months ago

Screenshot_20240109_010831_Gallery

BottlecapDave commented 10 months ago

Hello. The previous consumption data always retrieves the offset of data that has been configured (default previous days worth of data). But if this data isn't available in time, you are correct that it could be longer.

The data you require is already available within the entity as attributes and can be exposed with a template sensor

{{ state_attr('sensor.octopus_energy_electricity_{{METER_SERIAL_NUMBER}}_{{MPAN_NUMBER}}_previous_accumulative_consumption', 'charges')[-1]["end"] }}

The above would show the end date of the consumption data.

If you want to know when the sensor value was last updated, this is available in the HA data

{{ states.sensor.octopus_energy_electricity_{{METER_SERIAL_NUMBER}}_{{MPAN_NUMBER}}_previous_accumulative_consumption.last_updated }}

Because of this, I have no plans to expose such a sensor.

ialexyi commented 10 months ago

Thank you!