Fixing History Timezones

Fixing History Timezones

If for some reason the trends aren't showing up. Its likely that the his tz (timezone) doesn't match the point tz. To fix this, follow the below steps. Also, history is still being collected, its just not matching the same point timezone.

Issue - Los Angeles != Indianapolis

Currently the points have tz set as Los Angeles, but his data is set to Indianapolis tz. 

Option 1: Setting all to Indianapolis

We want to set everything to Indianapolis tz. Since our his tz is already set to Indianapolis, we go to the site and select the tz to be Indianapolis. Then click on the Sync Time zones For All Points. Thats it, both should be matching now.

Option 2: Setting all to Los Angeles

We want to set everything to Los Angeles tz. Currently the his tz is set to Indianapolis, so the user would need to match the point tz to the his tz. The user will follow Option 1 first to match the both his and point timezones. Once done doing Option 1, we'll need to rewrite the tz on the his data to Los Angeles. To do this, go to folio and run the query below for all points (if you have multiple sites with different tzs, we recommend using siteRef in the query).

QueryreadAll(point).each x=> hisRewrite(x->id) (val, ts) => [ts.toTimeZone("Los_Angeles"), val]

Note: Change "Los_Angeles" part to what timezone you want it to be. Look below on how to know which timezone to use.

Then once changing the his tz to Los Angeles, go to the site and change the timezone to Los Angeles and sync it to all points. Thats it, everything should now be using Los Angeles tz.

If the query isn't working for you because your points have different timezones (e.g. half are Los_Angeles and half are Indianapolis) then use this query, it will return those that were in the previous timezone:

Query: readAll(point and his).findAll(x=> try do hisRewrite(x->id) (val, ts) => [ts.toTimeZone("Los_Angeles"), val] ; false end catch true)

Changing to new timezone

If for some reason the tz isn't what you want and you want to change it. The user would first change the his tz and then the point tz. This is for those that don't have the above issue and everything is working fine.

Step 1: 

We'll need to rewrite the tz on the his data to Los Angeles (or whatever timezone you want). To do this, go to folio and run the query below for all points (if you have multiple sites with different tzs, we recommend using siteRef in the query).

QueryreadAll(point).each x=> hisRewrite(x->id) (val, ts) => [ts.toTimeZone("Los_Angeles"), val]

Note: Change "Los_Angeles" part to what timezone you want it to be. Look below on how to know which timezone to use.

Step 2: Go to the site and change the timezone to Los Angeles and Sync it to all points. Thats it.

Finding the his tz on a point

Here is how to find the his tz on a point.

First, copy the id of one point that has the issue.

Then run a hisRead query for that point to get the below error: read(id==@1ffcb9fa-02e6aeba).hisRead(today)

That will let you know what which timezone its using. In this case its Indianapolis.

How to know which timezone to use for query

To find out which timezone you want to use for the query to modify all, look on the site timezone drop down. It would be whatever is after the last forward slash "/".

Here are a few examples timezones you would use based on the screenshot below.

America/Indian/Know => Knox => Query: readAll(point).each x=> hisRewrite(x->id) (val, ts) => [ts.toTimeZone("Knox"), val]

America/Lima => Lima => Query: readAll(point).each x=> hisRewrite(x->id) (val, ts) => [ts.toTimeZone("Lima"), val]

America/Los_Angeles => Los_Angeles => Query: readAll(point).each x=> hisRewrite(x->id) (val, ts) => [ts.toTimeZone("Los_Angeles"), val]