I'm trying to create an In-Memory numeric value to represent the heating demand within a property.
Is it possible to use rules to either...
Count a regex selection of active sensors and push that number into an In-Memory command.
Or...
Can the numeric values of a regex selection be added together and the total be pushed into an In-Memory commamd?
The resulting value will provide management feedback for heating demand, then they'll decide if or when multiple boilers should be activated via some kind of rule.
Look on this rule, which is from the Smappee integration:
rule "--Smappee: active power"
when
exists SmappeeApplianceCopy()
Number($power: doubleValue) from accumulate(SmappeeApplianceCopy($p: power>0), sum($p))
Number($count: intValue) from accumulate($i:SmappeeApplianceCopy(power>0), count($i))
then
execute.command("VACTIVEPOWER", $power+" W ("+$count+")");
end
``
This rule counts all appliances detected by Smappee which are active at the moment and stores a string in the virtual in-memory variable VACTIVEPOWER. The string looks like “1100 W (3)”, where 1100 is a sum of all appliances power and 3 is number of active appliances.
rule"heatcall_count"
when
Number($count: intValue) from accumulate($i:Event(source matches “^.*-heatcall$”, value==“pressed”), count($i))
then
execute.command(“heatdemend”,$count);
end