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

Data doesn't fetch/update if you constantly change a setting with automation #231

Open
flip555 opened this issue Sep 15, 2024 · 0 comments

Comments

@flip555
Copy link

flip555 commented Sep 15, 2024

I have a CerboGX and interval is 30seconds, I have an automation to change max discharge depending different factors which runs every 5 seconds.

This number is usually the same so 2400, the automation runs every 5seconds and even though its the same number (both int and float) it updates and in debug log it says "Manually updated victron data"

This repeats forever, every 5 seconds, I guess resetting the 30second interval so the main function never runs to fetch the data.

I assume this would be the same for changing other settings not just numbers so I didn't do a pull request but for the number I added this to line 191 of number.py which fixed the non-updating sensors when spammed by automations - I guess some warning may be needed about too many requests but now mine updates both at the set interval or immediately after a number change.

await self.coordinator.async_request_refresh() 

Full Function:


async def async_set_native_value(self, value: float) -> None:
        """Update the current value."""
        #TODO convert float to int again with scale respected
        if value < 0:
            value = UINT16_MAX + value
        self.coordinator.write_register(unit=self.description.slave, address=self.description.address, value=self.coordinator.encode_scaling(value, self.description.native_unit_of_measurement, self.description.scale))
        await self.coordinator.async_update_local_entry(self.data_key, int(value))
        """Force update data after change."""
        await self.coordinator.async_request_refresh() 

EDIT: added the refresh to the async_update_local_entry function in cordinator.py instead and opened a PR #232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant