Skip to content
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Controllers
  3. OpenHAB
  4. Serial Gateway connection to Openhab
  • Getting Started
  • Controller
  • Build
  • Hardware
  • Download/API
  • Forum
  • Store

Serial Gateway connection to Openhab

Scheduled Pinned Locked Moved OpenHAB
development ope
86 Posts 16 Posters 81.1k Views 10 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jan Gatzke
    wrote on last edited by
    #22

    Why are you using a usb to serial adapter to connect the arduino to the raspberry? The raspberry hat an onboard uart at /dev/ttyAMA0. I am using the internal uart and cannot reproduce this kind of error.

    1 Reply Last reply
    0
    • J Offline
      J Offline
      Jan Gatzke
      wrote on last edited by
      #23

      Why are you using a usb to serial adapter to connect the arduino to the raspberry? The raspberry has an onboard uart at /dev/ttyAMA0. I am using the internal uart and cannot reproduce this kind of error.

      C 1 Reply Last reply
      3
      • J Jan Gatzke

        Why are you using a usb to serial adapter to connect the arduino to the raspberry? The raspberry has an onboard uart at /dev/ttyAMA0. I am using the internal uart and cannot reproduce this kind of error.

        C Offline
        C Offline
        C.r.a.z.y.
        wrote on last edited by C.r.a.z.y.
        #24

        @Jan-Gatzke said:

        ttyAMA0
        :+1:

        What version openhab runtime and add ons do you use?
        How many nodes do you have and how long time they are working fine without restart rpi?
        Please can you upload your config files?

        1.6.2 or 1.7.0 didn't switch on-off my relays but logs seems ok:

        I connected nano pins VIN+GND+TX+RX to RPI 5V+GND+TX+RX , (TX->TX , RX->RX)

        osgi> 2015-03-07 15:49:24.409 [INFO ] [.o.core.internal.CoreActivator] - openHAB runtime has been started (v1.7.0).
        2015-03-07 15:49:50.387 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - mDNS service has been started
        2015-03-07 15:49:51.200 [INFO ] [o.o.i.s.i.DiscoveryServiceImpl] - Service Discovery initialization completed.
        2015-03-07 15:50:01.540 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'default.items'
        2015-03-07 15:50:15.506 [WARN ] [cpr.DefaultAnnotationProcessor] - Unable to detect annotations. Application may fail to deploy.
        2015-03-07 15:50:17.567 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'default.sitemap'
        2015-03-07 15:50:32.786 [INFO ] [penhab.io.rest.RESTApplication] - Started REST API at /rest
        2015-03-07 15:50:38.947 [INFO ] [.o.u.w.i.servlet.WebAppServlet] - Started Classic UI at /openhab.app
        2015-03-07 15:50:51.918 [INFO ] [c.internal.ModelRepositoryImpl] - Loading model 'default.rules'
        RXTX Warning: Removing stale lock file. /var/lock/LCK..ttyAMA0
        2015-03-07 15:51:01.398 [INFO ] [.service.AbstractActiveService] - NTP Refresh Service has been started

        2015-03-07 15:51:57.516 [INFO ] [runtime.busevents ] - S2 received command ON
        2015-03-07 15:52:08.006 [INFO ] [runtime.busevents ] - S2 received command OFF
        2015-03-07 15:52:11.408 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;0

        2015-03-07 15:52:11.722 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;1

        2015-03-07 15:52:19.544 [INFO ] [runtime.busevents ] - S1 received command ON
        2015-03-07 15:52:21.200 [INFO ] [runtime.busevents ] - Arduino received command 51;1;1;0;2;0

        2015-03-07 15:52:22.143 [INFO ] [runtime.busevents ] - S2 received command ON
        2015-03-07 15:52:22.259 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;0

        2015-03-07 15:52:23.131 [INFO ] [runtime.busevents ] - AP3 received command ON
        2015-03-07 15:52:24.142 [INFO ] [runtime.busevents ] - Arduino received command 100;3;1;0;0;1

        1 Reply Last reply
        0
        • T Offline
          T Offline
          TimO
          Hero Member
          wrote on last edited by
          #25

          I've upgraded to the nightly of OpenHab 1.7.0 to see if I'm able to reproduce your problem.
          My modified OpenHab 1.6.2 did ran for a few weeks without problems. I'm using an Arduino Nano connected to an old laptop, so no RPi and the FTDI from the Nano.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            C.r.a.z.y.
            wrote on last edited by
            #26

            @TimO please can you share Openhab files?
            +My relay powered from nano icp headers maybe this makes trouble for wifi , i will change this and give update.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              C.r.a.z.y.
              wrote on last edited by C.r.a.z.y.
              #27

              @TimO

              I installed this https://github.com/lurch/rpi-serial-console
              pi@raspberrypi ~ $ rpi-serial-console status
              Serial console on /dev/ttyAMA0 is disabled

              Now my nodes are working perfect when i use manual button or ui but my logs are not correct

              My config:

              add on : org.openhab.binding.serial_1.6.0.201411271703.jar
              String Arduino "Arduino" { serial="/dev/ttyUSB0" }

              As you see there are "fails" but nodes are working.

              015-03-09 12:37:51.725 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

              2015-03-09 12:37:56.726 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 52-52-0 s=255,c=0,t=18,pt=0,l=5:1.4.1
              52;255;0;0;18;1.4.1
              0;0;3;0;9;read: 52-52-0 s=255,c=3,t=6,pt=1,l=1:0
              52;255;3;0;6;0

              2015-03-09 12:37:58.768 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 52-52-0 s=255,c=3,t=11,pt=0,l=14:Relay & Button
              52;255;3;0;11;Relay & Button
              0;0;3;0;9;read: 52-52-0 s=255,c=3,t=12,pt=0,l=3:1.0
              52;255;3;0;12;1.0
              0;0;3;0;9;read: 52-52-0 s=1,c=0,t=3,pt=0,l=5:1.4.1
              52;1;0;0;3;1.4.1
              0;0;3;0;9;read: 52-52-0 s=2,c=0,t=3,pt=0,l=5:1.4.1
              52;2;0;0;3;1.4.1

              2015-03-09 12:37:59.700 [INFO ] [runtime.busevents ] - S2 received command ON
              2015-03-09 12:37:59.822 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;0

              2015-03-09 12:38:00.106 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:0

              2015-03-09 12:38:00.546 [INFO ] [runtime.busevents ] - S2 received command OFF
              2015-03-09 12:38:00.661 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;1

              2015-03-09 12:38:00.967 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

              2015-03-09 12:38:01.161 [INFO ] [runtime.busevents ] - S2 received command ON
              2015-03-09 12:38:01.339 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;0

              2015-03-09 12:38:01.649 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:0

              2015-03-09 12:38:01.782 [INFO ] [runtime.busevents ] - S2 received command OFF
              2015-03-09 12:38:01.894 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;1

              2015-03-09 12:38:02.076 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

              T 1 Reply Last reply
              0
              • C C.r.a.z.y.

                @TimO

                I installed this https://github.com/lurch/rpi-serial-console
                pi@raspberrypi ~ $ rpi-serial-console status
                Serial console on /dev/ttyAMA0 is disabled

                Now my nodes are working perfect when i use manual button or ui but my logs are not correct

                My config:

                add on : org.openhab.binding.serial_1.6.0.201411271703.jar
                String Arduino "Arduino" { serial="/dev/ttyUSB0" }

                As you see there are "fails" but nodes are working.

                015-03-09 12:37:51.725 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

                2015-03-09 12:37:56.726 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 52-52-0 s=255,c=0,t=18,pt=0,l=5:1.4.1
                52;255;0;0;18;1.4.1
                0;0;3;0;9;read: 52-52-0 s=255,c=3,t=6,pt=1,l=1:0
                52;255;3;0;6;0

                2015-03-09 12:37:58.768 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;read: 52-52-0 s=255,c=3,t=11,pt=0,l=14:Relay & Button
                52;255;3;0;11;Relay & Button
                0;0;3;0;9;read: 52-52-0 s=255,c=3,t=12,pt=0,l=3:1.0
                52;255;3;0;12;1.0
                0;0;3;0;9;read: 52-52-0 s=1,c=0,t=3,pt=0,l=5:1.4.1
                52;1;0;0;3;1.4.1
                0;0;3;0;9;read: 52-52-0 s=2,c=0,t=3,pt=0,l=5:1.4.1
                52;2;0;0;3;1.4.1

                2015-03-09 12:37:59.700 [INFO ] [runtime.busevents ] - S2 received command ON
                2015-03-09 12:37:59.822 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;0

                2015-03-09 12:38:00.106 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:0

                2015-03-09 12:38:00.546 [INFO ] [runtime.busevents ] - S2 received command OFF
                2015-03-09 12:38:00.661 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;1

                2015-03-09 12:38:00.967 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

                2015-03-09 12:38:01.161 [INFO ] [runtime.busevents ] - S2 received command ON
                2015-03-09 12:38:01.339 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;0

                2015-03-09 12:38:01.649 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:0

                2015-03-09 12:38:01.782 [INFO ] [runtime.busevents ] - S2 received command OFF
                2015-03-09 12:38:01.894 [INFO ] [runtime.busevents ] - Arduino received command 52;1;1;0;2;1

                2015-03-09 12:38:02.076 [INFO ] [runtime.busevents ] - Arduino state updated to 0;0;3;0;9;send: 0-0-52-52 s=1,c=1,t=2,pt=0,l=1,st=fail:1

                T Offline
                T Offline
                TimO
                Hero Member
                wrote on last edited by
                #28

                @C.r.a.z.y. : I don't think this problem is related to OpenHab.

                In my case the output looks like this:

                2015-03-09 11:50:45.780 [INFO ] [runtime.busevents             ] - Light_Corridor_First_Floor received command ON
                2015-03-09 11:50:45.782 [INFO ] [runtime.busevents             ] - Arduino received command 102;2;1;0;2;1
                
                ArduinoUpdate -> 102;2;1;0;2;1
                2015-03-09 11:50:45.990 [INFO ] [runtime.busevents             ] - Arduino state updated to 0;0;3;0;9;send: 0-0-102-102 s=2,c=1,t=2,pt=0,l=1,st=ok:1
                
                ArduinoUpdate -> 0;0;3;0;9;send: 0-0-102-102 s=2,c=1,t=2,pt=0,l=1,st=ok:1
                

                OpenHab does not interpret the response (fail/ok). It is something I need to work on.

                C 1 Reply Last reply
                0
                • T TimO

                  @C.r.a.z.y. : I don't think this problem is related to OpenHab.

                  In my case the output looks like this:

                  2015-03-09 11:50:45.780 [INFO ] [runtime.busevents             ] - Light_Corridor_First_Floor received command ON
                  2015-03-09 11:50:45.782 [INFO ] [runtime.busevents             ] - Arduino received command 102;2;1;0;2;1
                  
                  ArduinoUpdate -> 102;2;1;0;2;1
                  2015-03-09 11:50:45.990 [INFO ] [runtime.busevents             ] - Arduino state updated to 0;0;3;0;9;send: 0-0-102-102 s=2,c=1,t=2,pt=0,l=1,st=ok:1
                  
                  ArduinoUpdate -> 0;0;3;0;9;send: 0-0-102-102 s=2,c=1,t=2,pt=0,l=1,st=ok:1
                  

                  OpenHab does not interpret the response (fail/ok). It is something I need to work on.

                  C Offline
                  C Offline
                  C.r.a.z.y.
                  wrote on last edited by
                  #29

                  @TimO I think so maybe rpi usb problem...

                  Is there a newer file for org.openhab.binding.serial_1.6.0.201411271703

                  T 1 Reply Last reply
                  0
                  • C C.r.a.z.y.

                    @TimO I think so maybe rpi usb problem...

                    Is there a newer file for org.openhab.binding.serial_1.6.0.201411271703

                    T Offline
                    T Offline
                    TimO
                    Hero Member
                    wrote on last edited by
                    #30

                    @C.r.a.z.y.: Yes, I'm using the current NIGHTLY from cloudbees: https://openhab.ci.cloudbees.com/job/openHAB/

                    You need to change:

                    String Arduino "Arduino" { serial="/dev/ttyUSB0" }
                    

                    To:

                    String Arduino "Arduino" { serial="/dev/ttyUSB0@115200" }
                    

                    The communication between the Gateway and the Controller/OpenHab seems to work fine, but the answer from the Gateway is the wrong one. So changing the binding won't solve this problem.

                    What is the serial output of the receiving node?

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      C.r.a.z.y.
                      wrote on last edited by
                      #31

                      @tim @hek
                      Hek adviced me to download current 1.4 v in a topic and i did. I was using 1.4 which downloaded 2 months ago.
                      After that;
                      My old node's sketch(or api) was not the same with my new serial controller sketch 1.4
                      I reupload sketches to every node and gateway still I am not sure with this solution but today my nodes worked fine.

                      1 Reply Last reply
                      0
                      • L Offline
                        L Offline
                        l154
                        wrote on last edited by
                        #32

                        Hi all,
                        I wrote some rules for serial gateway to openhab, temp, hum, switch, dimmer and some internal commands are working without a problem. I don't have too much time to develop this for other devices.
                        I'm not a java programmer so if I made some mistakes feel free to comment.
                        The goal is to write a rules that will be easily expanded to other devices.
                        I create a has map table where I define mappings ID to item name and inversely.
                        test.rules file:

                        import org.openhab.core.library.types.*
                        import org.openhab.core.persistence.*
                        import org.openhab.model.script.actions.*
                        import java.util.*
                        import org.eclipse.xtext.xbase.lib.*
                        import org.openhab.core.items.*
                        
                        var String ArduinoUpdate = ""
                        var String sketchName = ""
                        var int V_TEMP = 0
                        var int V_HUM = 1
                        var int V_LIGHT = 2
                        var int V_DIMMER = 3
                        var int V_PRESSURE = 4
                        var int V_FORECAST = 5
                        var int V_RAIN = 6
                        var int V_RAINRATE = 7
                        var int V_WIND = 8
                        var int V_GUST = 9
                        var int V_DIRECTION = 10
                        var int V_UV = 11
                        var int V_WEIGHT = 12
                        var int V_DISTANCE = 13
                        var int V_IMPEDANCE = 14
                        var int V_ARMED = 15
                        var int V_TRIPPED = 16
                        var int V_WATT = 17
                        var int V_KWH = 18
                        var int V_SCENE_ON = 19
                        var int V_SCENE_OFF = 20
                        var int V_HEATER = 21
                        var int V_HEATER_SW = 22
                        var int V_LIGHT_LEVEL = 23
                        var int V_VAR1 = 24
                        var int V_VAR2 = 25
                        var int V_VAR3 = 26
                        var int V_VAR4 = 27
                        var int V_VAR5 = 28
                        var int V_UP = 29
                        var int V_DOWN = 30
                        var int V_STOP = 31
                        var int V_IR_SEND = 32
                        var int V_IR_RECEIVE = 33
                        var int V_FLOW = 34
                        var int V_VOLUME = 35
                        var int V_LOCK_STATUS = 36
                        var int V_DUST_LEVEL = 37
                        var int V_VOLTAGE = 38
                        var int V_CURRENT = 39
                        var int msgPresentation = 0
                        var int msgSet = 1
                        var int msgReq = 2
                        var int msgInternal = 3
                        var int msgStream = 4
                        var int alarmArmor = 1
                        // Internal Commands
                        
                        var int I_BATTERY_LEVEL = 0
                        var int I_TIME = 1
                        var int I_VERSION = 2
                        var int I_ID_REQUEST = 3
                        var int I_ID_RESPONSE = 4
                        var int I_INCLUSION_MODE = 5
                        var int I_CONFIG = 6
                        var int I_FIND_PARENT = 7
                        var int I_FIND_PARENT_RESPONSE = 8
                        var int I_LOG_MESSAGE = 9
                        var int I_CHILDREN = 10
                        var int I_SKETCH_NAME = 11
                        var int I_SKETCH_VERSION = 12
                        var int I_REBOOT = 13
                        var int I_GATEWAY_READY = 14
                        // Mappings
                        var HashMap<String, String> sensorToItemsMap = newLinkedHashMap(
                        	"21;1;" -> "tempSalon01", 
                        	"tempSalon01" -> "21;1;",
                        	"21;0;" -> "humSalon01", 
                        	"humSalon01" -> "21;0;",
                        	"22;0;" -> "plugStrip01s12", 
                        	"plugStrip01s12" -> "22;0;",
                        	"22;1;" -> "plugStrip01s34", 
                        	"plugStrip01s34" -> "22;1;",
                        	"20;0;" -> "lightSalonCeiling00", 
                        	"lightSalonCeiling00" -> "20;0;",
                        	"20;1;" -> "lightSalonCeiling01", 
                        	"lightSalonCeiling01" -> "20;1;",
                        	"20;2;" -> "lightSalonCeiling02", 
                        	"lightSalonCeiling02" -> "20;2;",
                        	"20;3;" -> "lightSalonCeiling03", 
                        	"lightSalonCeiling03" -> "20;3;",
                        	"20;4;" -> "lightSalonCeiling04", 
                        	"lightSalonCeiling04" -> "20;4;",
                        	"10;4;" -> "lightBar04", 
                        	"lightBar04" -> "10;4;",
                        	"10;0;" -> "lightKitchenCabinet00", 
                        	"lightKitchenCabinet00" -> "10;0;",
                        	"10;1;" -> "lightKitchenCabinet01", 
                        	"lightKitchenCabinet01" -> "10;1;",
                        	"10;2;" -> "lightKitchenCabinet02", 
                        	"lightKitchenCabinet02" -> "10;2;",
                        	"10;3;" -> "lightKitchenCabinet03", 
                        	"lightKitchenCabinet03" -> "10;3;",
                        	"20;255;" -> "sensorLRCDimmer", 
                        	"21;255;" -> "sensorLRHumTemp", 
                        	"22;255;" -> "sensorLRStripPlug01", 
                        	"10;255;" -> "sensorKCLight"
                        
                        )
                        // dimmer function
                        val org.eclipse.xtext.xbase.lib.Functions$Function5 dimmerOperation = [
                        	org.openhab.core.library.items.DimmerItem relayItem, 
                        	org.openhab.core.library.items.StringItem arduinoItem, 
                        	String arduinoDevMap,
                        	String receivedCommand,
                        	Integer subType|
                        	var Number percent = 0
                        	if(relayItem.state instanceof DecimalType) percent = relayItem.state as DecimalType
                        	if(receivedCommand==INCREASE) percent = percent + 5
                        	if(receivedCommand==DECREASE) percent = percent - 5
                        	if(receivedCommand==ON) percent = 100       
                        	if(receivedCommand==OFF) percent = 0        
                        	if(percent<0)   percent = 0
                        	if(percent>100) percent = 100
                        	
                        	println ("Function: dimmerOperation >> "+arduinoDevMap + "1;1;" + subType + ";" + percent )
                        	arduinoItem.sendCommand(arduinoDevMap + "1;0;" + subType + ";" + percent + "\n")
                        ]
                        //switch function
                        val org.eclipse.xtext.xbase.lib.Functions$Function4 switchOperation = [
                        	org.openhab.core.library.items.SwitchItem relayItem, 
                        	org.openhab.core.library.items.StringItem arduinoItem, 
                        	String arduinoDevMap,
                        	Integer subType|
                        	var Integer state = 0
                                if (relayItem.state == OFF) {
                        		state = 0 
                        	}
                        	else {
                        		state = 1
                        	}
                        	println ("Function: switchOperation >> "+arduinoDevMap + "1;1;" + subType + ";" + state )
                        	arduinoItem.sendCommand(arduinoDevMap + "1;0;" + subType + ";" + state + "\n")
                        ]
                        
                        //receiving msg from mysensors gateway
                        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 (subType == V_DIMMER){
                        					postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), msg)
                        					println ("Dimmer item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " Dimmer: " + msg )
                        						}
                        				if (subType == V_LIGHT){
                        					var String state
                        					var Integer statusInt = new Integer(message.get(5))
                        					if(statusInt == 1) { 
                        						state = "ON"
                        						} 
                        					else { 
                        						state = "OFF" 
                        						}
                        					postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), state)
                        					println ("Light Item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " Light: " + state )
                        					}
                        				}
                        			// Internal Command
                        			if(msgType == 3){
                        				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
                        
                        
                        
                        rule "lightBar04 Switch Rule"
                        	when
                        		Item lightBar04 changed
                        	then
                        		switchOperation.apply(lightBar04, Arduino, sensorToItemsMap.get("lightBar04"), V_LIGHT)			
                        end	
                        
                        rule "lightKitchenCabinet00 Switch Rule"
                        	when
                        		Item lightKitchenCabinet00 changed
                        	then
                        		switchOperation.apply(lightKitchenCabinet00, Arduino, sensorToItemsMap.get("lightKitchenCabinet00"), V_LIGHT)			
                        end	
                        
                        rule "lightKitchenCabinet01 Switch Rule"
                        	when
                        		Item lightKitchenCabinet01 changed
                        	then
                        		switchOperation.apply(lightKitchenCabinet01, Arduino, sensorToItemsMap.get("lightKitchenCabinet01"), V_LIGHT)			
                        end	
                        
                        rule "lightKitchenCabinet02 Switch Rule"
                        	when
                        		Item lightKitchenCabinet02 changed
                        	then
                        		switchOperation.apply(lightKitchenCabinet02, Arduino, sensorToItemsMap.get("lightKitchenCabinet02"), V_LIGHT)			
                        end	
                        
                        rule "lightKitchenCabinet03 Switch Rule"
                        	when
                        		Item lightKitchenCabinet03 changed
                        	then
                        		switchOperation.apply(lightKitchenCabinet03, Arduino, sensorToItemsMap.get("lightKitchenCabinet03"), V_LIGHT)			
                        end	
                        
                        rule "lightSalonCeiling00 Switch Rule"
                        	when
                        		Item lightSalonCeiling00 received command
                        	then
                        		if(lightSalonCeiling00.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                        		dimmerOperation.apply(lightSalonCeiling00, Arduino, sensorToItemsMap.get("lightSalonCeiling00"), receivedCommand, V_DIMMER)			
                        		} 
                        	end	
                        rule "lightSalonCeiling01 Switch Rule"
                        	when
                        		Item lightSalonCeiling01 received command
                        	then
                        		if(lightSalonCeiling01.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                        		dimmerOperation.apply(lightSalonCeiling01, Arduino, sensorToItemsMap.get("lightSalonCeiling01"), receivedCommand, V_DIMMER)			
                        		} 
                        	end	
                        rule "lightSalonCeiling02 Switch Rule"
                        	when
                        		Item lightSalonCeiling02 received command
                        	then
                        		if(lightSalonCeiling02.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                        		dimmerOperation.apply(lightSalonCeiling02, Arduino, sensorToItemsMap.get("lightSalonCeiling02"), receivedCommand, V_DIMMER)			
                        		} 
                        	end	
                        rule "lightSalonCeiling03 Switch Rule"
                        	when
                        		Item lightSalonCeiling03 received command
                        	then
                        		if(lightSalonCeiling03.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                        		dimmerOperation.apply(lightSalonCeiling03, Arduino, sensorToItemsMap.get("lightSalonCeiling03"), receivedCommand, V_DIMMER)			
                        		} 
                        	end	
                        rule "lightSalonCeiling04 Switch Rule"
                        	when
                        		Item lightSalonCeiling04 received command
                        	then
                        		if(lightSalonCeiling04.state instanceof DecimalType || receivedCommand==INCREASE || receivedCommand==DECREASE){
                        		dimmerOperation.apply(lightSalonCeiling04, Arduino, sensorToItemsMap.get("lightSalonCeiling04"), receivedCommand, V_DIMMER)			
                        		} 
                        	end	
                        
                        rule "plugStrip01s12 Switch Rule"
                        	when
                        		Item plugStrip01s12 changed
                        	then
                        		switchOperation.apply(plugStrip01s12, Arduino, sensorToItemsMap.get("plugStrip01s12"), V_LIGHT)			
                        end	
                        
                        
                        rule "plugStrip01s34 Switch Rule"
                        	when
                        		Item plugStrip01s34 changed
                        	then
                        		switchOperation.apply(plugStrip01s34, Arduino, sensorToItemsMap.get("plugStrip01s34"), V_LIGHT)			
                        end	
                        

                        my test.item

                        String Arduino "Arduino" { serial="/dev/ttyUSB0@115200" }
                        Group All
                        Group flat "Flat" <house>
                        Group livingRoom "Living Room"  <sofa>  (All,flat)
                        Group kitchen      "Kitchen" <kitchen>  (All,flat)
                        Group corridor      "Corridor" <corridor>  (All,flat)
                        Group bathroom      "Bathroom" <bath>  (All,flat)
                        Group gmRoom  "Grandma Room" <smile>  (All,flat)
                        Group weather   (All)
                        Group status    (All)
                        Group mysensors    (All)
                        
                        Group:Switch:OR(ON, OFF) kLights "Lights" <light> (All, kitchen)
                        Group:Switch:OR(ON, OFF) kcLights "Cabinet Lights [(%d)]" <light> (All, kLights)
                        Group:Switch:OR(ON, OFF) skcLights "Single Cabinet Lights [(%d)]" <light> (All)
                        
                        Group:Switch:OR(ON, OFF) lrLights "Lights" <light> (livingRoom)
                        Group:Switch:OR(ON, OFF) lrcLights "Ceiling Lights [(%d)]" <light> (lrLights)
                        
                        Group:Switch:OR(ON, OFF) lrSockets "Sockets" <socket> (livingRoom)
                        Group:Switch:OR(ON, OFF) lrPlugStrip "Sockets [(%d)]" <socket> (lrSockets)
                        
                        Group:Number:AVG humAndTemp "Avg. Room Humidity[%.1f %%] and Temperature [%.1f °C]" <temperature>
                        Group:Number:AVG temperature "Avg. Room Temperature [%.1f °C]" <temperature> (status)
                        Group:Number:AVG humidity "Avg. Room Humidity [%.1f %%]" <temperature> (status)
                        
                        
                        Group:Switch:OR(ON, OFF) lights "All Lights [(%d)]" <light> (All)
                        
                        Number tempChartPeriod          "Chart Period"
                        Number tempSalon01 "Temperature [%s °C]" <temperature> (temperature,humAndTemp)
                        Number humSalon01 "Humidity [%s %%]" <temperature> (humidity,humAndTemp)
                        Switch lightKitchenCabinet00	"Light 1" (lights, kcLights)
                        Switch lightKitchenCabinet01	"Light 2" (lights, kcLights)
                        Switch lightKitchenCabinet02	"Light 3" (lights, kcLights)
                        Switch lightKitchenCabinet03	"Light 4" (lights, kcLights)
                        
                        Switch lightBar04		"Bar Lights" (lights, kLights, lrLights)
                        
                        Dimmer lightSalonCeiling00	"Light 1 [%s %%]" (lights, lrcLights)
                        Dimmer lightSalonCeiling01	"Light 2 [%s %%]" (lights, lrcLights)
                        Dimmer lightSalonCeiling02	"Light 3 [%s %%]" (lights, lrcLights)
                        Dimmer lightSalonCeiling03	"Light 4 [%s %%]" (lights, lrcLights)
                        Dimmer lightSalonCeiling04	"Light All [%s %%]" (lights,lrLights,allLights)
                        Switch plugStrip01s12		"Sockets 1-2" <socket> (lrPlugStrip)
                        Switch plugStrip01s34		"Sockets 3-4" <socket> (lrPlugStrip)
                        
                        String sensorLRCDimmer "Living Room Ceiling Light Sensor [%s]" (mysensors)
                        String sensorLRStripPlug01 "Living Room Strip Plug 01 Sensor [%s]" (mysensors)
                        String sensorLRHumTemp "Living Room Hum&Temp&Motion&Light  Sensor [%s]" (mysensors)
                        String sensorKCLight "Kitchen&Bar Light Sensor [%s]" (mysensors)
                        

                        my test.sitemap

                        sitemap demo label="Main Menu"
                        {
                        
                        	Frame label="Home" {
                        		Group label="Kitchen" icon="kitchen" {
                        			Frame label="Kitchen" {
                        				Group item=kLights label="Lights" {
                        				Switch item=lightBar04 label="Bar Lights"
                        				Switch item=kcLights label="Cabinet Lights"
                        				Group item=kcLights 
                        				}
                        			}
                        		}
                        
                        		Group item=livingRoom {
                        			Frame label="Living Room" {
                        				Group item=lrLights 
                        				Group label="Sensors" icon="temperature" {
                        					Text item=tempSalon01 valuecolor=[tempSalon01=="Uninitialized"="lightgray",tempSalon01>90="lightgray",>25="orange",>15="green",>5="orange",<=5="blue"]
                        					Text item=humSalon01 valuecolor=[humSalon01=="Uninitialized"="lightgray",tempSalon01>90="lightgray",>25="orange",>15="green",>5="orange",<=5="blue"]
                        					Switch item=tempChartPeriod label="Chart Period" mappings=[0="12 Hours", 1="Day", 2="Week", 3="Month"]
                        					Chart item=humAndTemp period=12h refresh=5000 visibility=[tempChartPeriod==0,tempChartPeriod=="Uninitialized"]
                        					Chart item=humAndTemp period=D refresh=1800 visibility=[tempChartPeriod==1]
                        					Chart item=humAndTemp period=W refresh=3600 visibility=[tempChartPeriod==2]
                        					Chart item=humAndTemp period=M refresh=7200 visibility=[tempChartPeriod==3]
                        				}
                        				Group item=lrPlugStrip
                        			}
                        		}
                        		Group item=corridor 
                        		Group item=bathroom icon="bath"
                        		Group item=grandmotherRoom icon="smiley"
                        	}
                        
                        	Frame label="Lights All"{
                        		Switch item=lights mappings=[OFF="All Off"]
                        		Group item=lights
                        		Group item=mysensors
                        	}
                        
                        E 1 Reply Last reply
                        2
                        • T Offline
                          T Offline
                          TimO
                          Hero Member
                          wrote on last edited by
                          #33

                          Cool! I will certainly adapt that! Thanks!

                          1 Reply Last reply
                          0
                          • J Offline
                            J Offline
                            Jan Gatzke
                            wrote on last edited by
                            #34

                            This looks great. Far better than my rules. I like the approach with the hash table very much.

                            1 Reply Last reply
                            0
                            • J Offline
                              J Offline
                              jemish
                              wrote on last edited by
                              #35

                              Can I get the Arduino uno code for this openhab serial binding?
                              I want a like to see that how it will work.

                              1 Reply Last reply
                              1
                              • T Offline
                                T Offline
                                TimO
                                Hero Member
                                wrote on last edited by
                                #36

                                @jemish : Just use this one: http://www.mysensors.org/build/serial_gateway

                                It is the standard serial gateway. Nothing special.

                                1 Reply Last reply
                                0
                                • J Offline
                                  J Offline
                                  jemish
                                  wrote on last edited by jemish
                                  #37

                                  At this link: http://www.mysensors.org/build/serial_gateway I got the arduino sketch,
                                  but I want to know, this sketch is for main arduino that is connected to the raspberry pi via serial communication and other side it is connected to the nRF24L01.

                                  If it is true than, I want to know which code is required at node side where I can ON or OFF LED and LIGHTS or DIMMER.

                                  1 Reply Last reply
                                  0
                                  • J Offline
                                    J Offline
                                    jemish
                                    wrote on last edited by
                                    #38

                                    Hey.....please can anyone reply me?......please......

                                    J 1 Reply Last reply
                                    0
                                    • J jemish

                                      Hey.....please can anyone reply me?......please......

                                      J Offline
                                      J Offline
                                      Jan Gatzke
                                      wrote on last edited by
                                      #39

                                      @jemish This is to basic to earn an answer. I suggest you start reading at http://www.mysensors.org .

                                      1 Reply Last reply
                                      1
                                      • J Offline
                                        J Offline
                                        jemish
                                        wrote on last edited by
                                        #40

                                        hi,
                                        I have a question, that how can I get feedback from our switchboard that is at our wall.

                                        If I am on the light by pressing the switch at switchboard.

                                        If in case I get the 5v from switchboard and give it to the Arduino, than how can I update state of switch in openhab.

                                        1 Reply Last reply
                                        0
                                        • J Offline
                                          J Offline
                                          jemish
                                          wrote on last edited by
                                          #41

                                          Hay, can any one try that.........feedback from switchboard

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          15

                                          Online

                                          11.7k

                                          Users

                                          11.2k

                                          Topics

                                          113.0k

                                          Posts


                                          Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • OpenHardware.io
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular