Merged "Analog Sensor API", "ProgramView", "Flow Alert" and "Monitor and Control" to current (2.0!)#206
Conversation
|
linter is failing @opensprinklershop |
|
hello @opensprinklershop looks like there is a small linting issue that still needs to be resolved: |
mellodev
left a comment
There was a problem hiding this comment.
Hello, this is a massive PR! Lots of comments on this one:
| * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| --> | ||
| <html> | ||
| <html data-appversion="2.4.175"> |
There was a problem hiding this comment.
I wanted to double check on this attribute data-appversion. I don't see any related code to read this value, is it required? Additionally, a few months ago there were some changes to how the app versioning works. All app version references are updated automatically by the github workflows associated with builds. I'd suggest either we either remove this attribute if it's not needed, or update the workflows to set this value automatically.
There was a problem hiding this comment.
Yes, you can remove that. It was used to query the current version number.
| <!-- Load OSApp modules --> | ||
| <script src="js/modules/about.js"></script> | ||
| <script src="js/modules/analog.js"></script> | ||
| <script src="js/modules/programview.js"></script> |
There was a problem hiding this comment.
I'd suggest renaming this import and the file itself to program-view.js to match the file naming convention used by the other multi-word modules.
| CURRENT_FW : "2.3.3(172)", | ||
| CURRENT_FW_ID : 231, | ||
| CURRENT_FW_MIN : 150, |
There was a problem hiding this comment.
Perhaps renaming these variables to REQUIRED_FW, REQUIRED_FW_ID and REQUIRED_FW_MIN would be more descriptive? Later on in checkFirmwareUpdate we see these variables are being used to verify a minimum supported fw version for specific features and suggest the user update to a specific supported firmware if needed.
| } | ||
| }; | ||
|
|
||
| OSApp.Analog.checkAnalogSensorAvail = function() { | ||
| return OSApp.currentSession.controller.options && OSApp.currentSession.controller.options.feature === "ASB"; | ||
| return OSApp.currentSession.controller.options && OSApp.currentSession.controller.options.feature.includes("ASB"); |
There was a problem hiding this comment.
This function is called from several other places in the app. I think this needs an elvis operator added to prevent an exception when options.feature is undefined.
| return OSApp.currentSession.controller.options && OSApp.currentSession.controller.options.feature.includes("ASB"); | |
| return OSApp.currentSession.controller.options && OSApp.currentSession.controller.options.feature?.includes("ASB"); |
There was a problem hiding this comment.
As soon as the extensions of my extended firmware have been included in the standard firmware, this can be removed
| }; | ||
|
|
||
| OSApp.Analog.checkMonitorAlerts = function() { | ||
| if (!window.cordova || !window.cordova.plugins || !OSApp.Analog.monitors || (!OSApp.currentDevice.isAndroid && !OSApp.currentDevice.isiOS)) |
There was a problem hiding this comment.
This looks like a really good candidate to be refactored out to it's own function. Looks like we duplicate this exact/similar logic in several functions in analog.js
| /* global $, ApexCharts */ | ||
|
|
||
| /*! | ||
| * Analog Sensor API - GUI for OpenSprinkler App | ||
| * https://github.com/opensprinklershop/ | ||
| * (c) 2023 OpenSprinklerShop | ||
| * Released under the MIT License | ||
| */ | ||
|
|
There was a problem hiding this comment.
The end-user documentation is easy: Press the "Start" button to start the program ;-)
| OSApp.Firmware.sendToOS("/du?pw=", "json").then( function( status ) { | ||
| var popup = "<div data-role='popup' id='debugWU' class='ui-content ui-page-theme-a'>"; |
There was a problem hiding this comment.
There was a problem hiding this comment.
yes, looks like checkOSVersion is missing here.
| if ( typeof OSApp.currentSession.controller.settings.otcs === "number" || (status && status.hasOwnProperty("status")) ) { | ||
| popup += "<div class='debugWUHeading'>Integrations</div>" + | ||
| "<table class='debugWUTable'>"; | ||
| if (typeof OSApp.currentSession.controller.settings.otcs === "number") | ||
| popup += "<tr><td>OpenThings Cloud</td><td>" + OSApp.SystemDiagnostics.resolveOTCStatus( OSApp.currentSession.controller.settings.otcs ) + "</td></tr>"; | ||
| if (status.hasOwnProperty("freeBytes")) | ||
| popup += "<tr><td>Free Bytes</td><td>" + OSApp.SystemDiagnostics.format2(status.freeBytes/1024) + " KB</td></tr>"; | ||
| if (status.hasOwnProperty("pingok")) | ||
| popup += "<tr><td>Ping check ok</td><td>" + status.pingok + "</td></tr>"; | ||
| if (status.hasOwnProperty("mqtt")) | ||
| popup += "<tr><td>MQTT</td><td>" + (status.mqtt?"connected":"disconnected") + "</td></tr>"; | ||
| if (status.hasOwnProperty("influxdb")) | ||
| popup += "<tr><td>influxdb</td><td>" + (status.influxdb ? "enabled" : "disabled") + "</td></tr>"; | ||
| if (status.hasOwnProperty("ifttt")) | ||
| popup += "<tr><td>IFTTT</td><td>" + (status.ifttt?"enabled":"disabled") + "</td></tr>"; | ||
| popup +="</table>"; | ||
| } |
There was a problem hiding this comment.
Consider passing all these string literals through the language translation OSApp.Language._()
| OSApp.Utils.escapeJSON2 = function( json ) { | ||
| return JSON.stringify( json ).replace(/#/g, "%23").replace(/=/g, "%3D").replace( /\{|\}/g, "" ); | ||
| }; | ||
|
|
There was a problem hiding this comment.
Out of curiosity, why are we implementing this ourselves rather than using encodeURIComponent? This escapeJSON2 and it's sibling escapeJSON both feature very limited/incomplete sets of character replacements/transformations.
There was a problem hiding this comment.
I think the problem was, that encodeURIComponent does too much, also escapes " and = and other elements that are needed by the json format.
There was a problem hiding this comment.
Out of curiosity why are we upgrading from v3.35.1 to v3.50.0? This jumps about 15 minor version releases they've made. If the goal is to update to the latest in the 3.x.x major version, it looks like v3.54.1 is the latest:
There was a problem hiding this comment.
Yes latest version is ok
|
I checked this PR out locally, made a branch from it and resolved almost every comment above (the ones with thumbs up reactopm). There were a couple I wasn't sure about (eyeballs reaction) so I left that untouched. See the updated branch PR here: #213 Does that mean we can close this one and use my #213 going forward? |
|
Closing in favor of #213 |




Analog Sensor API + Program View