Rev 2207 | Rev 2218 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 2207 | Rev 2211 | ||
|---|---|---|---|
| Line 241... | Line 241... | ||
| 241 | var aliases_data = Module_LookupAliases({ |
241 | var aliases_data = Module_LookupAliases({ |
| 242 | "module_name" : module_name, |
242 | "module_name" : module_name, |
| 243 | "module_id" : module_id, |
243 | "module_id" : module_id, |
| 244 | "group" : false }); |
244 | "group" : false }); |
| 245 | 245 | ||
| - | 246 | /* Must check sensor here in case no alias is stored the adress needs to be printed */ |
|
| 246 | var VikingSuccess = "NoVikingSensor"; |
247 | var VikingSuccess = "NoVikingSensor"; |
| 247 | loopAliases: /* Label to break nested */ |
- | |
| 248 | for (var alias_name in aliases_data) |
- | |
| 249 | { |
- | |
| 250 | if (aliases_data[alias_name]["specific"]["Channel"] == variables["Channel"] && |
- | |
| 251 | aliases_data[alias_name]["specific"]["Proto"] == variables["Protocol"]) |
- | |
| 252 | { |
- | |
| 253 |
|
248 | if (variables["Protocol"] == "Viking") |
| 254 | { |
249 | { |
| 255 | case "Viking": |
- | |
| 256 | { /* Add alias with these specifics: Channel=0,Proto=Viking,Address=<address of sensor> */ |
- | |
| 257 | VikingSuccess = "VikingNotFound"; |
- | |
| 258 | /* |
250 | /* |
| 259 | ??? aaaaaaaa sttttttttttt hhhhhhhh cccccccc |
251 | ??? aaaaaaaa sttttttttttt hhhhhhhh cccccccc |
| 260 | 341731651126 0b100 11111001 000011001011 00101110 00110110 20.3 46% |
252 | 341731651126 0b100 11111001 000011001011 00101110 00110110 20.3 46% |
| 261 | a = address, s = sign, t = temperature, h = humidity, c = crc |
253 | a = address, s = sign, t = temperature, h = humidity, c = crc |
| 262 | */ |
254 | */ |
| Line 266... | Line 258... | ||
| 266 | var temp = (data>>>16)&0xFFF; |
258 | var temp = (data>>>16)&0xFFF; |
| 267 | var addr = rshift(data,28)&0xFF; |
259 | var addr = rshift(data,28)&0xFF; |
| 268 | var unknown = rshift(data,36)&0xF; |
260 | var unknown = rshift(data,36)&0xF; |
| 269 | var calccrc=crc8(rshift(data,8), 32); |
261 | var calccrc=crc8(rshift(data,8), 32); |
| 270 | 262 | ||
| - | 263 | var sign = (temp>>>11)&1; |
|
| - | 264 | temp = temp&0x7FF; |
|
| - | 265 | if (sign > 0) |
|
| - | 266 | { |
|
| - | 267 | temp = -temp; |
|
| - | 268 | } |
|
| - | 269 | temp = temp/10; |
|
| - | 270 | ||
| - | 271 | VikingSuccess = "VikingNotFound"; |
|
| - | 272 | ||
| - | 273 | if (unknown != 4) |
|
| - | 274 | { |
|
| - | 275 | Log("\033[33mWarning: VikingSensor, unknown part="+unknown+", data="+data+"\033[0m"); |
|
| - | 276 | } |
|
| - | 277 | } |
|
| - | 278 | ||
| - | 279 | loopAliases: /* Label to break nested */ |
|
| - | 280 | for (var alias_name in aliases_data) |
|
| - | 281 | { |
|
| - | 282 | if (aliases_data[alias_name]["specific"]["Channel"] == variables["Channel"] && |
|
| - | 283 | aliases_data[alias_name]["specific"]["Proto"] == variables["Protocol"]) |
|
| - | 284 | { |
|
| - | 285 | switch (variables["Protocol"]) |
|
| - | 286 | { |
|
| - | 287 | case "Viking": |
|
| - | 288 | { /* Add alias with these specifics: Channel=0,Proto=Viking,Address=<address of sensor> */ |
|
| 271 | if (crc != calccrc) |
289 | if (crc != calccrc) |
| 272 | { |
290 | { |
| 273 | Log("\033[31mError: VikingSensor, incorrect CRC, data="+data+", CRC="+crc+", calcCRC="+calccrc+"\033[0m"); |
291 | Log("\033[31mError: VikingSensor, incorrect CRC, data="+data+", CRC="+crc+", calcCRC="+calccrc+"\033[0m"); |
| 274 | break loopAliases; |
292 | break loopAliases; |
| 275 | } |
293 | } |
| 276 | if (addr == aliases_data[alias_name]["specific"]["Address"]) |
294 | if (addr == aliases_data[alias_name]["specific"]["Address"]) |
| 277 | { |
295 | { |
| 278 | VikingSuccess = "VikingFound"; |
296 | VikingSuccess = "VikingFound"; |
| 279 | - | ||
| 280 | var sign = (temp>>>11)&1; |
- | |
| 281 | temp = temp&0x7FF; |
- | |
| 282 | if (sign > 0) |
- | |
| 283 | { |
- | |
| 284 | temp = -temp; |
- | |
| 285 | } |
- | |
| 286 | temp = temp/10; |
- | |
| 287 | - | ||
| 288 | if (unknown != 4) |
- | |
| 289 | { |
- | |
| 290 | Log("\033[33mWarning: VikingSensor, unknown part="+unknown+", data="+data+"\033[0m"); |
- | |
| 291 | } |
- | |
| 292 | 297 | ||
| 293 | var last_value = {}; |
298 | var last_value = {}; |
| 294 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
299 | var last_value_string = Storage_GetParameter("LastValues", alias_name); |
| 295 | 300 | ||
| 296 | if (last_value_string) |
301 | if (last_value_string) |
| Line 307... | Line 312... | ||
| 307 | break loopAliases; |
312 | break loopAliases; |
| 308 | } |
313 | } |
| 309 | break; |
314 | break; |
| 310 | } |
315 | } |
| 311 | case "Nexa2": |
316 | case "Nexa2": |
| 312 | { /* Add alias with these specifics: |
317 | { /* Add alias with these specifics: Channel=0,Proto=Nexa2,OnData=<data for on>,OffData=<data for off> */ |
| 313 | var deviceStateCommand = ""; |
318 | var deviceStateCommand = ""; |
| 314 | if (variables["IRdata"] == aliases_data[alias_name]["specific"]["OnData"] && variables["Status"] == "Pressed") |
319 | if (variables["IRdata"] == aliases_data[alias_name]["specific"]["OnData"] && variables["Status"] == "Pressed") |
| 315 | { |
320 | { |
| 316 | deviceStateCommand = "On"; |
321 | deviceStateCommand = "On"; |
| 317 | } |
322 | } |