Skip to content

Commit

Permalink
Merge branch 'develop' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
toggledbits committed Mar 4, 2019
2 parents 03c3ad5 + c1d19b7 commit 32033c0
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 40 deletions.
94 changes: 57 additions & 37 deletions J_ReactorSensor_UI7.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,15 @@ var ReactorSensor = (function(api, $) {
hh = parseInt( hh || "0" );
mm = parseInt( mm || "0" );
var tstr = ( hh < 10 ? '0' : '' ) + hh + ':' + ( mm < 10 ? '0' : '' ) + mm;
/* Possible forms are YMD, MD, D with time, or just time */
if ( isEmpty( m ) ) {
return tstr;
}
m = parseInt( m );
return monthName[m] + ' ' + d + ( isEmpty( y ) ? '' : ' ' + y ) + ' ' + tstr;
if ( isEmpty( d ) ) {
return tstr;
}
return tstr + " on day " + d + " of each month";
}
m = parseInt( m );
return monthName[m] + ' ' + d + ( isEmpty( y ) ? '' : ' ' + y ) + ' ' + tstr;
}

/**
Expand Down Expand Up @@ -1180,8 +1184,9 @@ var ReactorSensor = (function(api, $) {
break;

case 'trange':
/* Pre-sanity check */
if ( typ === "trange" && target !== undefined && target.hasClass('year') ) {
cond.operator = jQuery("div.params select.opmenu", row).val() || "bet";
var between = "bet" === cond.operator || "nob" == cond.operator;
if ( target !== undefined && target.hasClass('year') ) {
var pdiv = target.closest('div');
var newval = target.val().trim();
/* Vera's a 32-bit system, so date range is bound to MAXINT32 (2038-Jan-19 03:14:07 aka Y2K38) */
Expand All @@ -1201,42 +1206,59 @@ var ReactorSensor = (function(api, $) {
}
}
}
/* Fetch and load */
cond.operator = jQuery("div.params select.opmenu", row).val() || "bet";
res = [];
var mon = jQuery("div.start select.monthmenu", row).val();
if ( ! isEmpty( mon ) ) {
res.push( jQuery("div.start input.year", row).val() || "" );
res.push( jQuery("div.start select.monthmenu", row).val() || "" );
res.push( jQuery("div.start select.daymenu", row).val() || "1" );
var mon = jQuery("div.start select.monthmenu", row).val() || "";
if ( isEmpty( mon ) ) {
/* No/any month. Disable years. */
jQuery( '.datespec', row ).val( "" ).prop( 'disabled', true );
/* Ending month must also be blank */
jQuery( 'div.end select.monthmenu', row ).val( "" );
} else {
Array.prototype.push.apply( res, ["","",""] );
/* Month specified, year becomes optional, but either both
years must be specified or neither for between/not. */
jQuery( '.datespec', row ).prop( 'disabled', false );
jQuery( 'div.start select.daymenu:has(option[value=""]:selected)', row ).addClass( 'tberror' );
if ( between ) {
jQuery( 'div.end select.daymenu:has(option[value=""]:selected)', row ).addClass( 'tberror' );
var y1 = jQuery( 'div.start input.year', row ).val() || "";
var y2 = jQuery( 'div.end input.year', row ).val() || "";
if ( isEmpty( y1 ) !== isEmpty( y2 ) ) {
jQuery( '.datespec', row ).addClass( 'tberror' );
}
var m2 = jQuery( 'div.end select.monthmenu', row ).val() || "";
if ( isEmpty( m2 ) ) {
/* Ending month may not be blank--flag both start/end */
jQuery( 'select.monthmenu', row ).addClass( 'tberror' );
}
}
}
var dom = jQuery( 'div.start select.daymenu', row ).val() || "";
if ( isEmpty( dom ) ) {
/* Start day is blank. So must be end day */
jQuery( 'div.end select.daymenu', row ).val( "" );
} else if ( between ) {
/* Between with start day, end day must also be specified. */
jQuery( 'div.end select.daymenu:has(option[value=""]:selected)', row ).addClass( 'tberror' );
}

/* Fetch and load */
res = [];
res.push( isEmpty( mon ) ? "" : jQuery("div.start input.year", row).val() || "" );
res.push( mon );
res.push( jQuery("div.start select.daymenu", row).val() || "" );
res.push( jQuery("div.start select.hourmenu", row).val() || "0" );
res.push( jQuery("div.start select.minmenu", row).val() || "0" );
if ( cond.operator === "before" || cond.operator === "after" ) {
if ( ! between ) {
Array.prototype.push.apply( res, ["","","","",""] );
jQuery('div.end', row).hide();
} else {
jQuery('div.end', row).show();
if ( ! isEmpty( mon ) ) {
res.push( jQuery("div.end input.year", row).val() || "" );
res.push( jQuery("div.end select.monthmenu", row).val() || "" );
res.push( jQuery("div.end select.daymenu", row).val() || "1" );
} else {
Array.prototype.push.apply( res, ["","",""] );
}
res.push( isEmpty( mon ) ? "" : jQuery("div.end input.year", row).val() || "" );
res.push( isEmpty( mon ) ? "" : jQuery("div.end select.monthmenu", row).val() || "" );
res.push( jQuery("div.end select.daymenu", row).val() || "" );
res.push( jQuery("div.end select.hourmenu", row).val() || "0" );
res.push( jQuery("div.end select.minmenu", row).val() || "0" );
}
cond.value = res.join(',');
if ( typ === "trange" ) {
jQuery('.datespec', row).prop('disabled', res[1]==="");
if ( cond.operator !== "bet" && cond.operator !== "nob" ) {
jQuery('div.end', row).hide();
} else {
jQuery('div.end', row).show();
}
}
break;

case 'sun':
Expand Down Expand Up @@ -1886,11 +1908,11 @@ var ReactorSensor = (function(api, $) {
container.append( makeDateTimeOpMenu( cond.operator ) );
jQuery("select.opmenu", container).append('<option value="before">before</option>');
jQuery("select.opmenu", container).append('<option value="after">after</option>');
var months = jQuery('<select class="monthmenu form-control form-control-sm"><option value=""></option></select>');
var months = jQuery('<select class="monthmenu form-control form-control-sm"><option value="">(any month)</option></select>');
for ( k=1; k<=12; k++ ) {
months.append('<option value="' + k + '">' + monthName[k] + ' (' + k + ')</option>');
}
var days = jQuery('<select class="daymenu datespec form-control form-control-sm"></select>');
var days = jQuery('<select class="daymenu form-control form-control-sm"><option value="">(any day)</option></select>');
for ( k=1; k<=31; k++ ) {
days.append('<option value="' + k + '">' + k + '</option>');
}
Expand All @@ -1917,8 +1939,6 @@ var ReactorSensor = (function(api, $) {
.append('<input type="text" placeholder="yyyy" class="year narrow datespec form-control form-control-sm" autocomplete="off">')
.append( hours )
.append( mins );
jQuery("div.end select.monthmenu", container).addClass("datespec"); /* ability to disable */
jQuery('div.end select.monthmenu option[value=""]', container).remove();
/* Default all menus to first option */
jQuery("select", container).each( function( ix, obj ) {
jQuery(obj).val( jQuery("option:first", obj ).val() );
Expand All @@ -1945,8 +1965,8 @@ var ReactorSensor = (function(api, $) {
jQuery( flist[fx], container ).val( vlist[fx] );
}
}
/* Enable date fields if month spec present */
jQuery('.datespec', container).prop('disabled', vlist[1]==="");
/* Enable datespec fields if month spec present */
jQuery('.datespec', container).val( "" ).prop('disabled', vlist[1]==="");
jQuery("select", container).on( 'change.reactor', handleConditionRowChange );
jQuery("input", container).on( 'change.reactor', handleConditionRowChange );
break;
Expand Down
7 changes: 4 additions & 3 deletions L_Reactor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1950,7 +1950,7 @@ local function evaluateCondition( cond, grp, tdev )
if tpart[1] < 1970 then tpart[1] = 1970 elseif tpart[1] > 2037 then tpart[1] = 2037 end
if tpart[6] < 1970 then tpart[6] = 1970 elseif tpart[6] > 2037 then tpart[6] = 2037 end
D("evaluationCondition() clean tpart=%1", tpart)
if tparam[2] == "" then
if tparam[3] == "" then
-- No date specified, only time components. Magnitude comparison.
D("evaluateCondition() time-only comparison, now is %1, ndt is %2", now, ndt)
local nowMSM = ndt.hour * 60 + ndt.min
Expand Down Expand Up @@ -1981,8 +1981,9 @@ local function evaluateCondition( cond, grp, tdev )
end
end
elseif tparam[1] == "" then
-- No-year given, just M/D H:M. We can do comparison by magnitude,
-- No-year given, just [M/]D H:M. We can do comparison by magnitude,
-- which works better for year-spanning ranges.
-- N.B. month defaults to current month by setup of tpart.
local nowz = ndt.month * 100 + ndt.day
local stz = tpart[2] * 100 + tpart[3]
nowz = nowz * 1440 + ndt.hour * 60 + ndt.min
Expand Down Expand Up @@ -3615,7 +3616,7 @@ function request( lul_request, lul_parameters, lul_outputformat )
r = r .. "; " .. tostring((_G or {})._VERSION)
r = r .. EOL
r = r .. "Local time: " .. os.date("%Y-%m-%dT%H:%M:%S%z") .. ", DST=" .. tostring(luup.variable_get( MYSID, "LastDST", pluginDevice ) or "") .. EOL
r = r .. "House mode: tracking " .. ( usesHouseMode and "off" and "on" ) .. "; current mode " .. tostring(luup.variable_get( MYSID, "HouseMode", pluginDevice ) or "") .. EOL
r = r .. "House mode: tracking " .. ( usesHouseMode and "off" or "on" ) .. "; current mode " .. tostring(luup.variable_get( MYSID, "HouseMode", pluginDevice ) or "") .. EOL
r = r .. " Sun data: " .. tostring(luup.variable_get( MYSID, "sundata", pluginDevice ) or "") .. EOL
if geofenceMode ~= 0 then
local status, p = pcall( showGeofenceData )
Expand Down

0 comments on commit 32033c0

Please sign in to comment.