OpenSprinkler / OpenSprinkler-Weather

OpenSprinkler weather service used to calculate watering scale for the OpenSprinkler Unified Firmware.
https://opensprinkler.com
63 stars 38 forks source link

Version shows "Undefined" #128

Closed phinnay closed 3 weeks ago

phinnay commented 2 years ago

hello, I have just completed the install of OpenSprinkler-Weather and it appears to be online. I am unsure if it's functional as several errors have popped up .

The most noticeable is when navigating to the address via a browser - instead of seeing "OpenSprinkler Weather Service" as per the documentation, I see: undefined v2.0.4 When viewing stdout logs the following appears:

os-weather-service@2.0.4 start
node js/server

undefined now listening on 0.0.0.0:80
undefined now listening for local weather stream
Loaded baseline ETo data.

js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
Arguments: 
[0] _isAMomentObject: true, _isUTC: false, _useUTC: false, _l: undefined, _i: undefinedZ, _f: undefined, _strict: undefined, _locale: [object Object]
Error
    at Function.createFromInputFallback (/opt/osp-weather/node_modules/moment/moment.js:320:98)
    at configFromString (/opt/osp-weather/node_modules/moment/moment.js:2385:15)
    at configFromInput (/opt/osp-weather/node_modules/moment/moment.js:2611:13)
    at prepareConfig (/opt/osp-weather/node_modules/moment/moment.js:2594:13)
    at createFromConfig (/opt/osp-weather/node_modules/moment/moment.js:2561:44)
    at createLocalOrUTC (/opt/osp-weather/node_modules/moment/moment.js:2648:16)
    at createLocal (/opt/osp-weather/node_modules/moment/moment.js:2652:16)
    at hooks (/opt/osp-weather/node_modules/moment/moment.js:12:29)
    at /opt/osp-weather/js/routes/weatherProviders/local.js:66:76
    at step (/opt/osp-weather/js/routes/weatherProviders/local.js:45:23)

WeeWX is pushing data correctly, but my openSprinkler device shows "Weather Service Offline" and "Last Response: Connection Failed" under System Diagnostics menu.

Do I have to wait a while? are these errors cosmetic? I do not see anywhere to increase verbosity nor dig into other diagnostics in the documentation.

Thanks!

rmloeb commented 2 years ago

The first message is generated in server.ts, but process.env.npm_package_description is apparently not populated. I cannot find where it's supposed to be populated, and I'm ignorant about most of node.js.

What is in your .env file? The listening port should have defaulted to 3000. Unless you specified a different port in the .env file, When you navigated to the weather-service URL, did you specify port 3000?

phinnay commented 2 years ago

Thanks for following up - I'm in the same boat with node, I can hack my way thru but the nuance is lost on me.

I am running the weather service on port 80 due to having an OpenSprinkler 2,x device where you can not specify an alternative port.

my .env file is as follows:

# cat .env
HOST=0.0.0.0`
PORT=80
WEATHER_PROVIDER=local
PWS=WU
LOCAL_PERSISTENCE=true
# 

for reference this is the bit in weewx.conf

    [[Wunderground]]
        # This section is for configuring posts to the Weather Underground.
        # this binding is sending weather info to OpenSprinkler via the server_url parameter
        enable = true
        station = <redacted>
        password = <redacted>
        server_url = https://osp-weather.home.<redacted>.com/weatherstation/updateweatherstation.php
        rapidfire = False

I can confirm it is listening, WeeWx is able to send data and confirms so in the logs.

May 4 18:20:43 weewx[18] INFO weewx.restx: Wunderground-PWS: Published record 2022-05-04 18:20:00 EDT (1651702800)

Stumbled across this thread mentioning the LOCALPERSISTENCE flag as well as the meaning of &errCode=10&scale=100_ when sending the script a test sequence. Adding the above flag indeed creates the observations.json file and is populating it with data

# ls -al observations.json
-rw-r--r-- 1 root root 18257 May  4 18:17 observations.json
# 

Not really sure whats going on! Leaning towards the errors being cosmetic combined with official documentation missing detail... Current plan is to see if everything suddenly turns green once it's got 48 hours of observations.

RE: documentation - that LOCAL_PERSISTENCE flag really should be mentioned in the Docker docs... as well as the suggestion to place it on persistent storage.

rmloeb commented 2 years ago

You should only need 24 hours of data. Might want to look at the observations.json file with an editor to make sure the observations look reasonable. I'm uncomfortable about that initial error message, because it does indicate that something is not correct in the program.

phinnay commented 2 years ago

Agreed! puzzling why that one bit is undefined.

I peeked inside the file and it doesnt seem right, excerpt below:

# cat observations.json
[{"timestamp":1651704300,"solarRadiation":null,"precip":null},{"timestamp":1651704000,"solarRadiation":null,"precip":null},{"timestamp":1651703700,"solarRadiation":null,"precip":null},{"timestamp":1651703400,"solarRadiation":null,"precip":null},{"timestamp":1651703100,"solarRadiation":null,"precip":null},{"timestamp":1651702800,"solarRadiation":null,"precip":null},{"timestamp":1651702500,"solarRadiation":null,"precip":null},{"timestamp":1651702200,"solarRadiation":null,"precip":null},{"timestamp":1651701900,"solarRadiation":null,"precip":null},{"timestamp":1651701600,"solarRadiation":null,"precip":null},{"timestamp":1651701300,"solarRadiation":null,"precip":null},{"timestamp":1651701000,"solarRadiation":null,"precip":null},{"timestamp":1651700700,"solarRadiation":null,"precip":null},{"timestamp":1651700400,"solarRadiation":null,"precip":null},{"timestamp":1651700100,"solarRadiation":null,"precip":null},{"timestamp":1651699800,"solarRadiation":null,"precip":null},{"timestamp":1651699500,"solarRadiation":null,"precip":null},{"timestamp":1651699200,"solarRadiation":null,"precip":null},{"timestamp":1651698900,"solarRadiation":null,"precip":null},{"timestamp":1651698600,"solarRadiation":null,"precip":null},{"timestamp":1651698300,"solarRadiation":null,"precip":null},{"timestamp":1651698000,"solarRadiation":null,"precip":null},{"timestamp":1651697700,"solarRadiation":null,"precip":null},{"timestamp":16516

lots of null values, but towards the beginning of the recording (bottom) it was getting values just fine:

{"timestamp":1651619400,"temp":53.8,"humidity":81,"solarRadiation":null,"precip":null},{"timestamp":1651619100,"temp":53.6,"humidity":81,"solarRadiation":null,"precip":null},{"timestamp":1651618800,"solarRadiation":null,"precip":null},{"timestamp":1651618500,"temp":54.3,"humidity":80,"solarRadiation":null,"precip":null},{"timestamp":1651618200,"temp":55,"humidity":79,"solarRadiation":null,"precip":null}]
# 

EDIT: The null values are coming from WeeWX, i'm investigating....

EDIT2: The null values seen in the observations.json file were caused by WeeWx-SDR deciding that my weather station is now a Fineoffset-WH65B and changing the packet type from FOWH65BPacket to FOWH65BAltPacket. Updated mappings and data is being recorded properly. Unknown why this changed all of a sudden but outside the scope of this issue.