Dear all,
I've stuck. Please help me to understand.
Currently I have a serial gateway and openHAB 1.7. I've managed to get controller working and send commands to openhab installed on Windows.
Now I need to understand how to convert commands from the gateway.
I have a rule
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 == 3 ){
if (subType == 9){
sendCommand(Arduino_Motion1, ON)
pushover("Motion Detected", -1)
} } }
end
items:
String Arduino "Serial" {serial="COM4@115200"}
Switch Arduino_Motion1 "Motion" <siren>
and a sitemap
sitemap home label="Home"
{
Frame label="Serial" {
Switch item=Arduino_Motion1 label="Motion Sensor"
} }
So in debug I have following:
2015-06-01 12:51:29.154 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 1-1-0 s=1,c=1,t=16,pt=0,l=1:1
1;1;1;0;16;1
2015-06-01 12:51:29.156 [INFO ] [runtime.busevents ] - Arduino_Motion1 received command ON
So I've found an example of temp sensor but not the motion...
Pushover sends me notifications when motion sensor send 0 to the gateway every minute or so. (0;0;3;0;9;read: 1-1-0 s=1,c=1,t=16,pt=0,l=1:0). I don't understand how can I separate last 0 from 1.
I know I'm on a last step, please help
Thank you!