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

Pace of entity updates #81

Open
Altau38650 opened this issue May 15, 2023 · 5 comments
Open

Pace of entity updates #81

Altau38650 opened this issue May 15, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@Altau38650
Copy link

Hello,

I have used sun2 entities in a dashboard map and I can see that the values are updated every 5 minutes. Can this be changed?

Thank you in advance and congratulations for this very useful tool.

--
Alain
France

@pnbruckner
Copy link
Owner

I'm not sure what a "dashboard map" is, especially as related to sun2 entities. Also, the update rate of sun2 entities depends on its type. I.e., some sun2 entities update once a day, some update depending on some event (e.g., the sun rising above a certain elevation), etc. Can you tell me which type of sun2 entities you're using (e.g., could you share your sun2 configuration)?

@pnbruckner
Copy link
Owner

Closing due to no response. Feel free to reopen if/when you care.

@gsokoll
Copy link

gsokoll commented Nov 6, 2024

I have a similar question. I'm using the azimuth sensor for control of solar panel trackers. Currently it appears to update approx every 4 minutes in the middle of the day. Can this be adjusted through the configuration yaml ?

@pnbruckner
Copy link
Owner

I chose to implement the azimuth sensor a bit differently than the others.

Usually (many of) the sensors update as required to maintain a certain increment between values. E.g., the elevation sensor updates so that it changes by 0.5 degrees on each update. However, it wasn't as easy to do the same with the azimuth sensor given the nature of its curve.

So, instead, I chose to implement its update frequency the same way the standard sun integration does. I.e., its update frequency depends on the elevation. It updates the most frequently for elevations between 0 and 10, and less and less often the further the elevation is away from that range. I'm not sure why the standard sun integration works that way, but again, I chose to simply duplicate its behavior for the azimuth sensor.

FWIW, here is where this is done:

elevation = self._astral_event(cur_dttm, "solar_elevation")
if elevation >= 10:
delta = 4 * 60
elif elevation >= 0:
delta = 2 * 60
elif elevation >= -6:
delta = 4 * 60
elif elevation >= -18:
delta = 8 * 60
else:
delta = 20 * 60
self._unsub_update = async_call_later(self.hass, delta, async_schedule_update)

So, right now, no, there's no way to change the update frequency of the azimuth sensor via the integration's configuration. You'd have to edit the code directly to do so. Which, of course, you can do.

Honestly, I've never really been happy with the implementation of the azimuth sensor. In fact, this integration didn't even have that sensor for a long time, which is why I chose the easy path of simply duplicating the standard sun integration's implementation, just to fill the gap in the integration.

I'm not sure I'd like to make the update frequency configurable. But it might make sense to make the update frequency for all elevations above -6 degrees be every 2 minutes (instead of only every 2 minutes for elevations between 0 - 10 degrees, and every 4 minutes for all other elevations above -6 degrees.) Would that suffice?

@pnbruckner pnbruckner reopened this Nov 6, 2024
@gsokoll
Copy link

gsokoll commented Nov 14, 2024

Thanks Phil. For my immediate needs, I've realised that the 4 minute update interval for azimuth isn't as big a problem as I was initially thinking. Refining to 2-minute updates as you've suggested would be a reasonable compromise I think.

@pnbruckner pnbruckner self-assigned this Nov 15, 2024
@pnbruckner pnbruckner added the enhancement New feature or request label Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants