Timezone in EmonCMS

During summertime I had an issue that the My Electric app shows yesterday’s use in KWh rather than today’s in the summary. This issue was reported here: EmonSD and time in Node Red? - #5 by Vster and the response is to set the timezone correctly in the user’s configuration. I made that change and it solved the problem for me.

However, I question whether this is the correct solution. That resolves the issue when the browser is in the same timezone as the server, but e.g. I travel often and when I do the problem would recur until my browser is back in Europe/London.

One option could be to always use the server’s timezone to determine how to divide up the days, since the energy usage (daytime vs. night) makes more sense in the server’s timezone anyway. Maybe there’s a better solution?

I’m mostly highlighting this as a feature request/call for ideas: my original problem has mostly been addressed for now.

I agree, It doesn’t matter where in the world you happen to be, energy data is only really relative to the local timezone of that location, I do not think browser time is of any interest, the api calls all have to be in UTC so “now” is the same globally once the browser’s local time is converted to UTC.

I recently helped someone in another part of the world with some emoncms issues and looking at thier public dashboards from here in the UK meant sunrise was around 2pm and solar PV was generated when in to the early hours of the following day.

The only time the current method is useful when abroad is IF you use you own device and have not changed the locality (ie it’s fixed to you home location) otherwise it is just confusing and causes the viwer to have to calculate every time they see to their home timezone from the local timezone their in at the time.

Consider someone with multiple homes/properties in different timezones, currently it is not possible to view both locations from any one palce without doing the time conversions in your head to make sense of what you see.

I’m all for choice so perhaps a user setting so a user can set their account to always use the browser timezone or to use the account timezone might suit a wider audience, but forced to choose one or the other, I think account TZ wins.

How do non-UK timezone emoncms.org users manage?

If the data posted is posted relative to UTC, stored in the database as UTC, when the dashboard is created, it could have a setting allowing a time relative to UTC timezone to be set - thus the dashboard (or each visualisation) is always in local time. You could make this clear in the Feed name for your own future reference.

This might solve the issue of a user with 2 data sources in different timezones.

Just a thought…

[edit] How do dashboards cope with the period where daylight saving is started / ended or are the dashboards always in UTC? Not thought about this before :smile:

Their browsers are persumably in the same “non-UK” timezone.

All data is stored in UTC, so data is sourced and saved as UTC, it’s only when viewing and or sub-totaling into days etc that any TZ is required, the data seen is always displayed with a time adjustment made locally so that the viewers TZ is used, eg if I look at someones data collected in Oz at around midnight UK time the PV generation will be at it’s peak because at midnight UK time it’s actually midday for the data being viewed.

I think an ability to set an over riding timezone per dash is a good idea, but ideally there needs to be a default, and that should be the account TZ NOT the almost irrelevant browser TZ.

That’s not necessary as the feeds are all UTC, which TZ the property that this feed applies to will be known from what property it’s from, if you have 2 houses you are unlikely to have 2 feeds called “waterheater” unless they are tagged house 1 and house 2, any dashboards for house 1 would have the dashboard set to the TZ of house 1 and all would be correct no matter who viewed the data from where on what.

Everything should be UTC except viewing, no matter where in the world you are or what browser you are using, when you view a dashboard, any timestamps used in the urls are in UTC derived (currently) from the local browser time and timezone. When the requests are fulfilled they are in UTC and then they get converted to “show” the local browser time locally by using the browser TZ, the data is still UTC as always.

By using the account (or dashboard) TZ instead of the browser TZ to view the data/dashboards/vizualisations etc, the data is still UTC but presented with a time adjustment relative to the geographic location of the data source rather than the current location of the viewer.

@pb66
I am using a dashboard that is viewed by people across different time zones and would like to fix the graph time axis on the site time zone. Has there been anymore updates after the comments above?

Would if be possible to assign a site specific time zone for each installation?

Not to my knowledge.

Not as far as I’m aware in the current code.

As I’ve stated above I believe the source of the data should dictate the TZ rather than were the user is based at the time of viewing, yes there are good reasons for making it user selectable per dashboard etc, but I think as a minimum, the account TZ should be used rather than the browser TZ for all viewing.

The reason it’s probably ended up the way it is currently is that most users are in the same country as the emoncms TZ settings for the account most of the time, so it is a small user base that would want to stick with the account TZ whilst abroad (or other user TZ’s view their data). It is an even smaller user group that have properties/devices in multiple TZ on one emoncms account so by using account TZ over browser TZ it would suit a wider range of users, but I’m guessing this won’t gain much traction unfortunately, but I hope I’m wrong.

A while back I started writing an apps module app that used the user session data to establish the TZ rather than using the browser TZ but I aborted that as it would only work for logged in users, not for viewing by api key (or public) (see Incorrect "en-EN" locale code used in emoncms? · Issue #888 · emoncms/emoncms · GitHub)

I have just raised an issue for this on the emoncms repo so it might get some consideration.

There must be some merit in giving the user a choice, as that’s what Grafana does.

Grafana_LBtime_UTC

The box to the right of “Timezone” is a pull-down menu. (as are the two boxes above it)

1 Like

Noting @pb66’s github issue, I think this is a good idea. Happy support a pull request if anyone is keen to implement, or/and will add to development list.

It would be very helpful if someone could address this issue. I have 3 sites across different timezones and it’s quite confusing when the data is displayed using my browser time.

1 Like

You could try up-voting the issue I raised on github in hope it might push it up the priorities list a place or 2.