Skip to content

Commit a958903

Browse files
committed
- Implemented: Blockly, Option to compare sensor value against another sensor value
1 parent 848c7ba commit a958903

File tree

3 files changed

+43
-75
lines changed

3 files changed

+43
-75
lines changed

History.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Version 2.xxx (xxxx 2015)
6666
- Implemented: Logwindow, Added option to filter text
6767
- Implemented: Support for the Plugwise Anna Thermostat (NEM)
6868
- Implemented: Blockly, Split Utility Sensors into multiple groups
69+
- Implemented: Blockly, Option to compare sensor value against another sensor value
6970
- Changed: KMTronic LAN, now using actual On/Off commands instead of 'Toggle'
7071
- Changed: EventSystem, not adding sensors from disable hardware
7172
- Changed: json "udevice" Perecentage sensor, you might get new ID's, now also creates an event for blockly/lua

www/eventsframe.html

Lines changed: 41 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -115,98 +115,65 @@
115115
function parseXmlBlocks(xml,pairId) {
116116
var boolString = "";
117117

118-
function parseLogicCompare(thisBlock){
119-
var locOperand = opSymbol($($(thisBlock).children("title:first")).text());
120-
var valueA = $(thisBlock).children("value[name='A']")[0];
121-
var variableType = $(valueA).children("block:first").attr("type");
122-
118+
function GetValueText(value, variableType) {
123119
if (variableType.indexOf("switchvariables") >= 0) {
124-
var titleA = $(valueA).find("title")[0];
125-
var valueB = $(thisBlock).children("value[name='B']")[0];
126-
var titleB = $(valueB).find("title")[0];
127-
var compareString = "device["+$(titleA).text()+"]";
128-
if ($(titleB).attr("name") == "State") {
129-
compareString += locOperand;
130-
compareString += '"'+$(titleB).text()+'"';
131-
}
132-
return compareString;
120+
var titleA = $(value).find("title")[0];
121+
return "device["+$(titleA).text()+"]";
133122
}
134-
if (variableType.indexOf("uservariables") >= 0) {
135-
var compareString = "";
123+
else if (variableType.indexOf("uservariables") >= 0) {
136124
var titleA = $(valueA).find("title")[0];
137-
var valueB = $(thisBlock).children("value[name='B']")[0];
138-
var titleB = $(valueB).find("title")[0];
139-
if ($(titleB).attr("name") == "TEXT") {
140-
compareString = "variable["+$(titleA).text()+"]";
141-
compareString += locOperand;
142-
compareString += '"'+encodeURIComponent($(titleB).text())+'"';
143-
}
144-
else if ($(titleB).attr("name") == "NUM") {
145-
compareString = "variable["+$(titleA).text()+"]";
146-
compareString += locOperand;
147-
compareString += $(titleB).text();
148-
}
149-
return compareString;
125+
return "variable["+$(titleA).text()+"]";
150126
}
151127
else if (variableType == "temperaturevariables") {
152-
var titleA = $(valueA).find("title")[0];
153-
var valueB = $(thisBlock).children("value[name='B']")[0];
154-
var titleB = $(valueB).find("title")[0];
155-
var compareString = "temperaturedevice["+$(titleA).text()+"]";
156-
if ($(titleB).attr("name") == "NUM") {
157-
compareString += locOperand;
158-
compareString += $(titleB).text();
159-
}
160-
return compareString;
128+
var titleA = $(value).find("title")[0];
129+
return "temperaturedevice["+$(titleA).text()+"]";
161130
}
162131
else if (variableType == "humidityvariables") {
163-
var titleA = $(valueA).find("title")[0];
164-
var valueB = $(thisBlock).children("value[name='B']")[0];
165-
var titleB = $(valueB).find("title")[0];
166-
var compareString = "humiditydevice["+$(titleA).text()+"]";
167-
if ($(titleB).attr("name") == "NUM") {
168-
compareString += locOperand;
169-
compareString += +$(titleB).text();
170-
}
171-
return compareString;
132+
var titleA = $(value).find("title")[0];
133+
return "humiditydevice["+$(titleA).text()+"]";
172134
}
173135
else if (variableType == "dewpointvariables") {
174-
var titleA = $(valueA).find("title")[0];
175-
var valueB = $(thisBlock).children("value[name='B']")[0];
176-
var titleB = $(valueB).find("title")[0];
177-
var compareString = "dewpointdevice["+$(titleA).text()+"]";
178-
if ($(titleB).attr("name") == "NUM") {
179-
compareString += locOperand;
180-
compareString += $(titleB).text();
181-
}
182-
return compareString;
136+
var titleA = $(value).find("title")[0];
137+
return "dewpointdevice["+$(titleA).text()+"]";
183138
}
184139
else if (variableType == "barometervariables") {
185-
var titleA = $(valueA).find("title")[0];
186-
var valueB = $(thisBlock).children("value[name='B']")[0];
187-
var titleB = $(valueB).find("title")[0];
188-
var compareString = "barometerdevice["+$(titleA).text()+"]";
189-
if ($(titleB).attr("name") == "NUM") {
190-
compareString += locOperand;
191-
compareString += $(titleB).text();
192-
}
193-
return compareString;
140+
var titleA = $(value).find("title")[0];
141+
return "barometerdevice["+$(titleA).text()+"]";
194142
}
195143
else if (variableType.indexOf("utilityvariables") >= 0) {
196-
var titleA = $(valueA).find("title")[0];
197-
var valueB = $(thisBlock).children("value[name='B']")[0];
198-
var titleB = $(valueB).find("title")[0];
199-
var compareString = "utilitydevice["+$(titleA).text()+"]";
200-
if ($(titleB).attr("name") == "NUM") {
201-
compareString += locOperand;
202-
compareString += $(titleB).text();
203-
}
204-
return compareString;
144+
var titleA = $(value).find("title")[0];
145+
return "utilitydevice["+$(titleA).text()+"]";
205146
}
206147
else {
148+
var titleB = $(value).find("title")[0];
149+
if ($(titleB).attr("name") == "State") {
150+
return '"'+$(titleB).text()+'"';
151+
}
152+
else if ($(titleB).attr("name") == "TEXT") {
153+
return '"'+encodeURIComponent($(titleB).text())+'"';
154+
}
155+
else if ($(titleB).attr("name") == "NUM") {
156+
return $(titleB).text();
157+
}
207158
return "unknown comparevariable "+variableType;
208159
}
209160
}
161+
162+
function parseLogicCompare(thisBlock){
163+
var locOperand = opSymbol($($(thisBlock).children("title:first")).text());
164+
var valueA = $(thisBlock).children("value[name='A']")[0];
165+
var variableTypeA = $(valueA).children("block:first").attr("type");
166+
var valueB = $(thisBlock).children("value[name='B']")[0];
167+
var variableTypeB = $(valueB).children("block:first").attr("type");
168+
169+
var varTextA=GetValueText(valueA,variableTypeA);
170+
var varTextB=GetValueText(valueB,variableTypeB);
171+
172+
var compareString = varTextA;
173+
compareString += locOperand;
174+
compareString += varTextB;
175+
return compareString;
176+
}
210177

211178
function parseLogicTimeOfDay(thisBlock) {
212179
var compareString = "";

www/html5.appcache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# ref 1088
2+
# ref 1089
33

44
CACHE:
55
# CSS

0 commit comments

Comments
 (0)