Skip to content

Commit

Permalink
Merge pull request #188 from jeremypoulter/charge_timer_sleep
Browse files Browse the repository at this point in the history
'Fix' for changing charge mode when the timer is enabled.
  • Loading branch information
jeremypoulter authored Sep 12, 2018
2 parents f878324 + 12433b6 commit de78284
Show file tree
Hide file tree
Showing 9 changed files with 845 additions and 781 deletions.
67 changes: 34 additions & 33 deletions src/data/home.js

Large diffs are not rendered by default.

710 changes: 355 additions & 355 deletions src/data/lib.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/data/wifi_portal.htm
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html> <html lang=en > <meta charset=utf-8 > <title>OpenEVSE</title> <meta name=viewport content="width=device-width, initial-scale=1.0"> <meta name=viewport content="width=device-width, user-scalable=no" /> <meta name=description content=OpenEVSE > <meta name=author content=OpenEVSE > <meta name=theme-color content="#000000" /> <link rel=stylesheet type="text/css" href=style.css > <link rel=icon type="image/png" href=favicon-32x32.png sizes=32x32 /> <link rel=icon type="image/png" href=favicon-16x16.png sizes=16x16 /> <div id=page > <div class=header > <h1>Open<span>EVSE</span></h1> <h3>WiFi</h3> </div> <div class=container > <div class=box data-bind="visible: wifi.canConfigure() &amp;&amp; !wifi.wifiConnecting()"> <h2>WiFi Setup</h2> <p><b>Mode:</b> <span id=mode data-bind="text: status.fullMode"></span></p> <p>Connect to network:</p> <table> <thead> <tr> <th>Select <th>Network <th>RSSI dBm <tbody id=networks data-bind="foreach: scan.results"> <tr> <td><input class='networkcheckbox' name='network' data-bind="checkedValue: bssid(), checked: $root.wifi.bssid" type='radio'> <td data-bind="text: ssid"> <td data-bind="text: rssi"> <tfoot data-bind="visible: 0 == scan.results().length"> <tr> <td colspan=3 >Scanning... </table> <p data-bind="text: config.ssid"></p> <p> <b>Passkey:</b><br> <input type=text style="width:180px" autocapitalize=none autocapitalize=none data-bind="textInput: config.pass"> <button data-bind="click: wifi.saveNetwork, text: (wifi.saveNetworkFetching() ? 'Saving' : (wifi.saveNetworkSuccess() ? 'Saved' : 'Connect')), disable: wifi.saveNetworkFetching">Connect</button> </p> <p>Connecting to a local WiFi network is not essential. OpenEVSE can be configured and controlled while in AP mode:</p> <div> <button onclick="window.location.href='/home.htm'">Continue in AP mode</button> </div> <p><i><span class=small-text >Note: remote logging features e.g Emoncms will not work while in AP mode</span></i></p> </div> <div class=box data-bind="visible: wifi.wifiConnecting() || !wifi.canConfigure()"> <h2>Connecting to <span data-bind="text: config.ssid"></span> ...</h2> <p>Please connect this device to <span data-bind="text: config.ssid"></span> and navigate to the IP address displayed on your OpenEVSE display.</p> <p>Alternatively you can use <a href="http://openevse.local/">http://openevse.local/</a> or <a href="http://openevse/">http://openevse/</a></p> <div id=client-view data-bind="visible: status.isWifiClient"> <button id=apoff data-bind="click: wifi.turnOffAccessPoint, disable: wifi.turnOffAccessPointFetching">Continue</button> </div> </div> <!-- <div class=container > <div class=box > <h2>Continue without WiFi</h2> <p>Connecting to a local WiFi network is not essentail.</p> <p>OpenEVSE can be configured and controlled while in AP mode:</p> <div> <button onclick="window.location.href='/home.htm'">Continue</button> </div> <i>Note: remote logging features e.g Emoncms will not work while in AP mode</i> </div> </div> --> <div id=footer > <br><b> Powered by <a href="http://www.openevse.com">OpenEVSE</a> and <a href="https://openenergymonitor.org">OpenEnergyMonitor</a></b> <br> <b>Version: </b>V<span data-bind="text: config.version"></span> </div> </div> <!--end container --> </div> <!--end page --> <script src=lib.js ></script> <script src=wifi_portal.js ></script>
<!doctype html> <html lang=en > <meta charset=utf-8 > <title>OpenEVSE</title> <meta name=viewport content="width=device-width, initial-scale=1.0"> <meta name=viewport content="width=device-width, user-scalable=no" /> <meta name=description content=OpenEVSE > <meta name=author content=OpenEVSE > <meta name=theme-color content="#000000" /> <link rel=stylesheet type="text/css" href=style.css > <link rel=icon type="image/png" href=favicon-32x32.png sizes=32x32 /> <link rel=icon type="image/png" href=favicon-16x16.png sizes=16x16 /> <div id=page > <div class=header > <h1>Open<span>EVSE</span></h1> <h3>WiFi</h3> </div> <div class=container > <div class=box data-bind="visible: wifi.canConfigure() &amp;&amp; !wifi.wifiConnecting()"> <h2>WiFi Setup</h2> <p><b>Mode:</b> <span id=mode data-bind="text: status.fullMode"></span></p> <p>Connect to network:</p> <table> <thead> <tr> <th>Select <th>Network <th>RSSI dBm <tbody id=networks data-bind="foreach: scan.results"> <tr> <td><input class='networkcheckbox' name='network' data-bind="checkedValue: bssid(), checked: $root.wifi.bssid" type='radio'> <td data-bind="text: ssid"> <td data-bind="text: rssi"> <tfoot data-bind="visible: 0 == scan.results().length"> <tr> <td colspan=3 >Scanning... </table> <p data-bind="text: config.ssid"></p> <p> <b>Passkey:</b><br> <input type=text style="width:180px" autocapitalize=none autocapitalize=none data-bind="textInput: config.pass"> <button data-bind="click: wifi.saveNetwork, text: (wifi.saveNetworkFetching() ? 'Saving' : (wifi.saveNetworkSuccess() ? 'Saved' : 'Connect')), disable: wifi.saveNetworkFetching">Connect</button> </p> <p>Connecting to a local WiFi network is not essential. OpenEVSE can be configured and controlled while in standalone WiFi AP (Access Point) mode:</p> <div> <button onclick="window.location.href='/home.htm'">WiFi Standalone Mode</button> </div> <p><i><span class=small-text >Note: remote logging features e.g Emoncms will not work while in AP standalone mode</span></i></p> </div> <div class=box data-bind="visible: wifi.wifiConnecting() || !wifi.canConfigure()"> <h2>Connecting to <span data-bind="text: config.ssid"></span> ...</h2> <p>Please connect this device to <span data-bind="text: config.ssid"></span> and navigate to the IP address displayed on your OpenEVSE display.</p> <p>Alternatively you can use <a href="http://openevse.local/">http://openevse.local/</a> or <a href="http://openevse/">http://openevse/</a></p> <div id=client-view data-bind="visible: status.isWifiClient"> <button id=apoff data-bind="click: wifi.turnOffAccessPoint, disable: wifi.turnOffAccessPointFetching">Continue</button> </div> </div> <!-- <div class=container > <div class=box > <h2>Continue without WiFi</h2> <p>Connecting to a local WiFi network is not essentail.</p> <p>OpenEVSE can be configured and controlled while in AP mode:</p> <div> <button onclick="window.location.href='/home.htm'">Continue</button> </div> <i>Note: remote logging features e.g Emoncms will not work while in AP mode</i> </div> </div> --> <div id=footer > <br><b> Powered by <a href="http://www.openevse.com">OpenEVSE</a> and <a href="https://openenergymonitor.org">OpenEnergyMonitor</a></b> <br> <b>Version: </b>V<span data-bind="text: config.version"></span> </div> </div> <!--end container --> </div> <!--end page --> <script src=lib.js ></script> <script src=wifi_portal.js ></script>
25 changes: 23 additions & 2 deletions src/divert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,30 @@ void divert_update_state()
}

