tjntomas / HADashboard-widgets

Widgets for HADashboard / Appdaemon
MIT License
52 stars 26 forks source link

Local time #9

Open tollerm opened 5 years ago

tollerm commented 5 years ago

it seems that the hagraph widget uses UTC time when plotting histories from the Home Assistant. Is it possible to plot sensors data using local time?

tjntomas commented 5 years ago

add:

time_zone: Europe/Stockholm  # Use your time zone here

to the widget parameters. I forgot to document this.

tollerm commented 5 years ago

Thanks! It works when I put this line into the 'variables.yaml' file. While it doea not matter, may be, it would be better to assign the value to this variable in the 'main.dash' file? And to do the same for variables hagraph.path and hagraph.token. It seems for me a little bit illogical to assign values to these variables in the css folder. Thanks again for your prompt help.

tjntomas commented 5 years ago

Yes, it would be better to have it in the main options in the dash file, but these parameters are not exposed by appdaemon to the widget so there is no way of accessing them from javascript.

tjntomas commented 5 years ago

I will however add an option to add token etc. to the widget parameters. The reason I put them in the css is so I don´t have to add them to each and every widget since I have a lot.

tuananh1094 commented 5 years ago

Hi tjntomas, I try add my "time_zone: Asia/Ho_Chi_Minh" to widgets definition, but time in my graph is not true. Can you help me fix it?

tjntomas commented 5 years ago

time_zone: Asia/Ho_Chi_Minh works fine when I try it. Have you tried clearing the browseer cache or recompiling the widget?

tuananh1094 commented 5 years ago

Thank you for your prompt response, I tried clearing browser cache and recompiling but it stills not work for me. I try put "time_zone" in variables.yaml or in my dashboard, but nothing changed. You can see my config below:

tjntomas commented 5 years ago

Just noticed that you are using the hagraph widget. I only implemented the time_zone for the graph widget. I'll upload a new basehagraph.js in a bit.

tjntomas commented 5 years ago

Ok, so the repo is updated. You need to replace your existing basehagraph.js file with the new one from here. I have added some debug so the javascript console should log the current time zone settings etc.

please also try to add your locale to the widget def (which I think is 'vi' but it might be 've') locale: vi

tjntomas commented 5 years ago

tuananh1094, I deleted your post since your duckdns address was included, better to be safe than sorry.

swdwi2 commented 4 years ago

Hope you can help me with this issue also. I have the time zone set to my time zone (Europe/London) tried this in both the custom_css variables.yaml and by direct edit in the custom_widget js file. The java console shows that it is reading Europe/London. However the time base on the hagraph widget is 1 hour out. i.e. it shows 1 hour earlier than the current time at its most recent update. Also the data being displayed is time shifted. So an event that took place at say 8am local time is in the HA mini graph at 8am but is displayed in hagraph at 7am.