HomeGenie
HomeGenie copied to clipboard
Update homegenie.webapp.utility.js for displaying Temp with no decimal placed on Dashboard
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
Hi @soxfan1966! What's the reason to drop decimal places of the temperature displayed on Dashboard and Groups drop-down?
Its more in line with how the weather temps are reported - i.e. its 35 degrees not 35.2 degrees, just looks cleaner.
Looks like it depends on settings and data provider (and also one's preferences).
Here is how my Weather widged looks like:
I think it would be better if user can control display options (like it's possible to change C/F) globally.
I agree -a user preference would make sense. I also tweaked the weather widget, this is what mine looks like now:
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
OK, I will work on that - may take me some time thought.
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 ?
Or a new preference under Maintenance / User Interface? If a new preference, I would need to see how / where that would be defined.
Probably best to put it in as Options in the Startup code. Have a look at the Email Account for an example of this.
This is not a HG program or Widget change, it is a change to the system file "homegenie.webapp.utility.js"
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.
That is what I was suggesting: "would it make sense to just use the existing User Preference for Celsius or Fahrenheit ?"
Yes. It’s a binary choice for all so best to use what’s already configured in the initial setup of HG.
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.
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')
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 ?
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:
- helper methods to get and set setting
UI.TemperaturePrecision
(example name) in_maintenance.js
- add UI controls for editing this setting in
maintenance/main.html
- refactor
$$.GetLocaleTemperature
and$$.FormatTemperature
methods inhomegenie.webapp.utility.js