Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. schudoel
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by schudoel

    • RE: [Tutorial] openHAB with serial gateway

      @Jan-Gatzke Yes, the command line of openHAB is always open. Wiring was okay. I bought some capacitors yesterday and added one 4.7uF to every nrf24l01+, now it is working again 🙂

      posted in OpenHAB
      schudoel
      schudoel
    • RE: [Tutorial] openHAB with serial gateway

      Was working ... I do not know why, but after I changed the power cables of the sensor, it stopped working correctly. Serial output:

      repeater started, id 101
      send: 101-101-0-0 s=255,c=0,t=18,pt=0,l=5,st=fail:1.4.1
      send: 101-101-0-0 s=255,c=3,t=6,pt=1,l=1,st=fail:0
      send: 101-101-0-0 s=255,c=3,t=11,pt=0,l=5,st=fail:Relay
      send: 101-101-0-0 s=255,c=3,t=12,pt=0,l=3,st=fail:1.0
      send: 101-101-0-0 s=1,c=0,t=3,pt=0,l=5,st=fail:1.4.1
      

      I do not have a decoupling capacitor to test whether it could solve my issues, but my hum/temp sensor and gateway do not have one either and are still working perfectly. I have tried to find any information on those fail messages, but wasn't successful. Do you have any suggestions?

      posted in OpenHAB
      schudoel
      schudoel
    • RE: [Tutorial] openHAB with serial gateway

      @Jan-Gatzke Thank you! I had a rule for the command, but it did not work out as I wanted. I think I had a typo in the code, but I could fix it. Are there any log files I could use for debugging the rules?

      This is the code I use now:

      import org.openhab.core.library.types.*
      import org.openhab.core.persistence.*
      import org.openhab.model.script.actions.*
      import org.joda.time.*
      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(
          "100;0;"            -> "livingHum01",
          "livingHum01"       -> "100;0;",
          "100;1;"            -> "livingTemp01",
          "livingTemp01"      -> "100;1;",
          "101;1;"            -> "livingRelay",
          "livingRelay"       -> "101;1;"
      )
      
      //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_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 "livingRelay Switch Rule"
          when
              Item livingRelay changed
          then
              switchOperation.apply(livingRelay, Arduino, sensorToItemsMap.get("livingRelay"), V_LIGHT)         
      end 
      

      and it's working like charm.

      posted in OpenHAB
      schudoel
      schudoel
    • RE: [Tutorial] openHAB with serial gateway

      @TimO Thank you very much! I could not get the Symlink to work at first, but then I fould this, maybe it can help other Raspberry Pi owners.

      @Jan-Gatzke I tried to connect a different sensor (RelayActuator) to my Gateway, added it to my .items, .sitemap and added your V_LIGHT routine in my .rules, but no success. Did I miss anything?

      Thanks to all of you
      Flo

      posted in OpenHAB
      schudoel
      schudoel