This page last changed on Oct 10, 2012 by hjs.

I'm working through a proof-of-concept integration with my system. I'm using Telnet commands and regexes to parse out the states of each device (Incidentally, 00 is "off" and 64 is "on"). I'm happily getting to the point where the 64 or 00 is parsed out, but then I hit a snag. I've set up a "custom" sensor, with mappings of "off" -> 00 and "on" -> 64 but it seems that when this is read in, the mapping ends up looking like state-1 -> 00 and state-2 -> 64. In stepping through the code, I see that the 00 (or 64) is found, but when it's looked up in the state mapping, it loses the resolution to "on" and "off" and remains "state-x".

Am I misunderstanding the intent of the custom sensor? I'll have more time to poke at this later this evening, but wanted to know if there was something obvious that I wasn't doing.

Thanks in advance

-h

I finally got around to looking into this more, and it seems that the mappings weren't even being loaded in at all.

The following patch fixes my issue, but since I'm not familiar enough with the code base, I've got no idea what else this may break.

Index: src/org/openremote/controller/model/sensor/StateSensor.java
===================================================================
--- src/org/openremote/controller/model/sensor/StateSensor.java	(revision 6950)
+++ src/org/openremote/controller/model/sensor/StateSensor.java	(working copy)
@@ -87,7 +87,12 @@
 
     for (String state : states.getAllStates())
     {
-      props.put("state-" + index++, state);
+      String mappingValue = states.getMapping(state);
+      if(mappingValue != null) {
+        props.put(mappingValue, state);
+      } else {
+        props.put("state-" + index++, state);
+      }
     }
 
     return props;
Posted by hjs at Oct 24, 2012 16:08
Document generated by Confluence on Jun 05, 2016 09:30