Please login or register.

Login with username, password and session length
Pages: 1 [2] 3

Author Topic: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp  (Read 5919 times)

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #15 on: February 04, 2020, 01:03:52 PM »

I think I found where this temperature display on the Dashboard header is getting its value from.

In the BaseFiles/Common/html/js/app/homegenie.webapp.utility.js file (which I found here: https://github.com/genielabs/HomeGenie/tree/master/BaseFiles/Common/html/js/app)

it builds a variable called temp based on the temperatureUnit field (C or F) and then uses this code:

displayvalue = (temp * 1).toFixed(1) + '°';

I did some searching and it looks like that .ToFixed(1) function is rounding the value to 1 digit after the decimal point.  If it were toFixed(0) it would round to zero decimal places.
Lines 261 and 265 if you are interested.

I tested this here:

https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_tofixed

So I think that would fix it, problem is it looks like its a core HG file and not a widget or program, so it means editing the file on the pi itself to make that change and then re-starting the service so it takes affect.

I can give that a whirl when I have a chance and see what happens.
Logged

bkenobi

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 24
  • Posts: 2081
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #16 on: February 04, 2020, 01:19:43 PM »

Nice work.  Java script is interpretted code rather than compiled.  It is embedded in html and if you look at the path you found, the code should be something you can change on your RPi and test.  Yes, you should probably stop the service, make the change, and start HG again.  You should keep in mind that if Gene updates HG it is possible your update could be lost.  You could submit a change request in the Issues section if you think that might be a common request.  I personally don't think it's valuable having any decimal places for either the current or predicted temperatures.  The temperature where it is measured won't be the same 10' away or 10 seconds later (to that accuracy), so why include it.

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 282
  • Posts: 10497
  • I don't work for X10, I use it successfuly!
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #17 on: February 04, 2020, 02:32:20 PM »

 #:) you just keep plugging away. I think we created a Eveready coding bunny  rofl
 >!
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #18 on: February 04, 2020, 04:33:35 PM »

Well, that seemed like the likely place but there must be somewhere else its doing something similar.  I made the changes as I noted, stopped the service and then started it again but no luck.  Still displaying the temp with 1 decimal place in the Dashboard header.

I will try poking around some more, probably tomorrow.
Logged

bkenobi

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 24
  • Posts: 2081
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #19 on: February 04, 2020, 05:19:03 PM »

The temperature is most likely stored in a float and only changed to a 1-digit decimal when displayed.  I don't know if changing it to round down to 0-places will affect anything on the display side for the widget since the widget will presumably format the output as needed.  Seems like the widget is where you should be focusing on, but I haven't looked so I'm not sure.

Tuicemen

  • Administrator
  • Hero Member
  • ****
  • Helpful Post Rating: 282
  • Posts: 10497
  • I don't work for X10, I use it successfuly!
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #20 on: February 04, 2020, 05:27:19 PM »

I believe the API supplies a 2 decimal value HG converts that to 1 decimal. If you play with the program side and chage the value to a value with no decimal that nuber gets displayed in the widget and the
HG header bar. So I suspect that is where you need to do your math.round. remember values will only change after a pull.
Logged
Please Read Topic:
General Forum Etiquette
Before you post!

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #21 on: February 05, 2020, 06:22:06 AM »

I had found another field using the ToFixed(1) that I changed to ToFixed(0) under temperature just above the other 2 lines I had changed (which were in Format temperature).

Then I restarted the service again - but same results.

Oddly, this morning I pulled up the HomeGenie page (from a web browser, not the android app) and the temps displaying in the Dashboard header and drop down selection both showed the temperature with 0 decimal places.   I get to work and pull up the HomeGenie page from a web browser on my work pc and the temps show 1 decimal place.  Not sure why, will see if there is some other place where a different display is used for mobile vs desktop ?

Images attached - the rounded temp displays are from my phone whereas the ones with 1 decimal place are from my work pc.
« Last Edit: February 05, 2020, 06:25:22 AM by soxfan1966 »
Logged

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #22 on: February 05, 2020, 09:01:03 AM »

I was inspecting the HTML code that is running on my work pc (a nice feature in Chrome btw) and was able to find the field for the temperature that is being displayed with the decimals.  The field is called hg-indicator-temperature and it is the same field in both the Home menu selection (where you pick a dashboard) and in the upper right corner of the Dashboard.

Trying to look at where this field / value is coming from.
Logged

bkenobi

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 24
  • Posts: 2081
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #23 on: February 05, 2020, 12:26:09 PM »

Remember that HG sometimes requires clearing the cache to work when it breaks.  I wonder if your changes were being effective, but your browser wasn't pulling up the new code.

petera

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 27
  • Posts: 1750
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #24 on: February 05, 2020, 12:53:51 PM »


I generally find restarting the service after an edit and save helps too. The difference in how an element is displayed in different browsers has always been an issue in HG. Looking through previous code samples will show how these differences were catered for and hard coded into the relevant programs.
Logged

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #25 on: February 05, 2020, 02:22:14 PM »

Good call on the browser cache.  I cleared my cache (not history etc, just the cache - I use Chrome) and then loaded HG again.  It took a lot longer to load (which was expected) but the temperature on the Dashboard dropdown and the upper right corner of the Dashboard both are displaying with no decimal places.

If someone wants to verify the code fix for me, I could submit a pull request over on the HG site.  Haven't done one of those before so I would feel more fomfortable if someone had a chance to validate my findings if possible.

Thanks
Logged

petera

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 27
  • Posts: 1750
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #26 on: February 05, 2020, 02:57:23 PM »

Good call on the browser cache.  I cleared my cache (not history etc, just the cache - I use Chrome) and then loaded HG again.  It took a lot longer to load (which was expected) but the temperature on the Dashboard dropdown and the upper right corner of the Dashboard both are displaying with no decimal places.

If someone wants to verify the code fix for me, I could submit a pull request over on the HG site.  Haven't done one of those before so I would feel more fomfortable if someone had a chance to validate my findings if possible.

Thanks

Submit the pull request anyway. The author will validate and approve it for inclusion it if he feels it will be of general use to others. Not all pull requests do get approved for obvious reasons and the author is not very active these days so don’t expect immediate attention.

Many HG users have their own customised versions of HG running but don’t see the need to submit these customisations.

Now that you’re well beyond the novice stage I suggest getting more active over on the HomeGenie Club forum where a number of new members have joined who are well versed in C# and Python as well as those who are already established where you can exchange ideas. You’ll see from the posts yourself.

Happy productivity to you and HG.
Logged

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #27 on: February 06, 2020, 12:59:38 PM »

I will post the pull request and also add some more info for my post on the Home Genie Club too (and take a look around there).

It happened to be snowing this morning (well, freezing rain but that gets reported as snow).  I noticed the Weather Widget only shows 0 in of rain.

So I played around with it some more and have a version 2.0 for my changes now (see image)

I will show Snow (the word, as there is no icon for the white snow like rain) with the rate if its > o otherwise the snow info should not appear.  I also noticed it can be snowing and raining in the reported info, so I will show both if that is true, and similar to what I did with the snow rate, if the rain rate is 0 I will not show it.  I also am reporting the rain and snow rates with 2 decimal places as we were getting less than an inch of each and it made sense to show a number and not just 0.

And then I played around with the formatting (i.e. moved the wind speed under the weather icon, indented things) so it hopefully looks nicer.  Updated program and widget also attached if you are interested.

Logged

petera

  • PI Expert
  • Hero Member
  • ******
  • Helpful Post Rating: 27
  • Posts: 1750
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #28 on: February 06, 2020, 01:08:36 PM »

If I get a chance I’ll give it a spin. I’ve locked down my HG installation for now and am back working with both Home Assistant and Vera.

I dispensed with the Raspberry Pi Zero W as its performance with HG is sluggish. It’s now running on a Raspberry Pi 3b+ and the difference is very noticeable.

A few more posts over on the HG forum and you will be able to post your OW code contributions so get posting.
Logged

soxfan1966

  • Hero Member
  • *****
  • Helpful Post Rating: 3
  • Posts: 388
Re: OpenWeatherMap to include Today's High Temp forecast and Feels Like Temp
« Reply #29 on: February 06, 2020, 01:23:25 PM »

Pull request for the Temp to display with no decimal places in the Dashboard has been posted:
https://github.com/genielabs/HomeGenie/pull/398

Thanks
Logged
Pages: 1 [2] 3
 

X10.com | About X10 | X10 Security Systems | Cameras| Package Deals
© Copyright 2014-2016 X10.com All rights reserved.