HADashboard-widgets icon indicating copy to clipboard operation
HADashboard-widgets copied to clipboard

Local time

Open tollerm opened this issue 5 years ago • 11 comments

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?

tollerm avatar Apr 18 '19 17:04 tollerm

add:

time_zone: Europe/Stockholm  # Use your time zone here

to the widget parameters. I forgot to document this.

tjntomas avatar Apr 19 '19 16:04 tjntomas

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.

tollerm avatar Apr 19 '19 16:04 tollerm

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 avatar Apr 20 '19 09:04 tjntomas

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.

tjntomas avatar Apr 20 '19 09:04 tjntomas

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?

tuananh1094 avatar May 29 '19 02:05 tuananh1094

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

tjntomas avatar May 29 '19 05:05 tjntomas

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:

  • in variables.yaml
graph_style: "border-radius: 0px; background-color: rgba(30,30,30,0.45);"  # Change to whichever css you like.
graph_legend_text_color: "#888888"
graph_grid_color: "#888"
graph_title_color: "#cccccc"
graph_x_axis_text_color: "#cccccc"
graph_y_axis_legend_color: "#cccccc"
graph_y_axis_text_color: "#cccccc"
graph_widget_style: "border-bottom-left-radius: 10px;border-bottom-right-radius: 10px;border-top-left-radius: 10px;border-top-right-radius: 10px;"
graph_trace_colors: "1"  # Set the opacity for the trace colors.
graph_fill_colors: "1"   # Set the opacity for the fill colors.
graph_bar_colors: "1"    # Set the opacity for the bar colors.
graph_bar_multi: "1"     # Leave this as is
graph_degrees_celsius_text: "Degrees Celsius"  # Adjust to your own language
graph_degrees_fahrenheit_text: "Degrees Fahrenheit"  # Adjust to your own language
graph_percent_text: "Percent"  # Adjust to your own language
hagraph_path: https://myhome.duckdns.org:8123  # Adjust the port if needed.
hagraph_token: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmOTU4ZjlkOTZkODc0Mzc0OTI0ZWEzYTRhYTE1ZDJkOSIsImlhdCI6MTU1ODY5MzQyMSwiZXhwIjoxODc0MDUzNDIxfQ.QKNcm2Ggtnna6B1VHDFVpyy2qU3PW9c6oVmwPWYeVHM
time_zone: Asia/Ho_Chi_Minh
  • in mydashboard.dash
temperature:
  widget_type: hagraph
  entities:
    - sensor.temperature
  units: ""
  titles:
    - "Temperature(°C)"
  time: 24h
  time_zone: Asia/Ho_Chi_Minh
  title: "Temperature"
  value_in_legend: 1
  fill: "tozeroy"
  colorIndex: 0
  log: 1

tuananh1094 avatar May 29 '19 07:05 tuananh1094

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 avatar May 29 '19 15:05 tjntomas

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 avatar May 29 '19 15:05 tjntomas

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

tjntomas avatar Jun 01 '19 20:06 tjntomas

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.

swdwi2 avatar Apr 25 '20 11:04 swdwi2