I tried asking this on the OpenHAB forums, but I haven't received any feedback. I'm having problems properly sending the I_CONFIG value to my sensors.
Below is my "Arduino sends to Openhab" rule that I've added the I_CONFIG variable to:
rule "Arduino sends to Openhab"
when
Item Arduino received update
then
var String lineBuffer = Arduino.state.toString.split("\n")
for (String line : lineBuffer) {
var String[] message = line.split(";")
var Integer nodeId = new Integer(message.get(0))
var Integer childId = new Integer(message.get(1))
var Integer msgType = new Integer(message.get(2))
var Integer ack = new Integer(message.get(3))
var Integer subType = new Integer(message.get(4))
var String msg = message.get(5)
if(msgType == 1 ){
if (subType == V_TEMP){
postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
println ("Temp item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " temp: " + msg )
}
if (subType == V_HUM){
postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
println ("Hum item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " hum: " + msg )
}
}
if(msgType == 3){
if(subType == I_BATTERY_LEVEL){
postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
println ("Battery level received: " + msg)
}
if(subType == I_CONFIG){
println("Request config units")
sendCommand(Arduino, nodeId + ";" + childId + ";" + msgType + ";" + ack + ";" + subType + ";" + core_Units.state + "\n")
println("Sent measurement units:" + core_Units.state )
}
if(subType == I_SKETCH_NAME){
println("Sketch name: " + msg )
sketchName=msg
}
if(subType == I_SKETCH_VERSION){
println("Sketch version: " + msg )
postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), sketchName+" " +msg )
sketchName=""
}
}
}
end
In it's current state, the sensor node gets repeated responses from the controller/gateway with the units (I or M), based on the value of the item Core_Units.state. I'm trying to figure out why this doesn't just sendCommand one time to the sensor node. The response received by the sensor node seems correct, I just get hundreds of them. Below is the output from my sensor node after requesting the I_CONFIG value from the controller:
read: 0-0-105 s=255,c=3,t=6,pt=0,l=1,sg=0:I
This appears correct to me. Any thoughts?