Skip to content

Commit

Permalink
Next release (#1152)
Browse files Browse the repository at this point in the history
  • Loading branch information
BottlecapDave authored Jan 2, 2025
2 parents 65edfe6 + 0c61292 commit 90550ae
Show file tree
Hide file tree
Showing 49 changed files with 148 additions and 100 deletions.
2 changes: 1 addition & 1 deletion _docs/entities/intelligent.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ This sensor is used to see and set the target time for your future intelligent c

!!! warning

There is a time based sensor called `select.octopus_energy_{{ACCOUNT_ID}}_intelligent_target_time` which represents this functionality. This is a legacy sensor which will be removed in the future.
There is a time based sensor called `time.octopus_energy_{{ACCOUNT_ID}}_intelligent_target_time` which represents this functionality. This is a legacy sensor which will be removed in the future.

## Migrating from megakid/ha_octopus_intelligent?

Expand Down
1 change: 1 addition & 0 deletions _docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Based on a request from [Octopus Energy](https://forum.octopus.energy/t/pending-
| Wheel of fortune | 60 | Doesn't change that frequently, and not fundamental for a smart home (other than knowledge) so no need to request too often. |
| Greenness Forecast | 180 | Doesn't change frequently |
| Free electricity sessions | 90 | Data is provided by my own [private API](https://github.com/BottlecapDave/OctopusEnergyApi) and there is usually at least half a day notice before the sessions which is why this is refreshed slightly less than saving sessions. |
| Heat Pump state | 1 | Data is updated frequently and doesn't seem to cause any issues around rate limits. This might change in the future. |

If data cannot be refreshed for any reason (e.g. no internet or APIs are down), then the integration will attempt to retrieve data as soon as possible, slowly waiting longer between each attempt, to a maximum of 30 minutes between each attempt. Below is a rough example assuming the first (failed) scheduled refresh was at `10:35`.

Expand Down
5 changes: 3 additions & 2 deletions custom_components/octopus_energy/cost_tracker/cost_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)
# Make sure our attributes don't override any changed settings
self._attributes.update(self._config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)
# Make sure our attributes don't override any changed settings
self._attributes.update(self._config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)
# Make sure our attributes don't override any changed settings
self._attributes.update(self._config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

_LOGGER.debug(f'Restored state: {self._state}')
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

_LOGGER.debug(f'Restored state: {self._state}')
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

if "last_updated_timestamp" in self._attributes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

if "last_updated_timestamp" in self._attributes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

_LOGGER.debug(f'Restored OctopusEnergyCurrentElectricityIntervalAccumulativeConsumption state: {self._state}')
5 changes: 3 additions & 2 deletions custom_components/octopus_energy/electricity/current_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes, ['all_rates', 'applicable_rates'])
_LOGGER.debug(f'Restored OctopusEnergyElectricityCurrentRate state: {self._state}')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

_LOGGER.debug(f'Restored state: {self._state}')
5 changes: 3 additions & 2 deletions custom_components/octopus_energy/electricity/next_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes, ['all_rates', 'applicable_rates'])

_LOGGER.debug(f'Restored OctopusEnergyElectricityNextRate state: {self._state}')
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

_LOGGER.debug(f'Restored state: {self._state}')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

_LOGGER.debug(f'Restored state: {self._state}')
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

_LOGGER.debug(f'Restored OctopusEnergyPreviousAccumulativeElectricityCostOverride state: {self._state}')
5 changes: 3 additions & 2 deletions custom_components/octopus_energy/electricity/previous_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes, ['all_rates', 'applicable_rates'])

_LOGGER.debug(f'Restored OctopusEnergyElectricityPreviousRate state: {self._state}')
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes, ['valid_from', 'valid_to'])

_LOGGER.debug(f'Restored OctopusEnergyElectricityCurrentStandingCharge state: {self._state}')
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

_LOGGER.debug(f'Restored OctopusEnergyCurrentAccumulativeGasConsumption state: {self._state}')
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes, ["total"])

_LOGGER.debug(f'Restored OctopusEnergyCurrentAccumulativeGasConsumption state: {self._state}')
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

_LOGGER.debug(f'Restored OctopusEnergyCurrentAccumulativeGasCost state: {self._state}')
5 changes: 3 additions & 2 deletions custom_components/octopus_energy/gas/current_consumption.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

if "last_updated_timestamp" in self._attributes:
Expand Down
5 changes: 3 additions & 2 deletions custom_components/octopus_energy/gas/current_rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes, ['all_rates', 'applicable_rates'])

_LOGGER.debug(f'Restored OctopusEnergyGasCurrentRate state: {self._state}')
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

_LOGGER.debug(f'Restored state: {self._state}')
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ async def async_added_to_hass(self):
# If not None, we got an initial value.
await super().async_added_to_hass()
state = await self.async_get_last_state()
last_sensor_state = await self.async_get_last_sensor_data()

if state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else state.state
if state is not None and last_sensor_state is not None and self._state is None:
self._state = None if state.state in (STATE_UNAVAILABLE, STATE_UNKNOWN) else last_sensor_state.native_value
self._attributes = dict_to_typed_dict(state.attributes)

_LOGGER.debug(f'Restored state: {self._state}')
Loading

0 comments on commit 90550ae

Please sign in to comment.