diff --git a/emhttp/plugins/dynamix/DashStats.page b/emhttp/plugins/dynamix/DashStats.page
index 46bc3460f..bb0e63894 100644
--- a/emhttp/plugins/dynamix/DashStats.page
+++ b/emhttp/plugins/dynamix/DashStats.page
@@ -1615,17 +1615,17 @@ dashboard.on('message',function(msg,meta) {
});
var apcups = new NchanSubscriber('/sub/apcups',{subscriber:'websocket'});
-apcups.on('message',function(data) {
- data = data.split(';');
- $('#ups_model').html(data[0]);
- $('#ups_status').html(data[1]);
- $('#ups_status_').html(data[1]);
- $('#ups_bcharge').html(data[2]);
- $('#ups_timeleft').html(data[3]);
- $('#ups_nompower').html(data[4]);
- $('#ups_loadpct').html(data[5]);
- $('#ups_loadpct_').html(data[5]);
- $('#ups_outputv').html(data[6]);
+apcups.on('message',function(msg) {
+ var get = JSON.parse(msg);
+ $('#ups_model').html(get[0]);
+ $('#ups_status').html(get[1]);
+ $('#ups_status_').html(get[1]);
+ $('#ups_bcharge').html(get[2]);
+ $('#ups_timeleft').html(get[3]);
+ $('#ups_nompower').html(get[4]);
+ $('#ups_loadpct').html(get[5]);
+ $('#ups_loadpct_').html(get[5]);
+ $('#ups_outputv').html(get[6]);
});
diff --git a/emhttp/plugins/dynamix/nchan/ups_status b/emhttp/plugins/dynamix/nchan/ups_status
index 505824801..6939283f1 100755
--- a/emhttp/plugins/dynamix/nchan/ups_status
+++ b/emhttp/plugins/dynamix/nchan/ups_status
@@ -68,8 +68,8 @@ while (true) {
$locale_init = _var($display,'locale');
update_translation($locale_init);
}
- unset($status,$rows,$power,$load,$freq,$output,$volt);
- $status = array_fill(0,7,"-");
+ unset($echo,$rows,$power,$load,$freq,$output,$volt);
+ $echo = array_fill(0,7,"-");
if (file_exists("/var/run/apcupsd.pid")) {
// get battery-level and runtime settings
$cfg = parse_plugin_cfg('dynamix.apcupsd');
@@ -80,32 +80,32 @@ while (true) {
[$key, $val] = array_map('trim', explode(':', $row, 2));
switch ($key) {
case 'MODEL':
- $status[0] = $val;
+ $echo[0] = $val;
break;
case 'STATUS':
$text = strtr($val, $state);
- $status[1] = $val ? (strpos($val,'ONLINE')!==false ? "$text" : "$text") : ""._('Refreshing')."...";
+ $echo[1] = $val ? (strpos($val,'ONLINE')!==false ? "$text" : "$text") : ""._('Refreshing')."...";
break;
case 'BCHARGE':
$charge = round($val);
- $status[2] = $charge>$level ? "$charge %" : "$charge %";
+ $echo[2] = $charge>$level ? "$charge %" : "$charge %";
break;
case 'TIMELEFT':
$time = round($val);
$unit = _('minutes');
- $status[3] = $time>$runtime ? "$time $unit" : "$time $unit";
+ $echo[3] = $time>$runtime ? "$time $unit" : "$time $unit";
break;
case 'NOMPOWER':
$power = $val;
- $status[4] = $power>0 ? "$power W" : "$power W";
+ $echo[4] = $power>0 ? "$power W" : "$power W";
break;
case 'LOADPCT':
$load = $val;
- $status[5] = round($load)." %";
+ $echo[5] = round($load)." %";
break;
case 'OUTPUTV':
$output = round($val);
- $status[6] = "$output V";
+ $echo[6] = "$output V";
break;
case 'NOMINV':
$volt = $val;
@@ -117,11 +117,11 @@ while (true) {
break;
}
}
- if (isset($power) && isset($load)) $status[5] = ($load<90 ? "" : "").round($power*$load/100)." W (".$status[5].")";
- elseif (isset($load)) $status[5] = ($load<90 ? "" : "").$status[5]."";
- $status[6] = isset($output) ? ((!$volt || ($minv<$output && $output<$maxv) ? "" : "").$status[6].(isset($freq) ? " ~ $freq Hz" : "")."") : $status[6];
+ if (isset($power) && isset($load)) $echo[5] = ($load<90 ? "" : "").round($power*$load/100)." W (".$echo[5].")";
+ elseif (isset($load)) $echo[5] = ($load<90 ? "" : "").$echo[5]."";
+ $echo[6] = isset($output) ? ((empty($volt) || ($minv<$output && $output<$maxv) ? "" : "").$echo[6].(isset($freq) ? " ~ $freq Hz" : "")."") : $echo[6];
}
- $echo = implode(';', $status);
+ $echo = json_encode($echo);
$md5_new = md5($echo,true);
if ($md5_new !== $md5_old) {
publish('apcups', $echo);