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

Unknown account spending response #4

Closed
manonstreet opened this issue Feb 25, 2024 · 5 comments
Closed

Unknown account spending response #4

manonstreet opened this issue Feb 25, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@manonstreet
Copy link

Running the test harness produces the following error
pyfamilysafety.account WARNING: Unknown account spending response, please report to developer. {'askAParentEnabled': False, 'balances': []}

This same error also reported in the ha integration.

@pantherale0
Copy link
Owner

Balances seem odd, might be because something isn't enabled on your account for it to work.

Nothing breaking though just prevents the below (at least in HA) from working:

SmartSelect_20240227_184046_Home Assistant

@manonstreet
Copy link
Author

I do have spending controls disabled for my kids, so that may be the issue. This does get rather noisy in HA though. Perhaps you can suppress this message for such cases?

Source: custom_components/family_safety/coordinator.py:42
Integration: Microsoft Family Safety ([documentation](https://github.com/pantherale0/ha-familysafety), [issues](https://github.com/pantherale0/ha-familysafety/issues))
First occurred: February 27, 2024 at 7:47:27 PM (1578 occurrences)
Last logged: 10:14:26 AM

Unknown account spending response, please report to developer. {'askAParentEnabled': False, 'balances': []}
Unknown account spending response, please report to developer. {'askAParentEnabled': True, 'balances': []}```

@manonstreet
Copy link
Author

I went ahead an enabled family spending monitoring, but I am still receiving the error. I wonder if it's because I have never funded the account? It looks like balances is returning a null value (as opposed to $0), and the module does not account for this?

@manonstreet
Copy link
Author

manonstreet commented Apr 21, 2024

I've modified the package on my end and commented out line 85 of account.py so the function is now:

    async def _get_account_balance(self):
        """Updates the account balance."""
        response = await self._api.send_request(
            endpoint="get_user_spending",
            USER_ID=self.user_id
        )
        response = response["json"]
        balances = response.get("balances", [])
        if len(balances) == 1:
            self.account_balance = balances[0]["balance"]
            self.account_currency = balances[0]["currency"]
            return
        #_LOGGER.warning("Unknown account spending response, please report to developer. %s", response)
        return

This solves my issue.

My understanding is that for those of us that have never deposited any funds, the balances array is null and therefore will never have a length. Catching this error generates many unnecessary warnings, especially when using the homeassistant integration. If you agree, can you kindly remove the warning from your upstream package?

Thanks!

@pantherale0
Copy link
Owner

Log spam removed in 1.0.0

@github-project-automation github-project-automation bot moved this from Backlog to Delivered in HA Family Safety - 2024.12.0 Oct 6, 2024
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
Development

No branches or pull requests

2 participants