smartthings icon indicating copy to clipboard operation
smartthings copied to clipboard

2025.5 upstream deprecation: `AttributeError: 'HomeAssistant' object has no attribute 'helpers'`

Open jtagcat opened this issue 8 months ago • 28 comments

Logger: homeassistant.setup
Source: setup.py:426
First occurred: 10:59:45 PM (1 occurrence)
Last logged: 10:59:45 PM

Error during setup of component smartthings: 'HomeAssistant' object has no attribute 'helpers'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 426, in _async_setup_component
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/smartthings/__init__.py", line 57, in async_setup
    await setup_smartapp_endpoint(hass)
  File "/config/custom_components/smartthings/smartapp.py", line 212, in setup_smartapp_endpoint
    store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY)
            ^^^^^^^^^^^^
AttributeError: 'HomeAssistant' object has no attribute 'helpers'

Workaround: Downgrade to 2025.4

See also: https://github.com/rospogrigio/localtuya/issues/1977

GitHub Etiquette

  • Please use the 👍 reaction to show that you are affected by the same issue. (?)
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue. (?)
  • Subscribe to receive notifications on new comments, or get notified of resolution with 'Status' (?).

jtagcat avatar May 07 '25 20:05 jtagcat

">>This current integration is not being updated, only fixed if HA update breaks it!<<" Aaaand an update broke it. @veista is this something fixable - are you looking into this?

vhamburger avatar May 08 '25 07:05 vhamburger

Same problem, if it is not resolved I will have to return to the standard

Diegocampy avatar May 08 '25 17:05 Diegocampy

On line 25 in smartapp.py , add , cloud at the end. You should get this: from homeassistant.components import webhook, cloud

After line 32 add from homeassistant.helpers.storage import Store

So you'll get this:

from homeassistant.helpers.dispatcher import (
    async_dispatcher_connect,
    async_dispatcher_send,
) # <-- This is line 32
from homeassistant.helpers.storage import Store # <-- add this
from homeassistant.helpers.network import NoURLAvailableError, get_url

