cdpuk / givenergy-local

Home Assistant integration for local access to GivEnergy inverter and battery systems
MIT License
52 stars 14 forks source link

Change refresh rate #41

Closed alfwro13 closed 1 year ago

alfwro13 commented 1 year ago

Is there a way of changing the default refresh rate?

cdpuk commented 1 year ago

Hi, there is no way to change the refresh rate at present. I'm open to the idea of someone adding this but care must be taken when speeding up the refresh rate as it's not an instantaneous operation and also the time taken to refresh depends on the number of batteries.

What sort of refresh rate are you looking for? That would be good to know for the benefit of any potential future implementation.

alfwro13 commented 1 year ago

Well the main objective better data resolution. For now I manually change it to 5 seconds in the coordinator.py:

class GivEnergyUpdateCoordinator(DataUpdateCoordinator[Plant]):
    """Update coordinator that enables efficient batched updates to all entities associated with an inverter."""

    require_full_refresh = True
    last_full_refresh = datetime.min

    def __init__(self, hass: HomeAssistant, host: str, num_batteries: int) -> None:
        """Initialize my coordinator."""
        super().__init__(
            hass,
            _LOGGER,
            name="Inverter",
            update_interval=timedelta(seconds=5),

but it would be nice if there was a way of changing that either from the Devices and Services Home Assistant page or via a HA service