Skip to content

Commit

Permalink
Handle 'now' argument in PollUpdateMixin._async_historical_handle_update
Browse files Browse the repository at this point in the history
* Fixes issue #8
* Version bump
  • Loading branch information
ldotlopez committed Jul 30, 2023
1 parent 6f2e155 commit 1e532f5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions custom_components/delorian/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/ldotlopez/ha-historical-sensor/issues",
"requirements": [
"homeassistant-historical-sensor==2.0.0b0"
"homeassistant-historical-sensor==2.0.0rc2"
],
"version": "2.0.0b0"
"version": "2.0.0rc2"
}
9 changes: 5 additions & 4 deletions custom_components/delorian/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ def __init__(self, *args, **kwargs):
self._attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
self._attr_device_class = SensorDeviceClass.ENERGY

# We DON'T opt-in for statistics. Why?
# Those stats are generated from a real sensor, this sensor but…
# we don't want that hass try to do anything with those statistics
# because we handled generation and importing
# We DON'T opt-in for statistics (don't set state_class). Why?
#
# Those statistics are generated from a real sensor, this sensor, but we don't
# want that hass try to do anything with those statistics because we
# (HistoricalSensor) handle generation and importing
#
# self._attr_state_class = SensorStateClass.MEASUREMENT

Expand Down
6 changes: 3 additions & 3 deletions homeassistant_historical_sensor/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import logging
from abc import abstractmethod
from datetime import timedelta
from datetime import datetime, timedelta

import sqlalchemy.exc
import sqlalchemy.orm
Expand Down Expand Up @@ -396,7 +396,7 @@ async def async_added_to_hass(self) -> None:
await self._async_historical_handle_update()
self._remove_time_tracker_fn = async_track_time_interval(
self.hass,
self._async_historical_handle_update, # type: ignore[call-arg]
self._async_historical_handle_update,
self.UPDATE_INTERVAL,
)

Expand All @@ -409,6 +409,6 @@ async def async_will_remove_from_hass(self) -> None:
if self._remove_time_tracker_fn:
self._remove_time_tracker_fn()

async def _async_historical_handle_update(self) -> None:
async def _async_historical_handle_update(self, _: datetime | None = None) -> None:
await self.async_update_historical()
await self.async_write_ha_historical_states()
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = homeassistant-historical-sensor
version = 2.0.0rc1
version = 2.0.0rc2
author = Luis López
author_email = [email protected]
description = Historical sensors for HomeAssistant
Expand Down

0 comments on commit 1e532f5

Please sign in to comment.