Open zivgin opened 2 months ago
Yes, same behaviour for me since about 5 days ago. Nothing in the logs but I haven't tried enabling the debug level. Presumably due to an API change, but if the maintainer needs any further information I'm happy to help.
This is actually a problem with the SmartThings website itself. Whenever I had this problem in the HA integration, the devices were missing from the website aswell. Only phones and tablets were still shown on the website. Logging out and back in fixed the problem.
I need to find a way to detect this scenario and trigger the reauth flow.
While I probably won't be able to fix this the next two weeks, in the meantime you could simply remove and readd the integration. This should fix it at least temporarily.
You also could manually edit the JSESSIONID
in .storage/core.config_entries
to any invalid value and after a restart of HA you should be prompted to login again.
Yeah i re-auth and that worked. thank you!
after i did the re-auth, it worked, but now it keeps asking me to re-auth all the time.
it even shows my to update the integration twice!
Are you sure you're on the latest version of this integration? Also, how did you reauthenticate - did you remove the integration or manually edit the .storage-file?
Make sure to always restart HA when doing changes like that!
Yeah restart probobly solve it
Had the same, Is it not possible that we can automate the steps we do to ready it. That we can see if all sensorsystemen go to unavailable. It ready them all. After that step it all works indeed.
Atleast will make automation that it send notification to me. Then I know to fix it. That will be the first step for me
Thanks, make sense. Just very annoying, where is this problem coming from?
Sorry for my late response. I was really busy with other stuff the last few weeks (and still am...)
Can't tell exactly, where the problem is coming from. It seems like the (unofficial) API only responds with a few devices after some time.
Currently, the integration works like this:
Both have their own API endpoint. Now for some reason, the first endpoint only responds with a subset of devices after a few days/weeks. For me it were mainly the SmartTags that were missing while phones/tablets were still available.
So it's not exactly the integrations fault, but we definitely need to find a workaround. Currently I can think of two solutions:
It's also pretty hard to test because I have to wait for the session to get into this state, which sometimes happens after a few hours, sometimes after a few weeks...
I'm sure you tested it but that's what the gpt told me:
Error Handling:
def fetch_data(self):
try:
response = requests.get(API_URL, headers=self.headers)
response.raise_for_status()
return response.json()
except requests.exceptions.HTTPError as http_err:
self.logger.error(f"HTTP error occurred: {http_err}")
except Exception as err:
self.logger.error(f"An error occurred: {err}")
return None
Session Management:
Solution: Add logic to check for session expiry and re-authenticate automatically.
def get_session(self):
if self.session_expired():
self.reauthenticate()
return self.session
def session_expired(self):
# Logic to check if session is expired
return self.session_expiry_time < datetime.now()
def reauthenticate(self):
# Logic to reauthenticate and get new session
self.session = requests.Session()
self.session_expiry_time = datetime.now() + timedelta(hours=1) # Example expiry time
API Rate Limits:
def fetch_data(self):
response = requests.get(API_URL, headers=self.headers)
if response.status_code == 429: # Too Many Requests
self.logger.warning("Rate limit hit, sleeping for a while")
time.sleep(60) # Sleep for 1 minute
response = requests.get(API_URL, headers=self.headers)
return response.json()
Polling Interval Configuration:
class SmartThingsFindConfigFlow(ConfigFlow, domain=DOMAIN):
async def async_step_user(self, user_input=None):
if user_input is not None:
return self.async_create_entry(title="SmartThings Find", data=user_input)
return self.async_show_form(step_id="user", data_schema=vol.Schema({
vol.Required("polling_interval", default=120): int,
}))
Polling Impact:
Solution: Allow disabling polling for specific devices and provide options to adjust the polling frequency.
def schedule_polling(self, interval):
self.hass.helpers.event.track_time_interval(self.update_devices, timedelta(seconds=interval))
async def update_devices(self, now):
# Fetch and update device data
pass
class SmartThingsFind(Entity):
def __init__(self, hass, interval=120):
self.hass = hass
self.schedule_polling(interval)
By addressing these bugs and implementing the suggested solutions, the HA-SmartThings-Find integration can become more robust, user-friendly, and efficient.
I had this appear for all my devices: "This entity is no longer being provided by the smartthings_find integration. If the entity is no longer in use, delete it in settings."
Except for my galaxy s6 watch (which is not exactly smartthing item)
Anyone else had encounter that?