Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arguments not propagated in SingleInverter.get_current_readings #182

Closed
vozdeckyl opened this issue Jan 3, 2023 · 5 comments
Closed

Arguments not propagated in SingleInverter.get_current_readings #182

vozdeckyl opened this issue Jan 3, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@vozdeckyl
Copy link

The arguments passed to SingleInverter.get_current_readings:

def get_current_readings(

are not forwarded to API.get_current_readings. When the number of maxretries is set to 1, it's still 5 due to the default value of 5 in API.get_current_readings. Also the recursive call should not happen in SingleInverter.get_current_readings as it already happens in API.get_current_readings.

Furthermore, the function should return data, but it returns retval set to None.

This is what the function should imho look like:

 def get_current_readings(
        self,
        raw: bool=True,
        retry: int=1,
        maxretries: int=5,
        delay: int=30,
        ) -> Any:
        """ grabs the data and makes sure self.data only has a single inverter """
        # update the data
        super().get_current_readings(raw, retry, maxretries, delay)
        # reduce self.data['inverter'] to a single dict from a list
        
        if self.data.get("inverter"):
            self.data["inverter"] = self.data["inverter"][0]
        return self.data
@yaleman yaleman self-assigned this Jan 3, 2023
@yaleman yaleman added the bug Something isn't working label Jan 3, 2023
@yaleman
Copy link
Owner

yaleman commented Jan 3, 2023

Thanks for picking this up, I've pushed v0.1.5 which includes the fixes.

@vozdeckyl
Copy link
Author

Hi @yaleman,
Thanks! Shouldn’t the if statement stay there? If the API call is not successful, an empty diction is returned and then it will throw an error.

@yaleman yaleman closed this as completed in e576474 Jan 4, 2023
yaleman added a commit that referenced this issue Jan 4, 2023
fixes #182 - pass settings through, handle errors better
@yaleman yaleman reopened this Jan 4, 2023
@yaleman
Copy link
Owner

yaleman commented Jan 4, 2023

the if is done in the call in API so that should be fine

@yaleman
Copy link
Owner

yaleman commented Mar 21, 2023

@vozdeckyl is this still an issue?

@vozdeckyl
Copy link
Author

Hi @yaleman ,
I don't think it is. You can close the issue! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants