diff --git a/demandshaper-module/demandshaper_controller.php b/demandshaper-module/demandshaper_controller.php index f4ee6e8..369669a 100644 --- a/demandshaper-module/demandshaper_controller.php +++ b/demandshaper-module/demandshaper_controller.php @@ -257,12 +257,14 @@ function demandshaper_controller() $state->ctrl_mode = "timer"; } } - else if ($ret[1]==1 || $ret[1]==3) { + else if ($ret[1]==1 || $ret[1]==2 || $ret[1]==3) { if ($state->timer_start1==0 && $state->timer_stop1==0) { $state->ctrl_mode = "on"; } else { $state->ctrl_mode = "timer"; } + } else if ($ret[1]==255) { + $state->ctrl_mode = "disabled"; } } else { $valid = false; diff --git a/demandshaper-module/general.js b/demandshaper-module/general.js index 6566a24..09046de 100644 --- a/demandshaper-module/general.js +++ b/demandshaper-module/general.js @@ -11,6 +11,10 @@ function load_device(device_id, device_name, device_type) // $(".device-name").html(" ("+device_name+")"); $(".node-scheduler").attr("node",device_name); + + if (device_type=="openevse") { + $("#mode button[mode='disabled']").show(); + } // ------------------------------------------------------------------------- // Defaults @@ -243,6 +247,7 @@ function load_device(device_id, device_name, device_type) if (schedule.settings.ctrlmode=="smart") { $(".smart").show(); $(".timer").hide(); $(".repeat").show(); } if (schedule.settings.ctrlmode=="on") { $(".smart").hide(); $(".timer").hide(); $(".repeat").hide(); } if (schedule.settings.ctrlmode=="off") { $(".smart").hide(); $(".timer").hide(); $(".repeat").hide(); } + if (schedule.settings.ctrlmode=="disabled") { $(".smart").hide(); $(".timer").hide(); $(".repeat").hide(); } // var elapsed = Math.round((new Date()).getTime()*0.001 - schedule.settings.last_update_from_device); // $("#last_update_from_device").html(elapsed+"s ago"); @@ -645,6 +650,9 @@ function load_device(device_id, device_name, device_type) case "off": $(this).addClass("red").siblings().removeClass('red').removeClass('green'); break; + case "disabled": + $(this).addClass("red").siblings().removeClass('red').removeClass('green'); + break; case "timer": // if (schedule.settings.period==0) schedule.settings.period = last_period; // if (schedule.settings.end==0) schedule.settings.end = 8.0; diff --git a/demandshaper-module/general.php b/demandshaper-module/general.php index e685414..e720b35 100644 --- a/demandshaper-module/general.php +++ b/demandshaper-module/general.php @@ -11,7 +11,7 @@
- +


diff --git a/demandshaper_run.php b/demandshaper_run.php index 0e88257..50d003e 100644 --- a/demandshaper_run.php +++ b/demandshaper_run.php @@ -227,6 +227,7 @@ if ($schedule->settings->ctrlmode=="on") $status = 1; if ($schedule->settings->ctrlmode=="off") $status = 0; + if ($schedule->settings->ctrlmode=="disabled") $status = -1; if ($status) { $log->info(" status: ON"); @@ -283,6 +284,9 @@ $timer[$device] = time_conv_dec_str($s1)." ".time_conv_dec_str($e1)." ".time_conv_dec_str($s2)." ".time_conv_dec_str($e2); } if ($device_type=="openevse") { + // in case it was disabled before + $mqtt_client->publish("$basetopic/$device/rapi/in/\$FE","",0); + $api = "rapi/in/\$ST"; $timer[$device] = time_conv_dec_str($s1," ")." ".time_conv_dec_str($e1," "); } @@ -303,6 +307,7 @@ if ($ctrlmode=="on") $ctrlmode_status = "On"; if ($ctrlmode=="smart") $ctrlmode_status = "Timer"; if ($ctrlmode=="timer") $ctrlmode_status = "Timer"; + if ($ctrlmode=="disabled") $ctrlmode_status = "Disabled"; if ($device_type=="smartplug" || $device_type=="hpmon" || $device_type=="wifirelay") { $mqtt_client->publish("$basetopic/$device/in/ctrlmode",$ctrlmode_status,0); @@ -310,7 +315,7 @@ } if ($device_type=="openevse") { - if ($ctrlmode=="on" || $ctrlmode=="off") { + if ($ctrlmode=="on" || $ctrlmode=="off" || $ctrlmode=="disabled") { $mqtt_client->publish("$basetopic/$device/rapi/in/\$ST","00 00 00 00",0); } if ($ctrlmode=="on") { @@ -321,6 +326,10 @@ $mqtt_client->publish("$basetopic/$device/rapi/in/\$FS","",0); schedule_log("$device turning OFF"); } + if ($ctrlmode=="disabled") { + $mqtt_client->publish("emon/$device/rapi/in/\$FD","",0); + schedule_log("$device turning DISABLED"); + } } } $last_ctrlmode[$device] = $ctrlmode; @@ -523,6 +532,7 @@ function message($message) if (isset($p->ctrlmode)) { if ($p->ctrlmode=="On") $schedules->$device->settings->ctrlmode = "on"; if ($p->ctrlmode=="Off") $schedules->$device->settings->ctrlmode = "off"; + if ($p->ctrlmode=="Disabled") $schedules->$device->settings->ctrlmode = "disabled"; if ($p->ctrlmode=="Timer" && $schedules->$device->settings->ctrlmode!="smart") $schedules->$device->settings->ctrlmode = "timer"; } @@ -545,6 +555,7 @@ function message($message) else if ($message->topic=="$basetopic/$device/out/ctrlmode") { if ($p=="On") $schedules->$device->settings->ctrlmode = "on"; if ($p=="Off") $schedules->$device->settings->ctrlmode = "off"; + if ($p=="Disabled") $schedules->$device->settings->ctrlmode = "disabled"; if ($p=="Timer" && $schedules->$device->settings->ctrlmode!="smart") $schedules->$device->settings->ctrlmode = "timer"; $demandshaper->set($userid,$schedules); }