// If charge rate > min current and EVSE is sleeping then start charging
if (state == OPENEVSE_STATE_SLEEPING){
if (state == OPENEVSE_STATE_SLEEPING)
{
DBUGLN(F("Wake up EVSE"));
if(0 == rapiSender.sendCmd(F("$FE"))) {
bool chargeStarted = false;

// Check if the timer is enabled, we need to do a bit of hackery if it is
if(0 == rapiSender.sendCmd("$GD"))
{
if(rapiSender.getTokenCnt() >= 5 &&
(0 != String(rapiSender.getToken(1)).toInt() ||
0 != String(rapiSender.getToken(2)).toInt() ||
0 != String(rapiSender.getToken(3)).toInt() ||
0 != String(rapiSender.getToken(4)).toInt()))
{
// Timer is enabled so we need to emulate a button press to work around
// an issue with $FE not working
if(false == chargeStarted && 0 == rapiSender.sendCmd(F("$F1"))) {
DBUGLN(F("Starting charge with button press"));
chargeStarted = true;
}
}
}

if(false == chargeStarted && 0 == rapiSender.sendCmd(F("$FE"))) {
DBUGLN(F("Starting charge"));
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/html/openevse.js
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,16 @@ function OpenEVSE(endpoint)
return request;
};

/**
*
*/
self.press_button = function(callback) {
var request = self._request("F1", function() {
callback();
});
return request;
};

self.setEndpoint = function (endpoint) {
self._endpoint = endpoint;
};
Expand Down
33 changes: 32 additions & 1 deletion src/html/view_models/OpenEvseViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,39 @@ function OpenEvseViewModel(baseEndpoint, statusViewModel) {
};

// support for changing status
self.setStatus = function (action) {
self.setStatus = function (action)
{
var currentState = self.status.state();
if(("disabled" === action && 255 === currentState) ||
("sleep" === action && 254 === currentState) ||
("enable" === action && currentState < 254))
{
// nothing to do
return;
}

self.updatingStatus(true);
if(self.delayTimerEnabled() && ("sleep" === action || "enable" === action))
{
// If the delay Timer is enabled we have to do a bit of hackery to work around a
// firmware issue
//
// When in timer mode the RAPI cpmmands to change state might not work, but
// Emulating a button press does toggle between sleep/enable

self.openevse.press_button(function () {
action = false;
}).always(function () {
self.openevse.status(function (state) {
self.status.state(state);
}, action).always(function() {
self.updatingStatus(false);
});
});

return;
}

self.openevse.status(function (state) {
self.status.state(state);
}, action).always(function() {
Expand Down
Loading

0 comments on commit de78284

Please sign in to comment.