genielabs / HomeGenie

HomeGenie, the programmable automation intelligence
https://homegenie.it
GNU General Public License v3.0
388 stars 154 forks source link

JkUtils - Solar Altitude = getting error in Widget since 1.3-stable.9 update #411

Closed soxfan1966 closed 4 years ago

soxfan1966 commented 4 years ago

Expected behavior

no errors

Actual behavior

getting compile / run time error

Steps to reproduce the problem starting from a fresh install

  1. Either use the Widget Editor or add the Solar Altitude widget to a Dashboard page
  2. Widget displays that it is not configured / Error displayed in Widget Editor

Specifications

Additional configuration notes

Good morning

I had noticed this the other day and tried looking into it, and I took the 1.3-stable.10 update this morning thinking maybe it would resolve the problem but its still there.

The Jk-Utils Solar Altitude program runs with no errors but the Widget has the following error:

TypeError: this.DataUiFieldsDisplayed[i].substr is not a function

This is in the ConvertTime function

Not sure what may have changed but I am running the standard version of this utility. Does anyone else have the same error with the widget?

tuicemen commented 4 years ago

Since this is an addon I suspect the author of it will need to look into this. I don't use this or the widget but do have it on my city place HG. I loaded up the widget and it tells me it is not configured. Looking at it I noticed the lat/lon parameters missing so I entered them. However widget still says it isn't configured. 🙄 Openweathermap did change some things recently so I'm wondering if the call parameters this uses were messed with.

mralapete commented 4 years ago

As a test click on the section where its says it's not configured on the widget. A Preference pop up should appear. Just change the Hue option and save.You should see updated readings now. Just report your findings.

soxfan1966 commented 4 years ago

I tried doing that but the Preferences doesn't launch. This is what the display of the widget looks like for me - notice the Preferences "window" below the widget. image

mralapete commented 4 years ago

Click on Sorry widget settings are still empty.The pop up will appear.Adjust the Hue settings and save.You should now see it updated

soxfan1966 commented 4 years ago

Nothing happens when I click anywhere in the widget - do you happen to know the field that gets updated for the Hue - I can try adjusting it in the code or in the Widget Edit Mode (the hamburger icon - the 3 line icon in the "bind to module" row.

mralapete commented 4 years ago

You'll find it in the Options section of the program.What browser are you using. Hover your mouse over the Sorry message and press Enter

soxfan1966 commented 4 years ago

I am using Chrome. There is no clickable indicator when I hover over the "Sorry ..." message nor anywhere else in the Widget.

In the program, I looked at the options this is what I have: image

mralapete commented 4 years ago

Most of these display issues in HG relate to browser types.Load up Firefox and try what I suggested above and report back.

soxfan1966 commented 4 years ago

I treid Firefox (note - both Firefox and Chrome are updated to the most recent versions on my computer). Same results for me in Firefox as in Chrome.

mralapete commented 4 years ago

I'm not a big fan of screen caps but here's the before and after I have in Firefox

Screenshot from 2020-06-08 15:10:42 Screenshot from 2020-06-08 15:11:22

mralapete commented 4 years ago

Do you have JKUtils Solar Altitude and JKUtils OpenWeatherData programs installed.

mralapete commented 4 years ago

Anyway this issue is not HG v1.3 r10 specific.This JS script is quite old, c2014 and the author Jan Koch of jkUtils fame I doubt is still active in the HG community. You might want to experiment with this one yourself.

soxfan1966 commented 4 years ago

I do not have the JKUtils OpenWeatherData program just the Solar Altitude one. I had tried to look into the issue myself - not sure what the problem is as nothing with the program or widget changed other than the recent HG updates.

mralapete commented 4 years ago

Try installing JkUtils OpenWeatherData too and run my above tests again.It won't conflict with your current weather setup. I installed all Weather and Environment programs just to troubleshoot your issue. This way we will be testing like with like setups.

soxfan1966 commented 4 years ago

I installed JK Open Weather Data (program and the widget).

I configured the program (API key, city, etc) and I am getting an error in the widget similar to what I was getting in the JK Solar Altitude - here is the JK Open Weather Data widget error:

TypeError: this.splice is not a function Line 106, Column 29

Here is the line of code at line 106: if (cuid) this.Container = $(cuid);

mralapete commented 4 years ago

Once you refresh your browser you loose your current JkUtils Solar Altitude and JkUtils OpenWeatherData settings.In order to restore them all you need to do is click on either widget and Preferences pop up will appear. Change any of the options here and the program will automatically update your readings. It appears that after refreshing the HG web ui the widget is not fetching the program readings. It should be easy enough to sort out.

mralapete commented 4 years ago

I installed JK Open Weather Data (program and the widget).

I configured the program (API key, city, etc) and I am getting an error in the widget similar to what I was getting in the JK Solar Altitude - here is the JK Open Weather Data widget error:

TypeError: this.splice is not a function Line 106, Column 29

Here is the line of code at line 106: if (cuid) this.Container = $(cuid);

Yes there is an error in the program but did you try to click on the widget to see if a Preferences pop up appears on top of either widget.This is what is driving the widget display settings.

mralapete commented 4 years ago

I've given you the results of my tests as per the above screen caps.I've got to get back to work now.Try experimenting with both JS scripts and their corresponding widgets to see if you can get those readings to hold. I'll do the same when I get more time.

soxfan1966 commented 4 years ago

For the JK Weather widget, yes - when I click inside it the preferences open up. Each of the fields has a value. For the Solar Altitude, no - nothing happens when I click inside the widget. However, I did look at the params defied in the program and each of those has a value too.

mralapete commented 4 years ago

I’ve screen capped and shown you the Preferences pop up in Solar Altitude widget above so both widgets are showing similar behaviour. As I mentioned these scripts haven’t been updated in quite a while but do work with a little experimentation. Not ideal but you need the time to experiment. Maybe that could be your next challenge or maybe Gene could have a look at this at some stage. It’s not v1.3 r10 specific though. Looks like it’s been like that for a while.

soxfan1966 commented 4 years ago

The JK Solar Altitude widget was working with no problem before I updated to 1.3-stable.9 last week,

tuicemen commented 4 years ago

@soxfan1966 Looks like this is a NorthAmerican thing LOL. I just checked my jkutils openweather data widget and it too isn't working even following @mralapete directions to fix (not that I hadn't already done that).

mralapete commented 4 years ago

As far as I can see there’s some form of conflict between Options in the script and Preferences in the widget. I don’t have time available to look at this any further but I’ll leave all components installed on my system do some further investigation when I do.

tuicemen commented 4 years ago

Just for kicks I reloaded the jkutils openweather data the opened the options screen again my hue value was 45. I changed that to @mralapete setting in his scteen shot I also notice zoom was set to 80 so set it to 100 and now everything is displaying corectlly 🙄 I haven't yet tried to reset zoom or hue values to what I had do that next.

mralapete commented 4 years ago

I picked Hue setting as an example of a setting to change quickly to demonstrate the Preferences updating overriding the Options Settings in the script. This does not fix the problem though.

This script was written before the Options setting was provided in HG. As a test leave all the fields in the Options section of the script blank other than the ones that the script provides as default. Finish off the config in the Preference pop up and see what results it returns. I’m not in a position to do that test myself.

tuicemen commented 4 years ago

Ok something strange is going on with these two widgets when I loaded up HG to set my old setting the widgets displayed the not configured messages again! Checking the iptions I see the settings are what I had set them to which got them displaying corectly. 🙄😖 so I reset to my original setting and the weather widget display worked but not the solar altitude😖🙄 refreshing the screen and now both are displaying the not configured messages again🙄

tuicemen commented 4 years ago

@mralapete I'll try your test and get back

soxfan1966 commented 4 years ago

I tried playing around with it a bot too with no luck

tuicemen commented 4 years ago

Did the test I cant get solar altitude widget to display corectly no mater what now. The openweather data widget will display if I leave the fields hue and custum size blank however a screen refresh throws the not configured message.

mralapete commented 4 years ago

As I said little or nothing had been done to the jkutils Scripts and widgets since it was first written. You will see the variables are updated regularly and are available for use. A closer inspection is needed of both widgets as they are bespoke and quite dated at this stage. Shouldn’t be too difficult to sort these out.

tuicemen commented 4 years ago

I never liked either widget and thought of redoing them but I don't use either widget. I do use the data from the solar altitude however.

soxfan1966 commented 4 years ago

The Solar Altitude widget is kinda interesting, but I don't use the JK weather one (I have my own version of the OpenWeatherMap program and widget).

The Solar Altitude program appears to be ok, it's just the widget that has the problem.

mralapete commented 4 years ago

There’s a wealth of open source widget editors out there that can be used and the end results can be imported into HG. As I said you could repurpose the Solar Altitude widget to suit your own needs. In fact I doubt it would take much work to edit the Solar Altitude widget to get it working properly. I quite like those two widgets but they are not rendering properly on small mobile devices.

mralapete commented 4 years ago

I meant to mention if you haven’t already studied Jan’s work here’s a link to it that might give you a better understanding of what’s going on http://old.homegenie.club:8080/www.homegenie.it/forum/indexa5ec.html?topic=124.0

soxfan1966 commented 4 years ago

OK, I played around with this some more and I think there is something amiss with the Widget Editor.

If you make a change to a widget then save it, go back to list of Widgets and pick the same widget again none of the changes you made will be saved.

I tried this with the Solar Altitude widget (I could get the error to go away by commenting out most of the code) and another widget - so I do not think it is specific to the Solar Altitude one.

Not sure if @genemars is following this or not - perhaps he can check into why changes to Widgets are not being saved.

