megakid / ha_octopus_intelligent

Apache License 2.0
86 stars 10 forks source link

Upgrading to Home Assistant 2023.06 broke the Slot entities #16

Closed grahamrjuk closed 1 year ago

grahamrjuk commented 1 year ago

After upgrading to Home Assistant 2023.06 the Octopus Intelligent Slot entities (Slot, Slot 1hr, 2hrs, 3hrs and Planned Dispatch are not available. It was all good before the upgrade.

I am using Home Assistant OS, on a Raspberry Pi 4.

Home Assistant 2023.6.0
Supervisor 2023.06.1
Operating System 10.2
Frontend 20230607.0 - latest

I have the following errors in the log:

Logger: py.warnings
Source: runner.py:179
First occurred: 21:48:42 (1 occurrences)
Last logged: 21:48:42

/usr/local/lib/python3.11/asyncio/base_events.py:1907: RuntimeWarning: coroutine 'OctopusIntelligentSystem.start' was never awaited handle = self._ready.popleft()

and

Logger: homeassistant.components.binary_sensor
Source: custom_components/octopus_intelligent/binary_sensor.py:100
Integration: Binary Sensor (documentation, issues)
First occurred: 21:48:56 (1 occurrences)
Last logged: 21:48:56

Error while setting up octopus_intelligent platform for binary_sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 320, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/octopus_intelligent/binary_sensor.py", line 19, in async_setup_entry
    OctopusIntelligentSlot(
  File "/config/custom_components/octopus_intelligent/binary_sensor.py", line 59, in __init__
    self._timer = async_track_utc_time_change(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1628, in async_track_utc_time_change
    f"time change listener {hour}:{minute}:{second} {action}",
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1026, in __repr__
    return f"<entity {self.entity_id}={self._stringify_state(self.available)}>"
                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 596, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/binary_sensor/__init__.py", line 211, in state
    if (is_on := self.is_on) is None:
                 ^^^^^^^^^^
  File "/config/custom_components/octopus_intelligent/binary_sensor.py", line 100, in is_on
    return self._is_on
           ^^^^^^^^^^^
AttributeError: 'OctopusIntelligentSlot' object has no attribute '_is_on'

Not sure if it is just a matter of time, and waiting would mean the slot would be updated, or if there is a bug here in the move to Python 3.11.

image

grahamrjuk commented 1 year ago

Looks like self.is_on() is being called in the super call in OctopusIntelligentSlot.__init__, before self._is_on is defined.

JasSmiths commented 1 year ago

Same issue here

megakid commented 1 year ago

Fixed in 1.6.2

Thanks for reporting

grahamrjuk commented 1 year ago

Thanks for fixing very promptly.

worz9 commented 1 year ago

yes thanks This automation is really useful

On 8 Jun 2023, at 17:04, Graham @.***> wrote:

Thanks for fixing very promptly.

— Reply to this email directly, view it on GitHub https://github.com/megakid/ha_octopus_intelligent/issues/16#issuecomment-1582933457, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQE2RZ357PGBIWNKSWWNSPDXKHZZXANCNFSM6AAAAAAY6OCZEQ. You are receiving this because you are subscribed to this thread.