HomeGenie icon indicating copy to clipboard operation
HomeGenie copied to clipboard

Update homegenie.webapp.utility.js for displaying Temp with no decimal placed on Dashboard

Open soxfan1966 opened this issue 5 years ago • 16 comments

The temperature that is displayed in the Groups drop down (i.e. Dashboard) and in the upper right corner of the Dashboard if it contains the Weather Widget with a decimal place and one significant digit.

I made some changes to the Weather Widget to round the temperature up on that (along with the Fahrenheit display changes in another pull request) and I was able to find that making these changes as noted will round the temp display on the main Dashboard and Group drop down. Not sure if this would be better as an option or just allow the no decimal place code to be the default but wanted to share what I found.

Thanks

soxfan1966 avatar Feb 06 '20 18:02 soxfan1966

Hi @soxfan1966! What's the reason to drop decimal places of the temperature displayed on Dashboard and Groups drop-down?

Bounz avatar Feb 06 '20 19:02 Bounz

Its more in line with how the weather temps are reported - i.e. its 35 degrees not 35.2 degrees, just looks cleaner.

image

soxfan1966 avatar Feb 06 '20 19:02 soxfan1966

Looks like it depends on settings and data provider (and also one's preferences). Here is how my Weather widged looks like: image

I think it would be better if user can control display options (like it's possible to change C/F) globally.

Bounz avatar Feb 06 '20 19:02 Bounz

I agree -a user preference would make sense. I also tweaked the weather widget, this is what mine looks like now:

image

soxfan1966 avatar Feb 06 '20 19:02 soxfan1966

I believe the decimal is more relevant with metric measurements then imperial. However I'm more inclined to agree it should be a user preference

tuicemen avatar Feb 06 '20 22:02 tuicemen

OK, I will work on that - may take me some time thought.

soxfan1966 avatar Feb 07 '20 15:02 soxfan1966

In regards to a user preference for this, I was thinking of where this would need to be defined - its not really part of a Widget but more of a system preference.

With that, would it make sense to just use the existing User Preference for Celsius or Fahrenheit ?

image

Or a new preference under Maintenance / User Interface? If a new preference, I would need to see how / where that would be defined.

soxfan1966 avatar Feb 13 '20 14:02 soxfan1966

Probably best to put it in as Options in the Startup code. Have a look at the Email Account for an example of this.

mralapete avatar Feb 13 '20 15:02 mralapete

This is not a HG program or Widget change, it is a change to the system file "homegenie.webapp.utility.js"

soxfan1966 avatar Feb 13 '20 15:02 soxfan1966

Surely in the global settings the user will have already defined Celsius or Fahrenheit to be displayed. Why would they need to define it again. Could you reference the global settings in your program and pull it down from there.

mralapete avatar Feb 13 '20 16:02 mralapete

That is what I was suggesting: "would it make sense to just use the existing User Preference for Celsius or Fahrenheit ?"

soxfan1966 avatar Feb 13 '20 17:02 soxfan1966

Yes. It’s a binary choice for all so best to use what’s already configured in the initial setup of HG.

mralapete avatar Feb 13 '20 17:02 mralapete

I have updated my previous pull request so that the existing user preference for F or C is used to determine if the temperature should be rounded or not. If it is F, then the new rounding to zero decimal places is used and if it is C then the existing option to use decimal places is used.

soxfan1966 avatar Feb 23 '20 11:02 soxfan1966

I have controversial thoughts about this change. On the one hand Farenheit scale is more precise than Celcius so the decimals may be unneeded, but on the the other hand this change will break existing user's interface. Imaging you are a HG user and for years there is a decimal values in the interface. And after the update 1) your interface changes and 2) you have no way to enable decimals for F at all - this all may be really frustrating.

I still think it's better to have a separate option to turn decimals on and off. You can save the setting on the browser's side like it's made for temperature unit and then use the value in HG interface and widgets code:

HG.WebApp.Store.set('UI.TemperatureUnit')
HG.WebApp.Store.get('UI.TemperatureUnit')

Bounz avatar Feb 24 '20 06:02 Bounz

I think either option makes sense (speaking as someone who uses F and is not accustomed to seeing decimals). You mention HG.WebApp.Store.set('UI.TemperatureUnit')

Where would one define the UI.TemperatureUnit field? I assume this would be either decimal precision or just a Yes/No field ?

soxfan1966 avatar Feb 29 '20 11:02 soxfan1966

UI.TemperatureUnit was only an example of storing user settings in browser's local store. It's used in homegenie.webapp.utility.js, for example (you can easily find it using any editor or IDE like VS Code, VS, Rider, etc).

To make the whole thing you will need to implement:

  1. helper methods to get and set setting UI.TemperaturePrecision (example name) in _maintenance.js
  2. add UI controls for editing this setting in maintenance/main.html
  3. refactor $$.GetLocaleTemperature and $$.FormatTemperature methods in homegenie.webapp.utility.js

Bounz avatar Mar 02 '20 20:03 Bounz