mralapete commented 4 years ago

There’s a hierarchy in play as far as programs and widgets are concerned. You may see the difficulty Jan was having when working on his JKUtils originally. You may have to export the edited widget and reimport it. Again reading through his efforts he managed this with input from Gene but this was many years ago. Either way it well documented in that link I included.

soxfan1966 commented 4 years ago

The issue with edits for widgets not being saved is not just the Solar Altitiude widget - it appears to be happening for all widgets.

mralapete commented 4 years ago

I’ve never really used the widget editor. Not too friendly. Try one of the external editors and import the results to HG. What’s the binding on that widget.

soxfan1966 commented 4 years ago

I have used the HG Widget editor quite a lot and did not have any issues with it until recently - I have done more editing in the Programs the last few weeks so not sure if that means the Widget Editor was working after the 1.3-stable 8 update or not, but it definitely appears to be having problems now with the 1.3-stable 10 update (unless its just me - perhaps someone can confirm that theirs is also not saving edits).

mralapete commented 4 years ago

Fair enough.

If I was doing any serious editing/debugging I’d opt for something like VS Code. Saves a lot of headaches and it’s free of course.

It is important to note that nothing has been done on this particular code since 2014 when most if not all users/contributors were working in a MS Windows environment.

Again Gene would have to confirm what if any of this code needs to be refactored to work with an ARM build.

All you need now is to get his attention. It may save you a lot of hours in the long run.

If you do believe that somehow the widget editor is broken with recent updates post a separate issue on the subject. Might attract more attention.

soxfan1966 commented 4 years ago

On a whim, I disabled the "Http Service Cache" on the Maintenance / HTTP Settings page (I noticed this morning that the Weather Widget and another widget I have that I was making edits to yesterday to test were showing the changes I made, even though yesterday they did not - and when I checked the Widget code it had the changes I saved yesterday).

With that setting now disabled, I think the edits I am making to Widgets and saving are now appearing - not sure why that setting would affect this (and to be honest, not even sure what that setting is doing) but at least that appears to resolve the edits problem.

The Solar Altitude widget is still showing the error - for now, I have removed the widget from my Dashboard (the Program works with no errors, and that is what I need - the widget was more or less a nice to have).

soxfan1966 commented 4 years ago

Just an update - this is still an issue with the HG 1.3 stable 14 version as of yesterday afternoon.

mralapete commented 4 years ago

Just to clarify, did the Solar Altitude widget ever display correctly for you prior to v9.

I mentioned earlier that all I need to do to have it displaying correctly is to tap on the widget, the Preferences pop up appears and adjust any of those fields and the widget auto updates.

Is there anything blocking those variables being passed to the widget at your end.

Being a third party program/package which has had very little development carried out on it since it was first written you may have to carry out some work on it yourself to get it working. All part of the challenge with HG.

Have you looked at the suncalc.org for any further clues.

soxfan1966 commented 4 years ago

Yes, it used to display correctly. And I did attempt your suggestion to to fix it but nothing on the widget is clickable and if I edit something from the Widget Editor it does not help.

I thought widget was interesting but what I really need is the program (which works fine). I've tried playing around with the widget to get it to work with no success - my hunch is that something in a recent HG update broke it,

mralapete commented 4 years ago

I think the problem lies between the Options in the program and the Preferences pop up in the widget. Possibly disabling the Preferences pop up might allow the variables to be passed directly to the widget.

As you say you’re able to use the variables from Solar Altitude for your automations. That’s all that matters here.

mralapete commented 4 years ago

Just looking a little closer at the menu navigation. As a test and assuming you have the Options section preconfigured in the program, access HG via your browser as usual. Keep JK Utils Open Weather and JK Utils Solar Altitude in separate Groups.Now select Home and the Group you have JK Utils Solar Altitude in and select JK Utils Solar Altitude. The usual....not configured appears in the widget. Repeat this selection process exactly as you did above without navigating away from the Dashboard. Is the Solar Attitude widget displaying the correct readings now.

soxfan1966 commented 4 years ago

I have not had a chance to try that, but I'm getting a runtime error in the widget in the Widget Editor just trying to Run/Preview it from there.

mralapete commented 4 years ago

I've no idea why you're getting a runtime error.Is this showing after you've recompiled the program.What does the compiler report.

soxfan1966 commented 4 years ago

The error appears in the Widget Editor when I click the Run / Preview button. The error reported is: this,splice is not a valid function

That is the error I have now, I was trying to debug the issue using the console.log calls and the Chrome Console (very handy I might add) and think I resolved the first error I was getting, and I think this current one is similar / related.

In the Javascript code for the Widget that starts with this comment: //-- Create Property Elements one of the values in the array being processed is what is resulting in the error I noted above. I haven't had time to do more debugging with it this afternoon.

mralapete commented 4 years ago

Yes you can still try what I suggested as that error is not fatal.