Navigation

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

    Posts made by shasha

    • How to receive data on openhab using UDP ? (solved)

      Hello !

      Here is the problem I am facing :

      I have an arduino node communicating using UDP. It sends on port 600 receives on port 500.
      I would like to be able to send and receive data to this node from the openhab.

      Sending data has been straight forward. It works nicely. On the other hand I did not manage to get
      any data from this node. I tried various changes in the config file and in the way to do the incoming
      binding but I still got warnings. Here are some information on my setup :

      items setup :

      String fromUDPnode "fromUDPnode" {udp="<[192.168.0.9:500:'REGEX((.*))']"}
      String toUDPnode "toUDPnode" {udp=">[192.168.0.9:500:'REGEX((.*))']"}
      
      

      config :

      udp:itemsharedconnections=true
      udp:bindingsharedconnections=true
      udp:directionssharedconnections=false
      udp:addressmask=true
      udp:postamble=
      udp:blocking=false
      udp:refreshinterval=250
      udp:port=600
      

      and here are the warnings I get :

       [WARN ] [AbstractDatagramChannelBinding] - Received data 10;59;1;0;23;0
               from an undefined remote end /192.168.0.9:500. We will not process it
       [WARN ] [AbstractDatagramChannelBinding] - No channel is active or defined for the data we received from /192.168.0.9:500. It will be discarded.
      

      seems openhab receives the data but discard them ...

      any clue on how to solve this issue ?

      Thanks

      posted in Troubleshooting
      shasha
      shasha
    • RE: How to create new icons for openhab ? (Solved)

      So it does work !

      I was not activating the item so the closed icon was not displayed on the screen. As soon as I was updating the state
      to open or closed the icon was here !!

      So it has to do with the fact that when the app starts the state of the item is not known and the system is unable to
      select the proper icon.

      So I added an other icon with no state this time "motion.png" this one is displayed on start up !!!.

      Several icons are needed :
      a generic one "myicon.png" to be used when the state is not known
      various icons "myicon-statex.png" to be used when the icon is in the x state

      Shasha

      posted in OpenHAB
      shasha
      shasha
    • How to create new icons for openhab ? (Solved)

      Hello!

      I would like to create icons for openhab. For instance I want a motion detector icon.

      what I did is I created 2 icons files motion-open.png and motion-closed.png 32x32 that
      I put in the openhab/webapps/images directory

      Then in my items file I specify the <motion> option to tell I want to use this icon.
      These are the only information I found in the wiki.

      This does not seem to work.

      anything I should pay attention to so the app will display this icon ?

      many thanks

      posted in OpenHAB
      shasha
      shasha
    • RE: openhab sendCommand problem with serialbinding (Solved)

      Thank you for the info

      so all the sendCommand to Arduino I will initiate will be seen again when using a trigger like "Arduino received update".

      The workaround I was thinking is the one you suggested. That is to say to check the payload of the incoming message.

      So this problem is solved !

      Thank you !

      posted in OpenHAB
      shasha
      shasha
    • openhab sendCommand problem with serialbinding (Solved)

      Hello

      I did not find the solution for the loopback problem:

      when I use sendCommand with serialbinding the message is sent to the gateway.
      but at the same time this message is presented as an incoming message to openhab.

      so this message is processed again and creates a deathloop.

      I tried to move the sendCommand from the processing incoming message rule to a separate one
      but the problem is the same. With this new code I use cron so the message does not come immediately
      but the loop is still here.

      I could set up a workaround but I would like to know if there is a clean solution ?
      Is it the way the rule are working ? Is it due to serialbinding ? I tried to have a look at the serial binding code
      but did not find what could create the loopback.

      Help help thank you for your support !

      here is the code :

      //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)
            
                  // Internal Command
                  if ( msgType == C_INT ){
                       if(subType == I_TIME ){ 
                              println("Time request from node : " + nodeId)   
                              timeToNodeId = nodeId
                              sendTime = 1
                        }              
                  }
              }
      end
      //
      //
      //
      rule "send time"
      when
                     Time cron "0 * * * * ?"
      then
                     if (sendTime == 1) {
                         var Integer time2 = now().getMillis()/1000 +7200
                         sendCommand(Arduino, timeToNodeId+";255;3;0;1;" + time2+"\n") 
                         sendTime = 0 
                     }       
      end
      
      posted in OpenHAB
      shasha
      shasha
    • RE: Difficulties with openhab

      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.

      posted in Troubleshooting
      shasha
      shasha
    • RE: Difficulties with openhab

      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
                          }
      
      posted in Troubleshooting
      shasha
      shasha
    • Difficulties with openhab

      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.

      posted in Troubleshooting
      shasha
      shasha
    • RE: How to use MyMessage .setDestination ??

      hum you are right !!

      thank you !

      posted in Troubleshooting
      shasha
      shasha
    • RE: How to use MyMessage .setDestination ??

      Hum some news :

      There are two constructors for MyMessage

      one is MyMessage::MyMessage()
      the other one is MyMessage::MyMessage(uint8_t _sensor, uint8_t _type)

      if I modify my dummy sketch like this :

      #include <MyMessage.h>
      
      MyMessage msgOut();
      MyMessage msgIn(1, V_TRIPPED);
      
      void setup() {
      msgIn.isAck();
      msgOut.isAck();
      msgOut.setDestination(10);
      msgIn.setDestination(10);
      }
      
      void loop() {
      }
      

      I get the following errors :

      In function 'void setup()':
      error: request for member 'isAck' in 'msgOut', which is of non-class type 'MyMessage()'
      error: request for member 'setDestination' in 'msgOut', which is of non-class type 'MyMessage()'

      The errors are only for msgOut that uses the first constructor.
      msgIn uses the second constructor and it works.

      Looks wierd to me. Can you explain why the simplest constructor gives errors ?

      Thanks again

      posted in Troubleshooting
      shasha
      shasha
    • How to use MyMessage .setDestination ??

      Hello,

      I would like to use the MyMessage set on the fly functions.
      Here is a dummy sketch that cannot compile.

      #include <MyMessage.h>
      
      MyMessage msgOut();
      
      void setup() {
      msgOut.setDestination(10);
      }
      
      void loop() {
      }
      

      here is the error I got :

      error: request for member 'setDestination' in 'msgOut', which is of non-class type 'MyMessage()'

      What it is wrong in the way I use this function ?
      Thanks

      posted in Troubleshooting
      shasha
      shasha
    • RE: sensor library compile problem after a change (SOLVED)

      I checked the RF24.cpp and the RF24.h and the function is well defined.

      The include list is correct !!

      But you said you have been able to compile so I checked again and I found that the printDetails function is in an If section

      this is controlled by MINIMAL

      #if !defined (MINIMAL)
      
      static const char rf24_datarate_e_str_0[] PROGMEM = "1MBPS";
      static const char rf24_datarate_e_str_1[] PROGMEM = "2MBPS";
      static const char rf24_datarate_e_str_2[] PROGMEM = "250KBPS";
      static const char * const rf24_datarate_e_str_P[] PROGMEM = {
        rf24_datarate_e_str_0,
        rf24_datarate_e_str_1,
        rf24_datarate_e_str_2,
      };
      static const char rf24_model_e_str_0[] PROGMEM = "nRF24L01";
      static const char rf24_model_e_str_1[] PROGMEM = "nRF24L01+";
      static const char * const rf24_model_e_str_P[] PROGMEM = {
        rf24_model_e_str_0,
        rf24_model_e_str_1,
      };
      static const char rf24_crclength_e_str_0[] PROGMEM = "Disabled";
      static const char rf24_crclength_e_str_1[] PROGMEM = "8 bits";
      static const char rf24_crclength_e_str_2[] PROGMEM = "16 bits" ;
      static const char * const rf24_crclength_e_str_P[] PROGMEM = {
        rf24_crclength_e_str_0,
        rf24_crclength_e_str_1,
        rf24_crclength_e_str_2,
      };
      static const char rf24_pa_dbm_e_str_0[] PROGMEM = "PA_MIN";
      static const char rf24_pa_dbm_e_str_1[] PROGMEM = "PA_LOW";
      static const char rf24_pa_dbm_e_str_2[] PROGMEM = "PA_HIGH";
      static const char rf24_pa_dbm_e_str_3[] PROGMEM = "PA_MAX";
      static const char * const rf24_pa_dbm_e_str_P[] PROGMEM = {
        rf24_pa_dbm_e_str_0,
        rf24_pa_dbm_e_str_1,
        rf24_pa_dbm_e_str_2,
        rf24_pa_dbm_e_str_3,
      };
      
      
      void RF24::printDetails(void)
      {
        print_status(get_status());
      
        print_address_register(PSTR("RX_ADDR_P0-1"),RX_ADDR_P0,2);
        print_byte_register(PSTR("RX_ADDR_P2-5"),RX_ADDR_P2,4);
        print_address_register(PSTR("TX_ADDR"),TX_ADDR);
      
        print_byte_register(PSTR("RX_PW_P0-6"),RX_PW_P0,6);
        print_byte_register(PSTR("EN_AA"),EN_AA);
        print_byte_register(PSTR("EN_RXADDR"),EN_RXADDR);
        print_byte_register(PSTR("RF_CH"),RF_CH);
        print_byte_register(PSTR("RF_SETUP"),RF_SETUP);
        print_byte_register(PSTR("CONFIG"),CONFIG);
        print_byte_register(PSTR("DYNPD/FEATURE"),DYNPD,2);
      
      #if defined(__arm__)
        printf_P(PSTR("Data Rate\t = %s\r\n"),pgm_read_word(&rf24_datarate_e_str_P[getDataRate()]));
        printf_P(PSTR("Model\t\t = %s\r\n"),pgm_read_word(&rf24_model_e_str_P[isPVariant()]));
        printf_P(PSTR("CRC Length\t = %s\r\n"),pgm_read_word(&rf24_crclength_e_str_P[getCRCLength()]));
        printf_P(PSTR("PA Power\t = %s\r\n"),pgm_read_word(&rf24_pa_dbm_e_str_P[getPALevel()]));
      #else
        printf_P(PSTR("Data Rate\t = %S\r\n"),pgm_read_word(&rf24_datarate_e_str_P[getDataRate()]));
        printf_P(PSTR("Model\t\t = %S\r\n"),pgm_read_word(&rf24_model_e_str_P[isPVariant()]));
        printf_P(PSTR("CRC Length\t = %S\r\n"),pgm_read_word(&rf24_crclength_e_str_P[getCRCLength()]));
        printf_P(PSTR("PA Power\t = %S\r\n"),pgm_read_word(&rf24_pa_dbm_e_str_P[getPALevel()]));
      #endif
      
      }
      
      #endif
      

      this MINIMAL is defined in the RF24_config.h file :

        /*** USER DEFINES:  ***/  
        //#define FAILURE_HANDLING
        //#define SERIAL_DEBUG  
        #define MINIMAL
        //#define SPI_UART  // Requires library from https://github.com/TMRh20/Sketches/tree/master/SPI_UART
        //#define SOFTSPI   // Requires library from https://github.com/greiman/DigitalIO
        /**********************/
      

      in my file MINIMAL was defined so the printDetails function was skipped
      if I comment the MINIMAL definition then it compiles !!!

      you led me to the solution thanks a lot.

      But seems your RF24_config.h was already modified or you use an other file. I was using the one provided with MySensor
      in this one MINIMAL is defined. As I am curious I checked the files provided with RF24 lib (not the one in the MySensor/utility and found that MINIMAL is not defined !!!

      Thanks again pb solved !!

      posted in Troubleshooting
      shasha
      shasha
    • sensor library compile problem after a change (SOLVED)

      Hello,

      I would like to add a call to printDetails (RF24 function) in the setupradio function from the sensor lib.
      here is the code

      void MySensor::setupRadio(rf24_pa_dbm_e paLevel, uint8_t channel, rf24_datarate_e dataRate) {
      	failedTransmissions = 0;
      	//debug(PSTR("MySensor::setupRadio\n"));
      	// Start up the radio library
      	RF24::begin();
      	if (!RF24::isPVariant()) {
      		debug(PSTR("check wires\n"));
      		while(1);
      	}
      	RF24::setAutoAck(1);
      	RF24::setAutoAck(BROADCAST_PIPE,false); // Turn off auto ack for broadcast
      	RF24::enableAckPayload();
      	RF24::setChannel(channel);
      	RF24::setPALevel(paLevel);
      	RF24::setDataRate(dataRate);
      	RF24::setRetries(5,15);
      	RF24::setCRCLength(RF24_CRC_16);
      	RF24::enableDynamicPayloads();
      	
      	// All nodes listen to broadcast pipe (for FIND_PARENT_RESPONSE messages)
      	RF24::openReadingPipe(BROADCAST_PIPE, TO_ADDR(BROADCAST_ADDRESS));
      
          RF24::printDetails();    // here is the line I added !!
      }
      

      then I get this compile error :
      MySensors\MySensor.cpp.o: In function `MySensor::setupRadio(rf24_pa_dbm_e, unsigned char, rf24_datarate_e)':

      ......\Arduino\libraries\MySensors/MySensor.cpp:113: undefined reference to `RF24::printDetails()'
      collect2.exe: error: ld returned 1 exit status

      printDetails() is referenced in the RF24 lib I dont really see what I am doing wrong here ?

      anyone can give me a hint ?

      thanks a lot !
      shasha

      posted in Troubleshooting
      shasha
      shasha