Skip to content

[measure] Ability to recover from 500 errors #3028

Closed
@challgren

Description

System Health details

Measure script issue

Checklist

  • I have read the FAQ to see if there is a known solution to my problem.
    I have enabled debug logging for my installation.
    I have filled out the issue template to the best of my ability.
    This issue only contains 1 issue (if you have multiple issues, open one issue for each issue).
    This issue is not a duplicate issue of currently previous issues..

Describe the issue

I've been recently contributing to powercalc and I have been measuring some of my devices using the built in script.

However one of my biggest grips is when there is a 500 error presented during the home assistant api call there is no graceful error handling. Without this error handling or attempt to retry the entire measure session is wasted on a temporary error that is quickly gone away.

Reproduction steps

  1. Start measure session
  2. Create error 500 response code during measure session
  3. Watch entire 4 hours go down the drain

Debug logs

N/A

Diagnostics dump or YAML config

No response

Activity

bramstroker

bramstroker commented on Jan 29, 2025

@bramstroker
Owner

You should be able to continue at the point it crashed when you have half CSV.
The measure tool should provide you with an option to resume.

Will have a look how to improve retry mechanism when HA API is temporarily unavailable.

challgren

challgren commented on Jan 30, 2025

@challgren
ContributorAuthor

By default the RESUME var is not set in the env. I uncommented it out and resume worked. However still having timeouts so having to keep restarting the script.

challgren

challgren commented on Jan 30, 2025

@challgren
ContributorAuthor

Ok so I figured out why I'm getting these random 500 errors.

I checked the Home Assistant main log and see.

Logger: homeassistant.components.light
Source: components/light/__init__.py:331
integration: Light ([documentation](https://www.home-assistant.io/integrations/light), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+light%22))
First occurred: 13:40:12 (5 occurrences)
Last logged: 23:38:17

Got `kelvin` argument in `turn_on` service, which is deprecated and will break in Home Assistant 2026.1, please use `color_temp_kelvin` argument
challgren

challgren commented on Jan 30, 2025

@challgren
ContributorAuthor

Actually it looks like the issue is really the Hubspace integration. I keep getting 403 from their web service, my guess is rate limiting maybe occurring.

bramstroker

bramstroker commented on Jan 30, 2025

@bramstroker
Owner

Yes the "error" you showed from log is not really an error but just a deprecation notice. Shouldn't break anything, and not be the cause of 500 error.

bramstroker

bramstroker commented on Jan 30, 2025

@bramstroker
Owner

Actually it looks like the issue is really the Hubspace integration. I keep getting 403 from their web service, my guess is rate limiting maybe occurring.

You could try raising the SLEEP_TIME in order to prevent hitting rate limiting on that cloud API. looking at the response code it shouldn't be rate limiting, but I won't be surprised if it's a badly implemented API or infrastructure.

challgren

challgren commented on Jan 30, 2025

@challgren
ContributorAuthor

Well majority of my issues were during the color_temp. Once I got into the HsVaration all my 403 errors resolved.

bramstroker

bramstroker commented on Jan 31, 2025

@bramstroker
Owner

I have probably fixed the deprecation error with #3041
Might be the problem you were running in the 403 errors, as the hs didn't give you issues.
Good to have this warning resolved anyway.

However having a hard time building the docker image.
github action keeps running in strange segmentation faults after 20 minutes :-(
New run is running here: https://github.com/bramstroker/homeassistant-powercalc/actions/runs/13077153943
Also cleared github caches now. Hopefully will succeed now.

challgren

challgren commented on Jan 31, 2025

@challgren
ContributorAuthor

Yeah thats what I'm thinking it was Hubspace really causing the issues by sending a 403 randomly. And Home Assistant just returning 500 instead of the actual message. The other thing was just having to restart it after every 500 that was the real pain because I would start the measure script. Go about my day and come back to find out it crashed 5 minutes after I started it and now I gotta resume it. So it was really having to babysit the measure script to ensure it was still working.

bramstroker

bramstroker commented on Feb 3, 2025

@bramstroker
Owner

Closing this issue. Improvements have been done in measure tool to prevent the script from crashing on one error.

challgren

challgren commented on Feb 3, 2025

@challgren
ContributorAuthor

Yep seems to be working great been running the effect measure for over 30 hours and no unexpected quits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmeasure-toolMeasure tooling related issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      [measure] Ability to recover from 500 errors · Issue #3028 · bramstroker/homeassistant-powercalc