Detection of irregular (high) consumer on a common line

Precondition:
Some kind of SmartMeter (in my case a 3Phase Rail Mounted Device up to 65A)
More than one consumer at that rail (otherwise detection against zero-Level is trivial)

Analysing History:
(In my case a wasching machine)


As can be seen we have peak at beginning, where the heating starts.
Depending on the load and water temperature the initial presented time never stays over the process (±30min) and sometimes even fail, when my wife or tenant put in to much cleaner.
Even measuring the level much before first peak and comparing during runtime might not be best, cause switching any light will distort.

Given Rule:

var waschingMaschine, maxWatt, deviationW, ttsFertig;

var dtf = Java.type("java.time.format.DateTimeFormatter");

var zdt = Java.type("java.time.ZonedDateTime");

function getZonedDateTime (datetime) {
  return zdt.parse(datetime + ' 00:00:00 +00:00', dtf.ofPattern('yyyy-MM-dd HH:mm:ss z'))
}

var persistence = Java.type('org.openhab.core.persistence.extensions.PersistenceExtensions');

if (typeof this.storedValues === 'undefined') {
  this.storedValues = [];
}

var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID);


waschingMaschine = 'ZWaveNode017ZMNHXDQubino3PhaseSmartMeter_Electricmeterwatts3';
maxWatt = (persistence.maximumSince(itemRegistry.getItem(waschingMaschine), zdt.now().minusHours(4)).getState());
deviationW = (persistence.deviationSince(itemRegistry.getItem(waschingMaschine), zdt.now().minusMinutes(10)));
if (!(this.storedValues['done']) && maxWatt > 1500 && deviationW < 30) {
  ttsFertig = 'Die Waschmaschine ist fertig!';
  events.sendCommand('DavidsEchoFlex', ttsFertig);
  this.storedValues['done'] = true;
}
if (maxWatt < 100) {
  this.storedValues['done'] = false;
}
logger.info(maxWatt);
logger.info(deviationW);

Explanation:
So the idea is to detect the consumer with its peak and send any alert when is comes steady.
This rule will be triggered every 5min from 6 AM to 12 PM.
The optional boolen is to prevent alerting all the time and will be resettet in a meaningful period (or optional with an adintional trigger, if I start a wasching-marathon without chance for reset.

I tested the Rule sucessfully over 3 weeks and will paste snipped of “deviation” and “variance” :wink:

1 Like

Sources

double total = 0;
int quantity = 0;
DecimalType histValue = null;
while(it.hasNext()) {
	State state = it.next().getState();
	if (state instanceof DecimalType) {
		histValue = (DecimalType) state;
		total += Math.pow(histValue.doubleValue()- average.doubleValue(), 2);
		quantity++;
	}
}
...
double variance = total / quantity;
deviation = Math.sqrt(variance.doubleValue());

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.