BottlecapDave / HomeAssistant-OctopusEnergy

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

Intelligent Dispatching Sensor low tariff period set inaccurately #446

Closed FozzieUK closed 11 months ago

FozzieUK commented 11 months ago

Describe the bug

After update to v8.4.0 the binary_sensor.octopus_energy_intelligent_dispatching is no longer available

I've read the notes around the new events triggers but I can't see anything that says this has been removed.

Reproduction steps

Need to be on Intelligent Octopus

Simply upgraded to v8.4.0 and it is no longer provided

Expected behaviour

The binary sensor would be available and turns true when the IO low tariff is active, it's attributes provide the dispatch schedules.

Tariff Code

Octopus Intelligent

Integration Version

v8.4.0

Home Assistant Version

2023.10.1

Fresh Install?

After upgrading

Home Assistant Logs

2023-10-07 12:09:23.322 ERROR (MainThread) [homeassistant.components.binary_sensor] Error adding entities for domain binary_sensor with platform octopus_energy Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities await asyncio.gather(tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1057, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 779, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 879, in _async_write_ha_state state, attr = self._async_generate_attributes() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 820, in _async_generate_attributes state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 785, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/binary_sensor/init.py", line 218, in state if (is_on := self.is_on) is None: ^^^^^^^^^^ File "/config/custom_components/octopus_energy/intelligent/dispatching.py", line 72, in is_on rates = self.coordinator.data.rates if self.coordinator is not None and self.coordinator.data is not None else None ^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'dict' object has no attribute 'rates' 2023-10-07 12:09:23.334 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up octopus_energy platform for binary_sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 367, in _async_setup_platform await asyncio.gather(pending) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities await asyncio.gather(*tasks) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1057, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 779, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 879, in _async_write_ha_state state, attr = self._async_generate_attributes() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 820, in _async_generate_attributes state = self._stringify_state(available) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 785, in _stringify_state if (state := self.state) is None: ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/binary_sensor/init.py", line 218, in state if (is_on := self.is_on) is None: ^^^^^^^^^^ File "/config/custom_components/octopus_energy/intelligent/dispatching.py", line 72, in is_on rates = self.coordinator.data.rates if self.coordinator is not None and self.coordinator.data is not None else None ^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'dict' object has no attribute 'rates'

FozzieUK commented 11 months ago

Reverted to v8.3.0 - working ok.

BottlecapDave commented 11 months ago

Sorry about that. This should be fixed in v8.4.1

FozzieUK commented 11 months ago

no problem, thanks for all your great work 👍

FozzieUK commented 11 months ago

Since the update (to v8.4.1/2) the intelligent dispatch sensor is now available ok but the standard low tariff rate is not being set correctly.

Rather than switching on at 11:30pm and off at 5:30am, it switches on erratically somedays at 11:59 and off at 5:59, or on others at 12:08 and off at 6:08am (but never at 11:30 and 5:30)

It seems to have lost it's precision around the 'standard' low tariff times - I haven't had any out of hours slots since then so can't confirm the accuracy of those but i'll try and get one today and see what it shows.

First 2 screen shots show before the update, last 2 after the update 1 2 3 4

BottlecapDave commented 11 months ago

@FozzieUK As this is a separate bug from the original, it would be good in future to raise a separate ticket. This helps me work out what is outstanding and what isn't at a glance, as well as helps others looking for similar issues that may or may not still be an issue. I've moved your issue into https://github.com/BottlecapDave/HomeAssistant-OctopusEnergy/issues/466, and will therefore reclose this issue.