from .const import (

Now line 97 (was 96), change it from if hass.components.cloud.async_active_subscription(): to
if cloud.async_active_subscription(hass):

So you should have this:

def validate_webhook_requirements(hass: HomeAssistant) -> bool:
    """Ensure Home Assistant is setup properly to receive webhooks."""
    if cloud.async_active_subscription(hass): # <--- here is the change to now line 97.
        return True
    if hass.data[DOMAIN][CONF_CLOUDHOOK_URL] is not None:
        return True
    return get_webhook_url(hass).lower().startswith("https://")

Now line 213 (was line 212 before the addition, Change from
store = hass.helpers.storage.Store(STORAGE_VERSION, STORAGE_KEY) to
store = Store(hass, STORAGE_VERSION, STORAGE_KEY)

You should have:

    # Get/create config to store a unique id for this hass instance.
    store = Store(hass, STORAGE_VERSION, STORAGE_KEY)
    config = await store.async_load()
    if not config:
        # Create config
        config = {
            CONF_INSTANCE_ID: str(uuid4()),
            CONF_WEBHOOK_ID: secrets.token_hex(),
            CONF_CLOUDHOOK_URL: None,
        }

Save the file and restart homeassistant.

Milkysunshine avatar May 08 '25 17:05 Milkysunshine

I created a PR, it may be easier to follow that if it isn't merged: https://github.com/veista/smartthings/pull/134/commits/ec5765cb4ea2ab69eb01cd11abf57cdc1ba14a0f

Milkysunshine avatar May 08 '25 17:05 Milkysunshine

I created a PR, it may be easier to follow that if it isn't merged: ec5765c

I Update smartapp.py with your but Smartthings not work, and in the log i see this:

Registratore: homeassistant.setup
Fonte: setup.py:426
Prima occorrenza: 23:33:54 (1 occorrenza)
Ultimo accesso: 23:33:54

Error during setup of component smartthings: 'HomeAssistant' object has no attribute 'components'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 426, in _async_setup_component
    result = await task
             ^^^^^^^^^^
  File "/config/custom_components/smartthings/__init__.py", line 57, in async_setup
    await setup_smartapp_endpoint(hass)
  File "/config/custom_components/smartthings/smartapp.py", line 233, in setup_smartapp_endpoint
    and hass.components.cloud.async_active_subscription()
        ^^^^^^^^^^^^^^^
AttributeError: 'HomeAssistant' object has no attribute 'components'

could you help me to undertand what is the problema now?

Diegocampy avatar May 08 '25 21:05 Diegocampy

Can confirm the above. I also got the error: AttributeError: 'HomeAssistant' object has no attribute 'helpers'

After modifying smartapp.py based on Milkysunshine's post, the error with 'helpers' was probably fixed, but now the integration returns an error with 'components': AttributeError: 'HomeAssistant' object has no attribute 'components' same as Diegocampy above.

z-oo-m avatar May 09 '25 01:05 z-oo-m

Yeah, I'm not sure.

I made the exact modifications I mentioned and it works?

I just rebooted HA again to verify... It works.

My PR was based on a full copy and paste of my current working file.

Maybe try pasting in the entire file from https://raw.githubusercontent.com/Milkysunshine/smartthings/refs/heads/master/custom_components/smartthings/smartapp.py ?

Milkysunshine avatar May 09 '25 01:05 Milkysunshine

I upgrqded to 2025.5 and removed Smarthings Custom - made the modification by @Milkysunshine, but got the same error. I then downgraded to 2025.4 and installed Smarthings Custom again, upgraded to 2025.5 without removing Smarthings Custom. Made the modification - restarted and everything worked.

breiviar avatar May 09 '25 05:05 breiviar

I upgrqded to 2025.5 and removed Smarthings Custom - made the modification by @Milkysunshine, but got the same error. I then downgraded to 2025.4 and installed Smarthings Custom again, upgraded to 2025.5 without removing Smarthings Custom. Made the modification - restarted and everything worked.

when you write downgrade, you restore a backup or different?

Diegocampy avatar May 09 '25 10:05 Diegocampy

I upgrqded to 2025.5 and removed Smarthings Custom - made the modification by @Milkysunshine, but got the same error. I then downgraded to 2025.4 and installed Smarthings Custom again, upgraded to 2025.5 without removing Smarthings Custom. Made the modification - restarted and everything worked.

when you write downgrade, you restore a backup or different?

I restored a backup

breiviar avatar May 09 '25 15:05 breiviar

There's a few other instances of hass.components.cloud that need to be replaced by just cloud like the PR was doing.

fabianluque avatar May 09 '25 16:05 fabianluque

There's a few other instances of hass.components.cloud that need to be replaced by just cloud like the PR was doing.

It is very possible. I only made changes until it worked on my installation.

Milkysunshine avatar May 09 '25 17:05 Milkysunshine

Hi - Here is a new modified file smartapp.py. It was necessary to do some more changes to the file, thank you @Milkysunshine for pointing in the right direction.

For modified file: https://github.com/breiviar/brama/blob/master/smartapp.py

You replace the file smartapp.py in config --> custom_components --> smartthings Restart Home Assistant and add Smartthings Custom integration again

breiviar avatar May 10 '25 07:05 breiviar

Hi - Here is a new modified file smartapp.py. It was necessary to do some more changes to the file, thank you @Milkysunshine for pointing in the right direction.

For modified file: https://raw.githubusercontent.com/breiviar/brama/refs/heads/master/smartapp.py?token=GHSAT0AAAAAADDRZIMMYD4U3DDRHLWKSJVQ2A67DFQ

You replace the file smartapp.py in config --> custom_components --> smartthings Restart Home Assistant and add Smartthings Custom integration again

Thank you, but the link gives me a 404 not found

msand83 avatar May 10 '25 07:05 msand83

Hi - Here is a new modified file smartapp.py. It was necessary to do some more changes to the file, thank you @Milkysunshine for pointing in the right direction. For modified file: https://raw.githubusercontent.com/breiviar/brama/refs/heads/master/smartapp.py?token=GHSAT0AAAAAADDRZIMMYD4U3DDRHLWKSJVQ2A67DFQ You replace the file smartapp.py in config --> custom_components --> smartthings Restart Home Assistant and add Smartthings Custom integration again

Thank you, but the link gives me a 404 not found

I´m terrible at this - please try again

brama-master.zip

https://github.com/breiviar/brama/blob/master/smartapp.py

breiviar avatar May 10 '25 07:05 breiviar

Hi - Here is a new modified file smartapp.py. It was necessary to do some more changes to the file, thank you @Milkysunshine for pointing in the right direction.

For modified file: https://github.com/breiviar/brama/blob/master/smartapp.py

You replace the file smartapp.py in config --> custom_components --> smartthings Restart Home Assistant and add Smartthings Custom integration again

Thank you 🙏 This fixed it for me.

mjeshurun avatar May 10 '25 09:05 mjeshurun

Thanks @breiviar, it works great for me ! 👌

nicolinuxfr avatar May 10 '25 12:05 nicolinuxfr

Hi all, What about 24 hours tokens, is somehow fixed in this file ? Because after one day it is not working

perseus177 avatar May 10 '25 16:05 perseus177

The upgrade to HA also broke my SmartThings integration. I tried the changes without success. I have fixed by restoring a backup from 3 days ago and recreating the PAT for SmartThings.

maritzhome1 avatar May 11 '25 11:05 maritzhome1

I redid the manual file update process described in this thread and now works 100% - many thanks to all involved for resolving. Most appreciated.

maritzhome1 avatar May 11 '25 12:05 maritzhome1

Hi - Here is a new modified file smartapp.py. It was necessary to do some more changes to the file, thank you @Milkysunshine for pointing in the right direction.

For modified file: https://github.com/breiviar/brama/blob/master/smartapp.py

You replace the file smartapp.py in config --> custom_components --> smartthings Restart Home Assistant and add Smartthings Custom integration again

You are an absolute life savior! This works flawless - just replaced the smartapp.py and rebooted (no restore of HA) and it just works again. However, this whole incident makes me question if this is still a good choice as it seems @veista is no longer maintaining this project. Maybe someone is willing to fork it to keep it alive?

vhamburger avatar May 12 '25 10:05 vhamburger

Is this to resolve the ‘not loaded’ error?

ylnest2018 avatar May 15 '25 13:05 ylnest2018

The whole token issue is solved in the core version and every version since comes with a load of new features, so consider switching back to the core version :)

joostlek avatar May 17 '25 11:05 joostlek

So I was thinking to ask this exact question, my integration shows it’s custom and from HACS I don’t know how or when I did it, what’s the way to switch back to the core one? I don’t have any interest in being ahead of the curve on a custom release 😅

ylnest2018 avatar May 17 '25 12:05 ylnest2018

Delete smartthings from your custom_components folder. If you run HAOS it's in /config/custom_components. Do note that you have to remove the integration beforehand. I have no clue if this custom integration updated the unique id in a weird way, so not all features are available, but if you join the smartthings discord I am happy to look into them

joostlek avatar May 17 '25 13:05 joostlek

Thank you so much I was actually thinking to myself the other week why does it look like an unofficial one but wasn’t sure…anyway I am setting back up now I’m stuck in the authorize HomeAssistant step I authorize it multiple times and still it sits waiting..I don’t want to hijack this thread so I’ll just move over to the discord if I can’t get past it or need more advice

ylnest2018 avatar May 17 '25 13:05 ylnest2018

For everyone who downloaded the custom SmartThings integration via HACS: delete it and install SmartThings (not HACS, and not custom) from the official Home Assistant store. The custom integration no longer works and forces you to log in every 24 hours. I spent two weeks trying to figure out the issue — oh man!

Arienz avatar May 18 '25 20:05 Arienz

The whole token issue is solved in the core version and every version since comes with a load of new features, so consider switching back to the core version :)

@joostlek Except I can't install it :-/ https://github.com/home-assistant/core/issues/147347

webdados avatar Jun 23 '25 12:06 webdados