Skip to content
  • MySensors
  • 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. Troubleshooting
  3. Difficulties with openhab

Difficulties with openhab

Scheduled Pinned Locked Moved Troubleshooting
6 Posts 4 Posters 5.2k Views 3 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.
  • S Offline
    S Offline
    shasha
    wrote on last edited by shasha
    #1

    Hello,

    I am trying to use openhab (v1.7) with a serialgateway. hum ... not easy.

    I defined an item file, a sitemap file and a rule file.

    I discovered that we need to code manythings in this rule file.

    So far I have several questions :

    1. when I want to do a postUpdate like : postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), tripped)

    I got this warning message :
    [WARN ] [.c.i.events.EventPublisherImpl] - given new state is NULL, couldn't post update for 'detecteur_hall'

    where does this error come from ? all the parameters are defined and not NULL ....

    1. I am trying to send a message to the gateway like :
      sendCommand(Arduino, nodeId +";255;3;0;1;" + "1496700000\n")

    I want to send the time in response to a time request
    the message is sent to the node great !!! BUTTTTTTTTTTT at the same time it gets to openhab
    then it is processed by the "Arduino sends to Openhab" rule. So it is decoded as a time request and
    sends it again ... here comes the death loop !!!

    Any idea on how to send a message to the network that will not be presented as an incoming message ?
    what do I do wrong here ?

    the Arduino string name has been defined the items file !

    1. is there a time variable containing the time that could be addressed from the rules ?
      haha seems the function now() returns a time value I will continue checking this !

    Thanks for your help.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      TimO
      Hero Member
      wrote on last edited by
      #2
      1. I had the same problem and needed some time to figure it out. My working rule looks like:
       if (subType == V_TRIPPED){
                          println ("Window item: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " status: " + Integer::parseInt(msg) )
                          if(Integer::parseInt(msg) == 1) {
                                                      postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), "OPEN")                    }
                          if(Integer::parseInt(msg) == 0) {
                              postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), "CLOSED")
                          }
                      }
      
      1. Show us the rule set you currently use, we need to find a way to differentiate between sending and receiving with the same nodeId and childId.. I don't had this problem yet, my combination of nodeId + childId is either sending or receiving.
      1 Reply Last reply
      0
      • S Offline
        S Offline
        shasha
        wrote on last edited by shasha
        #3

        Here are the two pieces of code :

                          if (subType == V_TRIPPED) {
                            var String tripped="OFF"
                            if (msg=="1"){
                                tripped="ON"
                            }
                            postUpdate(sensorToItemsMap.get( nodeId + ";" + childId + ";"), tripped)
                            println ("Unit: " + sensorToItemsMap.get( nodeId + ";" + childId + ";") + " etat: " + tripped )
        
        

        ah seems you solved one of my problems. If I change ON to OPEN and OFF to CLOSED it works !

        if(subType == I_TIME){ 
                                println("Time request" )  
                                sendCommand(Arduino, nodeId +";255;3;0;1;" + "1496700000\n")  // dummy time value
                            }
        
        1 Reply Last reply
        0
        • S Offline
          S Offline
          shasha
          wrote on last edited by shasha
          #4

          Regarding the time variable question I made some progress :

          var Integer time = now().getMillis()/1000    // I get the millisecondes then divide by 1000 hence the seconds
          println(nodeId +";255;3;0;1;" + time +"\n"    //  print to see the command to send
          

          this works fine I go the time in seconds from 1970. But I need to consider the timezone and the summer time.
          So I added :
          time = time + 7200 and then I get
          [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Arduino sends to Openhab': Could not invoke method: org.eclipse.xtext.xbase.lib.IntegerExtensions.operator_plus(int,int) on instance: null

          wow !!! for a simple add any clue ?

          well I decided to add the 7200 that way : var Integer time = now().getMillis()/1000 +7200
          and it works. very very strange. so now the code is :

          var Integer time = now().getMillis()/1000 + 7200    //convert the millis & add the offset for time zone and summer time
          println(nodeId +";255;3;0;1;" + time +"\n"    //  print to see the command to send
          

          The major problem is still the death loop with the
          sendCommand(Arduino, nodeId +";255;3;0;1;" + time+"\n")

          have you noticed this? seems there is a loopback in the serialbinding. Configurable maybe ?
          I will try to get some doc on this binding. At least the code could give an idea. I will look for it.

          1 Reply Last reply
          0
          • K Offline
            K Offline
            kimnguu204
            wrote on last edited by
            #5

            @Shasha,
            Can you share your rules? I can't send command from openhab to Node, can't control relays
            it's so difficult

            E 1 Reply Last reply
            0
            • K kimnguu204

              @Shasha,
              Can you share your rules? I can't send command from openhab to Node, can't control relays
              it's so difficult

              E Offline
              E Offline
              ewgor
              wrote on last edited by
              #6

              @kimnguu204 have you managed to control your relays and also to get their status?

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


              29

              Online

              11.7k

              Users

              11.2k

              Topics

              113.1k

              Posts


              Copyright 2025 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
              • MySensors
              • OpenHardware.io
              • Categories
              • Recent
              • Tags
              • Popular