home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.21k stars 31.16k forks source link

Sense integration unable to initialize after upgrading to 2024.11.0 from 2024.10.4 #130008

Open virtualuk opened 3 weeks ago

virtualuk commented 3 weeks ago

The problem

Since upgrading to 2024.11.0 (from 2024.10.4) the Sense integration that has been relatively solid for quite a while has stopped working. On the integrations page it shows "! Failed to setup", and ooking at the log files it appears to be having an issue during the init stage of the integration. As such no data from the integration is being generated.

I have tried rebooting HA, rebooting the machine that HA is running off of (Alpine Linux host running HA via container), and have tried deleting the integration and reinstalling the configuration but run into the same issue.

What version of Home Assistant Core has the issue?

2024.11.0

What was the last working version of Home Assistant Core?

2024.10.4

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Sense

Link to integration documentation on our website

https://www.home-assistant.io/integrations/sense/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-11-07 04:40:43.440 ERROR (MainThread) [homeassistant.config_entries] Error setting up entry *REMOVED*@*REMOVED*.com for sense
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 635, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sense/__init__.py", line 83, in async_setup_entry
    await gateway.fetch_devices()
          ^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ASyncSenseable' object has no attribute 'fetch_devices'. Did you mean: 'active_devices'?

Additional information

No response

home-assistant[bot] commented 3 weeks ago

Hey there @kbickar, mind taking a look at this issue as it has been labeled with an integration (sense) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `sense` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign sense` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


sense documentation sense source (message by IssueLinks)

kbickar commented 3 weeks ago

It seems like you have an outdated version of the sense_energy library. You should have 0.13.2 but it looks like you might have 0.12 instead

virtualuk commented 3 weeks ago

When I log into my HA container and search for sense related files here's what I get.

/ # find / -name sense -print /usr/local/lib/python3.12/site-packages/sense_energy-0.13.2.dist-info /usr/local/lib/python3.12/site-packages/sense_energy /usr/local/lib/python3.12/site-packages/sense_energy/sense_api.py /usr/local/lib/python3.12/site-packages/sense_energy/sense_exceptions.py /usr/local/lib/python3.12/site-packages/sense_energy/asyncsenseable.py /usr/local/lib/python3.12/site-packages/sense_energy/sense_link.py /usr/local/lib/python3.12/site-packages/sense_energy/senseable.py /usr/local/lib/python3.12/site-packages/pyversasense /usr/local/lib/python3.12/site-packages/opensensemap_api-0.2.0.dist-info /usr/local/lib/python3.12/site-packages/pyopnsense /usr/local/lib/python3.12/site-packages/poolsense-0.0.8.dist-info /usr/local/lib/python3.12/site-packages/poolsense /usr/local/lib/python3.12/site-packages/pyversasense-0.0.6.dist-info /usr/local/lib/python3.12/site-packages/opensensemap_api /usr/local/lib/python3.12/site-packages/whirlpool_sixth_sense-0.18.8.dist-info /usr/local/lib/python3.12/site-packages/pyopnsense-0.4.0.dist-info /usr/local/lib/python3.12/site-packages/googleapiclient/discovery_cache/documents/adsensehost.v4.1.json /usr/local/lib/python3.12/site-packages/googleapiclient/discovery_cache/documents/adsense.v2.json /usr/local/lib/python3.12/site-packages/ttn_client/parsers/sensecap.py /usr/src/homeassistant/homeassistant/components/sense /usr/src/homeassistant/homeassistant/components/poolsense /usr/src/homeassistant/homeassistant/components/opensensemap /usr/src/homeassistant/homeassistant/components/opnsense /usr/src/homeassistant/homeassistant/components/versasense /usr/src/homeassistant/homeassistant/components/hisense_aehw4a1 /sys/kernel/slab/scsi_sense_cache /config/esphome/.esphome/external_components/b5254113/esphome/components/senseair /config/esphome/.esphome/external_components/b5254113/esphome/components/senseair/senseair.h /config/esphome/.esphome/external_components/b5254113/esphome/components/senseair/senseair.cpp /config/custom_components/ha_sense /config/custom_components/pfsense /config/custom_components/pfsense/pypfsense

Should the change from 0.12 to 0.13.2 happen while upgrading to 2024.11.0?

kbickar commented 3 weeks ago

Yes it's included in 2024.11.0. Strange that it would be referencing the old version if you're using the docker container

mustangthz commented 3 weeks ago

I'm seeing broken sense integration as well....only one of my two sense units

kbickar commented 3 weeks ago

@mustangthz What are you seeing broken?

mustangthz commented 3 weeks ago

@mustangthz What are you seeing broken?

I'm not getting any usage reporting from my geothermal sense since upgrading to 11.0. My primary panel appears to still be working.

kbickar commented 3 weeks ago

That might be the issue fixed by #129998

mustangthz commented 3 weeks ago

That's awesome, when will it be released? I'm thinking about restoring from backup 10.4?

kbickar commented 3 weeks ago

It will be in 2024.11.1 which should be a couple days? Not sure the exact release date

kquinsland commented 3 weeks ago

@kbickar Can you tell me the class/package name(s) for the logger section of config.yaml?

I turned on MFA recently and - as expected - no new data. HA is even prompting me to provide a new MFA token but 6 digit number is never accepted. I can use the same number to log in to the home.sense.com app so I know it's not a TOTP seed / clock issue.

I wanted to get you some very explicit logs before I opened an issue; right now my logs are only showing: sense_energy.sense_exceptions.SenseAuthenticationException: API Return Code: 401


EDIT Well this is awkward. I restarted HA and ... can no longer reproduce the issue. As soon as HA came back up, I got the "one of your integrations needs to be reconfigured" message. I click through, I get the "enter MFA token" prompt and ... it worked.

virtualuk commented 3 weeks ago

Yes it's included in 2024.11.0. Strange that it would be referencing the old version if you're using the docker container

Any ideas on how I might be able to rectify the situation? I can log into the container if needed but I'm uncertain of what needs to change for this specific integration. Thanks!

p.s. I also looked at the version of sense-energy from within the container and it appears to be 0.11.1, so I tried upgrading from within the container:

homeassistant:/config# pip list | grep sense opensensemap-api 0.2.0 poolsense 0.0.8 pyopnsense 0.4.0 pyversasense 0.0.6 sense-energy 0.11.1 whirlpool_sixth_sense 0.18.8 homeassistant:/config# pip uninstall sense-energy Found existing installation: sense-energy 0.11.1 Uninstalling sense-energy-0.11.1: Would remove: /usr/local/lib/python3.12/site-packages/sense_energy-0.11.1.dist-info/ /usr/local/lib/python3.12/site-packages/sense_energy/ Proceed (Y/n)? Y Successfully uninstalled sense-energy-0.11.1 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning. homeassistant:/config# pip install sense-energy Looking in indexes: https://pypi.org/simple, https://wheels.home-assistant.io/musllinux-index/ Collecting sense-energy Downloading https://wheels.home-assistant.io/musllinux-index/sense_energy-0.13.3-py3-none-any.whl.metadata (3.5 kB) Requirement already satisfied: async-timeout>=3.0.1 in /usr/local/lib/python3.12/site-packages (from sense-energy) (4.0.3) Requirement already satisfied: ciso8601 in /usr/local/lib/python3.12/site-packages (from sense-energy) (2.3.1) Requirement already satisfied: orjson in /usr/local/lib/python3.12/site-packages (from sense-energy) (3.10.10) Requirement already satisfied: requests in /usr/local/lib/python3.12/site-packages (from sense-energy) (2.32.3) Requirement already satisfied: websocket-client in /usr/local/lib/python3.12/site-packages (from sense-energy) (1.8.0) Requirement already satisfied: websockets in /usr/local/lib/python3.12/site-packages (from sense-energy) (13.1) Requirement already satisfied: aiohttp in /usr/local/lib/python3.12/site-packages (from sense-energy) (3.10.10) Requirement already satisfied: kasa-crypt>=0.2.0 in /usr/local/lib/python3.12/site-packages (from sense-energy) (0.4.4) Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /usr/local/lib/python3.12/site-packages (from aiohttp->sense-energy) (2.4.3) Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.12/site-packages (from aiohttp->sense-energy) (1.3.1) Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.12/site-packages (from aiohttp->sense-energy) (24.2.0) Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.12/site-packages (from aiohttp->sense-energy) (1.5.0) Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.12/site-packages (from aiohttp->sense-energy) (6.1.0) Requirement already satisfied: yarl<2.0,>=1.12.0 in /usr/local/lib/python3.12/site-packages (from aiohttp->sense-energy) (1.17.1) Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.12/site-packages (from requests->sense-energy) (3.2.0) Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.12/site-packages (from requests->sense-energy) (3.10) Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.12/site-packages (from requests->sense-energy) (1.26.20) Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.12/site-packages (from requests->sense-energy) (2024.8.30) Requirement already satisfied: propcache>=0.2.0 in /usr/local/lib/python3.12/site-packages (from yarl<2.0,>=1.12.0->aiohttp->sense-energy) (0.2.0) Downloading https://wheels.home-assistant.io/musllinux-index/sense_energy-0.13.3-py3-none-any.whl (15 kB) Installing collected packages: sense-energy Successfully installed sense-energy-0.13.3 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning. homeassistant:/config# pip list | grep sense opensensemap-api 0.2.0 poolsense 0.0.8 pyopnsense 0.4.0 pyversasense 0.0.6 sense_energy 0.13.3 whirlpool_sixth_sense 0.18.8

It looks like it's upgrade to 0.13.3 but I'm still getting the same error at init unfortunately.

kbickar commented 3 weeks ago

What container are you using? Have you modified it in some way? Maybe download a new version of it

virtualuk commented 3 weeks ago

What container are you using? Have you modified it in some way? Maybe download a new version of it

Just the regular image (ghcr.io/home-assistant/home-assistant:stable), no modifications to it, pulled it yesterday.

kbickar commented 3 weeks ago

Are you using any custom components that might be using the sense-energy library?

virtualuk commented 3 weeks ago

No, the only thing I do with it is use the current energy usage entity to display on a card on my desktop.

On Sat, Nov 9, 2024, 10:59 AM Keilin Bickar @.***> wrote:

Are you using any custom components that might be using the sense-energy library?

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/130008#issuecomment-2466411449, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACAR53MJK3XF5NNNSVMDZVDZ7ZLQ3AVCNFSM6AAAAABRKMNTSWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRWGQYTCNBUHE . You are receiving this because you authored the thread.Message ID: @.***>

kbickar commented 3 weeks ago

Can you restart HA in safe mode and see if that solves the issue?

sharpsan commented 2 weeks ago

I'm getting the same error as the OP. Rebooting into safe mode and attempting to re-add the integration did not work for me.

kbickar commented 2 weeks ago

Is it still the error AttributeError: 'ASyncSenseable' object has no attribute 'fetch_devices'. Did you mean: 'active_devices'?

2024.11.2 has a fix for the MFA issue, but this one doesn't make sense with the current library

sharpsan commented 2 weeks ago

Is it still the error AttributeError: 'ASyncSenseable' object has no attribute 'fetch_devices'. Did you mean: 'active_devices'?

2024.11.2 has a fix for the MFA issue, but this one doesn't make sense with the current library

That reply was pre your MFA patch. 2024.11.2 fixed the issue I commented about.

dgriswo commented 3 days ago

I removed https://github.com/dahlb/ha_sense from HACS and the core integration stopped throwing exceptions on start.

dahlb commented 3 days ago

ha_sense version 1.2.7 allows for upgrades to sense_energy so resolves this issue

kbickar commented 3 days ago

Rather than using the custom component, you can just use the emulated kasa integration built in to HA

On Sun, Dec 1, 2024, 3:51 PM Bren Dahl @.***> wrote:

ha_sense version 1.2.7 allows for upgrades to sense_energy so resolves this issue

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/130008#issuecomment-2509801851, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA43XAOCBLMXCFKIFVP3QJ32DMO7DAVCNFSM6AAAAABRKMNTSWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMBZHAYDCOBVGE . You are receiving this because you were mentioned.Message ID: @.***>