openHAB 2.0 binding



  • Hey guys, first message on this forum. Been reading alot before. But now I have a problem I just can't solve.
    It's about smartsleep with openhab 2.
    Im using wifi gw rfm 69.
    Regular messages works as it should both ways.
    But it almost seems like the smartsleep isn't enabled in the binding.
    Here are my configs and logs.

    Things file:

    Bridge mysensors:bridge-eth:gw69 [ ipAddress="192.168.1.235", tcpPort=5003, sendDelay=100, enableNetworkSanCheck=true ] {
    //  Anarduino
        humidity        AnHum   [ nodeId="66", childId="0" ]
        temperature     AnTemp  [ nodeId="66", childId="1" ]
        light           light02 [ nodeId="66", childId="3", smartSleep=true ]
      }
    

    Items file:

    Switch  TestLight   "Test lampa" (Test) { channel="mysensors:light:gw69:light02:status" }
    

    Sketch: (Cleaned up the parts that dont matter, RTC and so on.)

    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    // Enable and select radio type attached
    #define MY_RADIO_RFM69
    #define MY_IS_RFM69HW
    #define MY_NODE_ID 66
    #define MY_RFM69_NETWORKID 100
    #define MY_RFM69_FREQUENCY RF69_433MHZ
    #define MY_SMART_SLEEP_WAIT_DURATION_MS 1000
    #include <MySensors.h>
    #include <TimeLib.h>
    #include <Wire.h>
    #include <MCP7940RTC.h>
    #include <DHT.h>
    
    #define MCP7940_CTRL_ID 0x6F
    #define CSMEM_PIN 5
    
    #define LEDPIN 9
    
    long sleepIntervalSec=5;
    long loopCnt=0;
    uint8_t d[8];
    uint8_t dAlarm[8];
    int d1[8];
    
    // Set this to the pin you connected the DHT's data pin to
    #define DHT_DATA_PIN 6
    
    // Set this offset if the sensor has a permanent small offset to the real temperatures
    #define SENSOR_TEMP_OFFSET 0
    
    // Sleep time between sensor updates (in milliseconds)
    // Must be >1000ms for DHT22 and >2000ms for DHT11
    static const uint64_t UPDATE_INTERVAL = 5000;
    
    // Force sending an update of the temperature after n sensor reads, so a controller showing the
    // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
    // the value didn't change since;
    // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
    static const uint8_t FORCE_UPDATE_N_READS = 10;
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_MULTIMETER 2
    
    float lastTemp;
    float lastHum;
    uint8_t nNoUpdatesTemp;
    uint8_t nNoUpdatesHum;
    bool metric = true;
    
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgVolt(CHILD_ID_MULTIMETER, V_VOLTAGE);
    
    DHT dht;
    
    int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
    int oldBatteryPcnt = 0;
    int batteryBasement = 812;
    int batteryFull = 922;
    float batteryConstant = 100.0 / (batteryFull - batteryBasement);
    float lastbatteryV = 0;
    
    const int buzzer = 7; //buzzer to arduino pin 7
    
    #define RELAY_1  8  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 1 // Total number of attached relays
    #define RELAY_ON 1  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
    void before()
    {
      for (int sensor=3, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);
        // Set relay to last known state (using eeprom storage)
        digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
      }
    }
    
    void setup()  
    {
       // use the 1.1 V internal reference
       analogReference(INTERNAL);
    
      pinMode(LEDPIN, OUTPUT);
      digitalWrite(LEDPIN, LOW);
      Wire.begin();
      pinMode(CSMEM_PIN, OUTPUT);
      digitalWrite(CSMEM_PIN, HIGH);
    
       dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
      if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
        Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
      }
      // Sleep for the time of the minimum sampling period to give the sensor time to power up
      // (otherwise, timeout errors might occure for the first reading)
      sleepIntervalSec = dht.getMinimumSamplingPeriod();
      clearAlarm();
      delay(20);
      setNewAlarm();
      sleep(dht.getMinimumSamplingPeriod());
      analogRead(BATTERY_SENSE_PIN);
     }
    
    void presentation() {
       // Send the sketch version information to the gateway and Controller
       sendSketchInfo("Humidity sensor", "1.0");
       present(CHILD_ID_MULTIMETER, S_MULTIMETER, "VOLT", true);
       present(CHILD_ID_HUM, S_HUM, "HUMIDITY", true);
       present(CHILD_ID_TEMP, S_TEMP, "TEMP", true);
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_BINARY);
      }
      metric = getControllerConfig().isMetric;
    }
    
    
    void loop()
    {
      wait(100);
       int sensorValue = analogRead(BATTERY_SENSE_PIN);
       #ifdef MY_DEBUG
       Serial.println(sensorValue);
       #endif
       float batteryV  = sensorValue * 0.004551646;
       if(sensorValue < batteryBasement) {
        sensorValue = batteryBasement;
        batteryV = 0;
       }
       else if (sensorValue > batteryFull) {
        sensorValue = batteryFull;
       }
       int batteryPcnt = (sensorValue - batteryBasement) * batteryConstant;
           if ((abs(oldBatteryPcnt - batteryPcnt) > 1)) {
          sendBatteryLevel(batteryPcnt);
          oldBatteryPcnt = batteryPcnt;
        }
       
       if(batteryV != lastbatteryV) {
       send(msgVolt.set(batteryV, 2));
       lastbatteryV = batteryV;
       }
       #ifdef MY_DEBUG
       Serial.print("Battery Voltage: ");
       Serial.print(batteryV);
       Serial.println(" V");
       Serial.print("Battery percent: ");
       Serial.print(batteryPcnt);
       Serial.println(" %");
       #endif
    
      // Force reading sensor, so it works also after sleep()
      dht.readSensor(true);
    
      // Get temperature from DHT library
      float temperature = dht.getTemperature();
      if (isnan(temperature)) {
        Serial.println("Failed reading temperature from DHT!");
      } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
        // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
        lastTemp = temperature;
        if (!metric) {
          temperature = dht.toFahrenheit(temperature);
        }
        // Reset no updates counter
        nNoUpdatesTemp = 0;
        temperature += SENSOR_TEMP_OFFSET;
        send(msgTemp.set(temperature, 1));
        #ifdef MY_DEBUG
        Serial.print("T: ");
        Serial.println(temperature);
        #endif
      } else {
        // Increase no update counter if the temperature stayed the same
        nNoUpdatesTemp++;
      }
    
      // Get humidity from DHT library
      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
        Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
        // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
        lastHum = humidity;
        // Reset no updates counter
        nNoUpdatesHum = 0;
        send(msgHum.set(humidity, 1));
    
        #ifdef MY_DEBUG
        Serial.print("H: ");
        Serial.println(humidity);
        #endif
      } else {
        // Increase no update counter if the humidity stayed the same
        nNoUpdatesHum++;
      }
    long sleepTime = UPDATE_INTERVAL;
    if (batteryPcnt < 50) {
      sleepTime = (sleepTime * 2);
    }
      // Sleep for a while to save energy
      sleepIntervalSec = sleepTime / 1000;
      Serial.println();
      Serial.print("Setting new sleep time: ");
      Serial.print(sleepIntervalSec);
      Serial.println(" seconds.");
      clearAlarm();
      delay(20);
      setNewAlarm();
      smartSleep(sleepTime);
    
    }
    
    void receive(const MyMessage &message)
    {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_STATUS) {
        // Change relay state
        digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
        // Store state in eeprom
        saveState(message.sensor, message.getBool());
        // Write some debug info
        Serial.print("Incoming change for sensor:");
        Serial.print(message.sensor);
        Serial.print(", New status: ");
        Serial.println(message.getBool());
      }
    }
    

    Sensor startup:

    0 MCO:BGN:INIT NODE,CP=RRNNA--,VER=2.1.1
    3 MCO:BGN:BFR
    4 TSM:INIT
    5 TSF:WUR:MS=0
    8 TSM:INIT:TSP OK
    9 TSM:INIT:STATID=66
    11 TSF:SID:OK,ID=66
    13 TSM:FPAR
    143 TSF:MSG:SEND,66-66-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    524 TSF:MSG:READ,0-0-66,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    529 TSF:MSG:FPAR OK,ID=0,D=1
    2150 TSM:FPAR:OK
    2151 TSM:ID
    2152 TSM:ID:OK
    2154 TSM:UPL
    2161 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2181 TSF:MSG:READ,0-0-66,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2186 TSF:MSG:PONG RECV,HP=1
    2189 TSM:UPL:OK
    2190 TSM:READY:ID=66,PAR=0,DIS=1
    2199 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    2253 TSF:MSG:READ,0-0-66,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    2310 TSF:MSG:SEND,66-66-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
    2366 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
    2403 TSF:MSG:READ,0-0-66,s=255,c=3,t=6,pt=0,l=1,sg=0:M
    2461 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=11,pt=0,l=15,sg=0,ft=0,st=OK:Humidity sensor
    2562 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
    2618 TSF:MSG:SEND,66-66-0-0,s=2,c=0,t=30,pt=0,l=4,sg=0,ft=0,st=OK:VOLT
    2757 !TSF:MSG:SEND,66-66-0-0,s=0,c=0,t=7,pt=0,l=8,sg=0,ft=0,st=NACK:HUMIDITY
    2777 TSF:MSG:SEND,66-66-0-0,s=1,c=0,t=6,pt=0,l=4,sg=0,ft=1,st=OK:TEMP
    2912 !TSF:MSG:SEND,66-66-0-0,s=1,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=NACK:
    2918 MCO:REG:REQ
    2974 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=1,st=OK:2
    2991 TSF:MSG:READ,0-0-66,s=255,c=3,t=27,pt=1,l=1,sg=0:1
    2996 MCO:PIM:NODE REG=1
    2999 MCO:BGN:STP
    3154 MCO:SLP:MS=2000,SMS=0,I1=255,M1=255,I2=255,M2=255
    3160 MCO:SLP:TPD
    3161 MCO:SLP:WUP=-1
    3163 MCO:BGN:INIT OK,TSP=1
    

    Log Sensor: (This is when I press the button when the sensor is awake)
    It's sends away it's heartbeat correctly.

    125578 TSF:MSG:READ,0-0-66,s=3,c=1,t=2,pt=0,l=1,sg=0:0
    Incoming change for sensor:3, New status: 0
    
    Setting new sleep time: 5 seconds.
    137926 MCO:SLP:MS=5000,SMS=1,I1=255,M1=255,I2=255,M2=255
    137939 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:134932
    

    Log Openhab: And the gateway receives heartbeat.

    18:21:37.174 [DEBUG] [rs.internal.protocol.MySensorsWriter] - Sending to MySensors: 66;3;1;0;2;0
    18:21:37.178 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'TestLight' received command OFF
    18:21:37.181 [INFO ] [marthome.event.ItemStateChangedEvent] - TestLight changed from ON to OFF
    18:22:15.416 [DEBUG] [rs.internal.protocol.MySensorsReader] - 66;255;3;0;22;134932
    18:22:16.372 [DEBUG] [rs.internal.protocol.MySensorsWriter] - Sending to MySensors: 0;0;3;0;2;
    18:22:16.408 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;2;2.1.1
    

    Log Openhab: When the node sleeps..

    18:26:52.396 [DEBUG] [rs.internal.protocol.MySensorsWriter] - Sending to MySensors: 66;3;1;0;2;0
    18:26:52.397 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'TestLight' received command OFF
    18:26:52.399 [INFO ] [marthome.event.ItemStateChangedEvent] - TestLight changed from ON to OFF
    

    As you can see there is no mention in the openhab log file about buffering or smart sleep. Or a received heartbeat. Which it gets.
    What am I doing wrong?


  • Hardware Contributor

    Hi, just a short question as I haven't found any up to date information about it: I am thinking about switching from domoticz to openHab 2 (as I really like the new UIs and the auto discovery). I am using an ESP8266 based MQTT gateway. Does openhab 2 on a raspi work with Mysensors using MQTT and does it support the new sensors/actor types added Mysensors 2 (specially RGBW)?

    Thank you!



  • Yes you can using proxy items and rules. see example here : https://github.com/mortommy/MySensorDioder
    But why not switching to ethernet/serial gateway with @TimO OH2 plugin ?


  • Hardware Contributor

    Thanks @Fabien I have a serial gateway too, but I liked the idea of a MQTT gateway more because its much more flexible. Does Tims plugin not support MQTT? I wanted to use that.



  • Hi @LastSamurai , currently Timo is working on MQTT gateway but I don't know precisely when it will be available to all.

    @TimO said in openHAB 2.0 binding:

    @Fabien Thank you for your feedback!
    And: I've waited for that question according firmware updates to come up. 😄

    I've looked into it and I'm very interested but till now there is only the implementation in the library, I've not seen an implementation in a binding. I'll continue to look at it, but with low priority. 🙂

    Current priority list is:

    1. Include binding in OH2 repository.
    2. Test and include the big refactoring from @andreacioni .
    3. Add MQTT gateway (proof of concept working, full integration after refactoring).
    4. Add little feature requests, add sensors ...

  • Hardware Contributor

    Ok, I will keep an eye on this one and stay with the serial gateway for now.



  • After moving from my ubuntu laptop to RP3 I have had success!!
    Flashed the sd card with the latest openhabian, waited for everything to auto install on the RP3 and could then install the my sensors (ethernet) gateway on the pi and also open a karaf console to log openhab2 via a remote/headless ssh. My remote browser could open the paper ui via openhabianpi:8080 and I added the ethernet gateway successfully. Adding the motion sensor needed the node id 2 and child id 1 as set by the Arduino sketch. The light level sensor was then turned on and it just showed up as my sensors (2,2) in the paper ui inbox so this level of discovery works! The sensors now show tripped status/light level in the paper ui control.
    Looks like I can now progress to using My Sensors to control the mi-lights already working in openhab2.
    Thanks Tim for all your work on the binding



  • @TimO , I just noticed a weird behavior - I've changed configuration for another binding and restarted it from the console but that killed mysensors binding:

    2017-03-04 13:07:19.110 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'demo.things'
    2017-03-04 13:07:19.123 [ERROR] [col.serial.MySensorsSerialConnection] - Interrupted reset time wait
    2017-03-04 13:07:19.124 [WARN ] [col.serial.MySensorsSerialConnection] - Skipping I_VERSION connection test, not recommended...
    2017-03-04 13:07:19.125 [INFO ] [col.serial.MySensorsSerialConnection] - Successfully connected to MySensors Bridge.
    2017-03-04 13:07:19.125 [WARN ] [col.serial.MySensorsSerialConnection] - Network Sanity Checker thread disabled from bridge configuration

    2017-03-04 13:07:21.141 [ERROR] [col.serial.MySensorsSerialConnection] - Can't connect to serial port. Wrong port?
    2017-03-04 13:07:21.149 [ERROR] [col.serial.MySensorsSerialConnection] - Failed connecting to bridge...next retry in 10 seconds (Retry No.:0)
    2017-03-04 13:07:33.161 [ERROR] [col.serial.MySensorsSerialConnection] - Can't connect to serial port. Wrong port?
    2017-03-04 13:07:33.163 [ERROR] [col.serial.MySensorsSerialConnection] - Failed connecting to bridge...next retry in 10 seconds (Retry No.:1)

    Complete stop/start of OH is the only solution so far.



  • Hi @AndrewZ , yes this is a known issue (I just openend an issue here) with the binding. Just out of curiosity, have you changed something in things file?



  • @andreacioni thank you
    Yes, it was a change in the .things file, but it was related to another binding.



  • @AndrewZ things file update trigger a reload of all binding declared inside it, nothing strange. 😉 Follow the above link to keep track of the status of this issue.


  • Hardware Contributor

    I just tried to get the openhab 2 binding up and running. I have a serial gateway and domoticz + openhab running on a pi. I stopped the domoticz service and installed the serial and mysensors addons for openhab like mentioned in the github readme (bundle:list showed them both). I also added the openhab user to the dialout group.
    I then created a demo.things file in config/things with

    Bridge mysensors:bridge-ser:gateway [ serialPort="/dev/ttyUSB0", sendDelay=200 ] {
        /** define things connected to that bridge here */
      }
    

    The log of openhab shows these errors though:

    2017-03-19 00:03:59.855 [ERROR] [col.serial.MySensorsSerialConnection] - Can't connect to serial port. Wrong port?
    2017-03-19 00:03:59.897 [ERROR] [col.serial.MySensorsSerialConnection] - Failed connecting to bridge...next retry in 10 seconds (Retry No.:46)
    

    Any idea why? This works just fine:

    cat /dev/ttyUSB0
    


  • @LastSamurai please check the group ownership

    $ ls -l /dev/ttyUSB0
    

    Make sure the port you're using is included in EXTRA_JAVA_OPTS as described here


  • Hardware Contributor

    Thank you, that helped! Should anyone ever face the same problem: after changing the EXTRA_JAVA_OPTS I also needed to restart openhab (more likely the java vm).


  • Hardware Contributor

    So openhab is running now and discovers my sensors when I restart them while scanning. My RGBW controller nodes pop up as RGBW sensors though. The on/off switch works, but what do I have to do to actually control the colors?
    I tried editing the 4 variables but that doesn't seem to change the lights.

    0_1490048386134_upload-9bf82cdd-ddd8-4249-973e-65bd30a3a959


  • Hero Member

    @LastSamurai : What does your sketch expect? One ASCII formated RGB code like described here: https://www.mysensors.org/download/serial_api_20 or a value between 0 and 100% per color (r,g,b,w)? I see different implementations (in openhab and in mysensors) and maybe we have to adjust the binding.


  • Hardware Contributor

    @TimO Right, I guess thats the problem. I have written my sketch against domoticz, so it expects either a 6 bit hex string (rgb = e.g. ff00ff) or a 9 bit (idk why) rgbw hex string (e.g. #ff00ff00).
    According to the mysensors docu "ff00ff00" would be right, I guess.



  • Just noticed in the log:

    [WARN ] [.discovery.MySensorsDiscoveryService] - Cannot automatic discover thing node: 0, child: 255 please insert it manually
    

    Is that normal or any additional configuration is needed?
    Thanks!


  • Hero Member

    @AndrewZ hmmmm, a child that represents itself with an id of 255 shouldn't exist. 255 is used for battery status for example. What's the message that comes in before that?


  • Hero Member

    @LastSamurai I'm working on a solution! RGB seems easy, but I haven't looked at RGBW. The Colopicker in OpenHAB only sends RGB.



  • @TimO here is the output:

    2017-03-23 20:51:32.531 [INFO ] [ui.habmin.internal.servlet.HABminApp] - Started HABmin servlet at /habmin
    2017-03-23 20:51:33.754 [WARN ] [.discovery.MySensorsDiscoveryService] - Cannot automatic discover thing node: 0, child: 255 please insert it manually
    2017-03-23 20:51:33.772 [INFO ] [al.protocol.ip.MySensorsIpConnection] - Successfully connected to MySensors Bridge.
    

  • Hero Member

    @AndrewZ the message occurs right after startup and before the bridge gets connected?! Just ignore the message if everything else is working fine. 😄
    I'll release the refactored version soon. It's already available via the new IoT marketplace.



  • @TimO yes, message occurs on startup and I'm already using version from marketplace, I see it as market:binding-3328323 - 1.0


  • Hero Member

    @AndrewZ oh okay! I will look at it!


  • Hardware Contributor

    @TimO Cool, I'll test it once you are done. Domoticz only allows to either use the white channel or a RGB value (without the white) at the moment. Perhaps it can be done similarly in openhab.


  • Hero Member

    @LastSamurai Could you please take a look at this: https://github.com/tobof/openhab2-addons/issues/76 ?

    I've added the RGB & RGBW channels and because I'm not that confident about the RGBW implementation I'm kindly asking you to test the implementation and give me some feedback. 🙂
    The conversion from HSB, which is used by OpenHAB2 internally, to RGBW left me pretty confused. 😉


  • Hardware Contributor

    I'll test it. Might take some days to get to it though 😉



  • I found the solution myself. About a week ago i upgraded the binding. And it worked.
    Everything seems to work as it should. Except I can't recieve var1 (custom) for neither the hum or temp child.

    smartSleep is nice. I use it once an hour (regular sleep every minute) to get configurations from openhab about sleep time and other small things in the code.

    @balder88 said in openHAB 2.0 binding:

    Hey guys, first message on this forum. Been reading alot before. But now I have a problem I just can't solve.
    It's about smartsleep with openhab 2.
    Im using wifi gw rfm 69.
    Regular messages works as it should both ways.
    But it almost seems like the smartsleep isn't enabled in the binding.
    Here are my configs and logs.

    Things file:

    Bridge mysensors:bridge-eth:gw69 [ ipAddress="192.168.1.235", tcpPort=5003, sendDelay=100, enableNetworkSanCheck=true ] {
    //  Anarduino
        humidity        AnHum   [ nodeId="66", childId="0" ]
        temperature     AnTemp  [ nodeId="66", childId="1" ]
        light           light02 [ nodeId="66", childId="3", smartSleep=true ]
      }
    

    Items file:

    Switch  TestLight   "Test lampa" (Test) { channel="mysensors:light:gw69:light02:status" }
    

    Sketch: (Cleaned up the parts that dont matter, RTC and so on.)

    // Enable debug prints to serial monitor
    #define MY_DEBUG 
    
    // Enable and select radio type attached
    #define MY_RADIO_RFM69
    #define MY_IS_RFM69HW
    #define MY_NODE_ID 66
    #define MY_RFM69_NETWORKID 100
    #define MY_RFM69_FREQUENCY RF69_433MHZ
    #define MY_SMART_SLEEP_WAIT_DURATION_MS 1000
    #include <MySensors.h>
    #include <TimeLib.h>
    #include <Wire.h>
    #include <MCP7940RTC.h>
    #include <DHT.h>
    
    #define MCP7940_CTRL_ID 0x6F
    #define CSMEM_PIN 5
    
    #define LEDPIN 9
    
    long sleepIntervalSec=5;
    long loopCnt=0;
    uint8_t d[8];
    uint8_t dAlarm[8];
    int d1[8];
    
    // Set this to the pin you connected the DHT's data pin to
    #define DHT_DATA_PIN 6
    
    // Set this offset if the sensor has a permanent small offset to the real temperatures
    #define SENSOR_TEMP_OFFSET 0
    
    // Sleep time between sensor updates (in milliseconds)
    // Must be >1000ms for DHT22 and >2000ms for DHT11
    static const uint64_t UPDATE_INTERVAL = 5000;
    
    // Force sending an update of the temperature after n sensor reads, so a controller showing the
    // timestamp of the last update doesn't show something like 3 hours in the unlikely case, that
    // the value didn't change since;
    // i.e. the sensor would force sending an update every UPDATE_INTERVAL*FORCE_UPDATE_N_READS [ms]
    static const uint8_t FORCE_UPDATE_N_READS = 10;
    
    #define CHILD_ID_HUM 0
    #define CHILD_ID_TEMP 1
    #define CHILD_ID_MULTIMETER 2
    
    float lastTemp;
    float lastHum;
    uint8_t nNoUpdatesTemp;
    uint8_t nNoUpdatesHum;
    bool metric = true;
    
    MyMessage msgHum(CHILD_ID_HUM, V_HUM);
    MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP);
    MyMessage msgVolt(CHILD_ID_MULTIMETER, V_VOLTAGE);
    
    DHT dht;
    
    int BATTERY_SENSE_PIN = A0;  // select the input pin for the battery sense point
    int oldBatteryPcnt = 0;
    int batteryBasement = 812;
    int batteryFull = 922;
    float batteryConstant = 100.0 / (batteryFull - batteryBasement);
    float lastbatteryV = 0;
    
    const int buzzer = 7; //buzzer to arduino pin 7
    
    #define RELAY_1  8  // Arduino Digital I/O pin number for first relay (second on pin+1 etc)
    #define NUMBER_OF_RELAYS 1 // Total number of attached relays
    #define RELAY_ON 1  // GPIO value to write to turn on attached relay
    #define RELAY_OFF 0 // GPIO value to write to turn off attached relay
    
    void before()
    {
      for (int sensor=3, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
        // Then set relay pins in output mode
        pinMode(pin, OUTPUT);
        // Set relay to last known state (using eeprom storage)
        digitalWrite(pin, loadState(sensor)?RELAY_ON:RELAY_OFF);
      }
    }
    
    void setup()  
    {
       // use the 1.1 V internal reference
       analogReference(INTERNAL);
    
      pinMode(LEDPIN, OUTPUT);
      digitalWrite(LEDPIN, LOW);
      Wire.begin();
      pinMode(CSMEM_PIN, OUTPUT);
      digitalWrite(CSMEM_PIN, HIGH);
    
       dht.setup(DHT_DATA_PIN); // set data pin of DHT sensor
      if (UPDATE_INTERVAL <= dht.getMinimumSamplingPeriod()) {
        Serial.println("Warning: UPDATE_INTERVAL is smaller than supported by the sensor!");
      }
      // Sleep for the time of the minimum sampling period to give the sensor time to power up
      // (otherwise, timeout errors might occure for the first reading)
      sleepIntervalSec = dht.getMinimumSamplingPeriod();
      clearAlarm();
      delay(20);
      setNewAlarm();
      sleep(dht.getMinimumSamplingPeriod());
      analogRead(BATTERY_SENSE_PIN);
     }
    
    void presentation() {
       // Send the sketch version information to the gateway and Controller
       sendSketchInfo("Humidity sensor", "1.0");
       present(CHILD_ID_MULTIMETER, S_MULTIMETER, "VOLT", true);
       present(CHILD_ID_HUM, S_HUM, "HUMIDITY", true);
       present(CHILD_ID_TEMP, S_TEMP, "TEMP", true);
      for (int sensor=1, pin=RELAY_1; sensor<=NUMBER_OF_RELAYS; sensor++, pin++) {
        // Register all sensors to gw (they will be created as child devices)
        present(sensor, S_BINARY);
      }
      metric = getControllerConfig().isMetric;
    }
    
    
    void loop()
    {
      wait(100);
       int sensorValue = analogRead(BATTERY_SENSE_PIN);
       #ifdef MY_DEBUG
       Serial.println(sensorValue);
       #endif
       float batteryV  = sensorValue * 0.004551646;
       if(sensorValue < batteryBasement) {
        sensorValue = batteryBasement;
        batteryV = 0;
       }
       else if (sensorValue > batteryFull) {
        sensorValue = batteryFull;
       }
       int batteryPcnt = (sensorValue - batteryBasement) * batteryConstant;
           if ((abs(oldBatteryPcnt - batteryPcnt) > 1)) {
          sendBatteryLevel(batteryPcnt);
          oldBatteryPcnt = batteryPcnt;
        }
       
       if(batteryV != lastbatteryV) {
       send(msgVolt.set(batteryV, 2));
       lastbatteryV = batteryV;
       }
       #ifdef MY_DEBUG
       Serial.print("Battery Voltage: ");
       Serial.print(batteryV);
       Serial.println(" V");
       Serial.print("Battery percent: ");
       Serial.print(batteryPcnt);
       Serial.println(" %");
       #endif
    
      // Force reading sensor, so it works also after sleep()
      dht.readSensor(true);
    
      // Get temperature from DHT library
      float temperature = dht.getTemperature();
      if (isnan(temperature)) {
        Serial.println("Failed reading temperature from DHT!");
      } else if (temperature != lastTemp || nNoUpdatesTemp == FORCE_UPDATE_N_READS) {
        // Only send temperature if it changed since the last measurement or if we didn't send an update for n times
        lastTemp = temperature;
        if (!metric) {
          temperature = dht.toFahrenheit(temperature);
        }
        // Reset no updates counter
        nNoUpdatesTemp = 0;
        temperature += SENSOR_TEMP_OFFSET;
        send(msgTemp.set(temperature, 1));
        #ifdef MY_DEBUG
        Serial.print("T: ");
        Serial.println(temperature);
        #endif
      } else {
        // Increase no update counter if the temperature stayed the same
        nNoUpdatesTemp++;
      }
    
      // Get humidity from DHT library
      float humidity = dht.getHumidity();
      if (isnan(humidity)) {
        Serial.println("Failed reading humidity from DHT");
      } else if (humidity != lastHum || nNoUpdatesHum == FORCE_UPDATE_N_READS) {
        // Only send humidity if it changed since the last measurement or if we didn't send an update for n times
        lastHum = humidity;
        // Reset no updates counter
        nNoUpdatesHum = 0;
        send(msgHum.set(humidity, 1));
    
        #ifdef MY_DEBUG
        Serial.print("H: ");
        Serial.println(humidity);
        #endif
      } else {
        // Increase no update counter if the humidity stayed the same
        nNoUpdatesHum++;
      }
    long sleepTime = UPDATE_INTERVAL;
    if (batteryPcnt < 50) {
      sleepTime = (sleepTime * 2);
    }
      // Sleep for a while to save energy
      sleepIntervalSec = sleepTime / 1000;
      Serial.println();
      Serial.print("Setting new sleep time: ");
      Serial.print(sleepIntervalSec);
      Serial.println(" seconds.");
      clearAlarm();
      delay(20);
      setNewAlarm();
      smartSleep(sleepTime);
    
    }
    
    void receive(const MyMessage &message)
    {
      // We only expect one type of message from controller. But we better check anyway.
      if (message.type==V_STATUS) {
        // Change relay state
        digitalWrite(message.sensor-1+RELAY_1, message.getBool()?RELAY_ON:RELAY_OFF);
        // Store state in eeprom
        saveState(message.sensor, message.getBool());
        // Write some debug info
        Serial.print("Incoming change for sensor:");
        Serial.print(message.sensor);
        Serial.print(", New status: ");
        Serial.println(message.getBool());
      }
    }
    

    Sensor startup:

    0 MCO:BGN:INIT NODE,CP=RRNNA--,VER=2.1.1
    3 MCO:BGN:BFR
    4 TSM:INIT
    5 TSF:WUR:MS=0
    8 TSM:INIT:TSP OK
    9 TSM:INIT:STATID=66
    11 TSF:SID:OK,ID=66
    13 TSM:FPAR
    143 TSF:MSG:SEND,66-66-255-255,s=255,c=3,t=7,pt=0,l=0,sg=0,ft=0,st=OK:
    524 TSF:MSG:READ,0-0-66,s=255,c=3,t=8,pt=1,l=1,sg=0:0
    529 TSF:MSG:FPAR OK,ID=0,D=1
    2150 TSM:FPAR:OK
    2151 TSM:ID
    2152 TSM:ID:OK
    2154 TSM:UPL
    2161 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=24,pt=1,l=1,sg=0,ft=0,st=OK:1
    2181 TSF:MSG:READ,0-0-66,s=255,c=3,t=25,pt=1,l=1,sg=0:1
    2186 TSF:MSG:PONG RECV,HP=1
    2189 TSM:UPL:OK
    2190 TSM:READY:ID=66,PAR=0,DIS=1
    2199 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=15,pt=6,l=2,sg=0,ft=0,st=OK:0100
    2253 TSF:MSG:READ,0-0-66,s=255,c=3,t=15,pt=6,l=2,sg=0:0100
    2310 TSF:MSG:SEND,66-66-0-0,s=255,c=0,t=17,pt=0,l=5,sg=0,ft=0,st=OK:2.1.1
    2366 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=6,pt=1,l=1,sg=0,ft=0,st=OK:0
    2403 TSF:MSG:READ,0-0-66,s=255,c=3,t=6,pt=0,l=1,sg=0:M
    2461 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=11,pt=0,l=15,sg=0,ft=0,st=OK:Humidity sensor
    2562 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=12,pt=0,l=3,sg=0,ft=0,st=OK:1.0
    2618 TSF:MSG:SEND,66-66-0-0,s=2,c=0,t=30,pt=0,l=4,sg=0,ft=0,st=OK:VOLT
    2757 !TSF:MSG:SEND,66-66-0-0,s=0,c=0,t=7,pt=0,l=8,sg=0,ft=0,st=NACK:HUMIDITY
    2777 TSF:MSG:SEND,66-66-0-0,s=1,c=0,t=6,pt=0,l=4,sg=0,ft=1,st=OK:TEMP
    2912 !TSF:MSG:SEND,66-66-0-0,s=1,c=0,t=3,pt=0,l=0,sg=0,ft=0,st=NACK:
    2918 MCO:REG:REQ
    2974 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=26,pt=1,l=1,sg=0,ft=1,st=OK:2
    2991 TSF:MSG:READ,0-0-66,s=255,c=3,t=27,pt=1,l=1,sg=0:1
    2996 MCO:PIM:NODE REG=1
    2999 MCO:BGN:STP
    3154 MCO:SLP:MS=2000,SMS=0,I1=255,M1=255,I2=255,M2=255
    3160 MCO:SLP:TPD
    3161 MCO:SLP:WUP=-1
    3163 MCO:BGN:INIT OK,TSP=1
    

    Log Sensor: (This is when I press the button when the sensor is awake)
    It's sends away it's heartbeat correctly.

    125578 TSF:MSG:READ,0-0-66,s=3,c=1,t=2,pt=0,l=1,sg=0:0
    Incoming change for sensor:3, New status: 0
    
    Setting new sleep time: 5 seconds.
    137926 MCO:SLP:MS=5000,SMS=1,I1=255,M1=255,I2=255,M2=255
    137939 TSF:MSG:SEND,66-66-0-0,s=255,c=3,t=22,pt=5,l=4,sg=0,ft=0,st=OK:134932
    

    Log Openhab: And the gateway receives heartbeat.

    18:21:37.174 [DEBUG] [rs.internal.protocol.MySensorsWriter] - Sending to MySensors: 66;3;1;0;2;0
    18:21:37.178 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'TestLight' received command OFF
    18:21:37.181 [INFO ] [marthome.event.ItemStateChangedEvent] - TestLight changed from ON to OFF
    18:22:15.416 [DEBUG] [rs.internal.protocol.MySensorsReader] - 66;255;3;0;22;134932
    18:22:16.372 [DEBUG] [rs.internal.protocol.MySensorsWriter] - Sending to MySensors: 0;0;3;0;2;
    18:22:16.408 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;2;2.1.1
    

    Log Openhab: When the node sleeps..

    18:26:52.396 [DEBUG] [rs.internal.protocol.MySensorsWriter] - Sending to MySensors: 66;3;1;0;2;0
    18:26:52.397 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'TestLight' received command OFF
    18:26:52.399 [INFO ] [marthome.event.ItemStateChangedEvent] - TestLight changed from ON to OFF
    

    As you can see there is no mention in the openhab log file about buffering or smart sleep. Or a received heartbeat. Which it gets.
    What am I doing wrong?



  • First I want to thank you for this binding, got it working with my esp8266 gateway without any problems at all. However, I want to ask how the reconnection problem is developing, any plans to solve it or is it not possible? I've tried to scan the thread but didn't find any information regarding it.



  • Thanks for making this binding! 🙂

    One question, is there a specific reason motion (tripped) sensors have to be Contact items?
    In OH2 all the Z-wave motion sensors are Switches (AFAIK) so it would be nice if the mysensor PIR's could also be Switches so I can just add these to my existing motion sensor groups and rules.

    (I tried setting a triggered channel as Switch but it didn't work)



  • @Alpoy check this discussion on GitHub. The question is still open.

    @antonholmstedt reconnection is currently implemented in binding (look here). Feel free to open an issue if you experience reconnection fails in your environment 😃



  • @antonholmstedt reconnection is currently implemented in binding (look here). Feel free to open an issue if you experience reconnection fails in your environment 😃

    Yes I have reconnection problems right now, so will open an issue 🙂



  • I was checking back on this bindning and it really has matured!
    On GitHub I see that there are some updates referring to MqTT protocol.
    Are they available in the JAR that is posted here?
    http://www.oberfoell.com/openhab2/org.openhab.binding.mysensors-2.0.0-SNAPSHOT.jar

    Kudos on the great work!


  • Hero Member

    @Nicklas-Starkel Well no, MQTT Gateway is not yet supported. 😞
    I got distracted by my current hardware project and need to catch up on the binding. First tests of the MQTT addition to the binding look very promising and I'll include it soon.

    The current release is this one: http://www.oberfoell.com/openhab2/org.openhab.binding.mysensors-2.1.0-SNAPSHOT.jar

    While preparing the code to be included in OpenHAB2 I'm currently changing some things that will break the current configuration / things files. But I will give some information about that with the release of the next version.



  • Hi @TimO, @andreacioni.

    I am doing some "expert mode" rules where I need to get the NodeId of a specific sensors, or at least, to get all the configured Nodes Ids. Is that possible?

    I would like to cron a rule where every X minutes, heartbeat request message is sent to all configured nodes, so as to see wether they are alive or not.

    Thanks, regards.



  • Hi @gonzalonal 😃

    In the new version of binding we have implemented a (beta-)function that allows you to send heartbeat message at certain interval without the need to write your own rules.

    Please take a lock at this gateway-parameter (you must have set enableNetworkSanCheck=true and sanityCheckerInterval).

    With sanCheckSendHeartbeat parameter set you could also use this node-parameter to put your nodes offline after a certain number of failure.

    I hope this function will help you!



  • Hi @andreacioni . Thats a great feature.
    But for the moment, I think I prefer doing it manually, by rules, because of the way in which I can show my offline nodes in my sitemap and configure custom notifications for them.

    For each node, I have a datetime item showing the time of last heartbeat response received. If more than 25' have passed (5 heartbeats request, 1 heartbeat request each 5 mins) without response, I fire up a notification telling that that specific node has gone offline.

    So, back to my original question. Is there any way to get Node Ids at the rules engine?

    Do you believe we can customize this kind of behavior with the beta feature proposed?

    Thanks, regards.


  • Hero Member

    @gonzalonal I have no clue! Could be possible, but better ask at the OH2 community because the node Id is something that is specified in the thing description (xml) and maybe it is possible to access this information in rules.


  • Hardware Contributor

    Does this happen to support MQTT gateways? You mention serial or ethernet, but openhab doesn't support ethernet so i'm assuming you mean ethernet as the mqtt ethernet gateway?



  • Just few posts before 😉

    @TimO said in openHAB 2.0 binding:

    @Nicklas-Starkel Well no, MQTT Gateway is not yet supported. 😞
    I got distracted by my current hardware project and need to catch up on the binding. First tests of the MQTT addition to the binding look very promising and I'll include it soon.

    The current release is this one: http://www.oberfoell.com/openhab2/org.openhab.binding.mysensors-2.1.0-SNAPSHOT.jar

    While preparing the code to be included in OpenHAB2 I'm currently changing some things that will break the current configuration / things files. But I will give some information about that with the release of the next version.


  • Hardware Contributor

    I'm sorry, I ran a ctrl+f search and it either didn't show or i completely missed it, thank you for the prompt reply though.

    In this case then i will have to wait for this release then as i can't achieve what i need to do with rules. Do we have any idea when the release will be?



  • Hi, did anyone hit the problem when it seems that all works fine
    and then mysensors plugin start to think that it failed connecting to bridge (even if it doesnt actually)

    Should I find newer version (last jar I found is since 2017-01-18)

    I put message from node every 1 second, and in log you will see "0;255;3;0;9;TSF:MSG:READ...." every second
    but every 10 second it recconects saying "Failed connecting to bridge...next retry in 10 seconds (Retry No.:31).... Shutting down serial connection!...

    17:40:21.656 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;9;TSF:MSG:READ,202-202-0,s=1,c=1,t=37,pt=2,l=2,sg=0:468
    17:40:21.657 [DEBUG] [rs.internal.protocol.MySensorsReader] - 202;1;1;0;37;468
    17:40:22.421 [ERROR] [col.serial.MySensorsSerialConnection] - Can't connect to serial port. Wrong port?
    17:40:22.424 [ERROR] [col.serial.MySensorsSerialConnection] - Failed connecting to bridge...next retry in 10 seconds (Retry No.:31)
    17:40:22.425 [DEBUG] [col.serial.MySensorsSerialConnection] - Shutting down serial connection!
    17:40:22.842 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;9;TSF:MSG:READ,202-202-0,s=1,c=1,t=37,pt=2,l=2,sg=0:486
    17:40:22.844 [DEBUG] [rs.internal.protocol.MySensorsReader] - 202;1;1;0;37;486
    17:40:24.029 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;9;TSF:MSG:READ,202-202-0,s=1,c=1,t=37,pt=2,l=2,sg=0:470
    17:40:24.032 [DEBUG] [rs.internal.protocol.MySensorsReader] - 202;1;1;0;37;470
    17:40:25.218 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;9;TSF:MSG:READ,202-202-0,s=1,c=1,t=37,pt=2,l=2,sg=0:474
    17:40:25.222 [DEBUG] [rs.internal.protocol.MySensorsReader] - 202;1;1;0;37;474
    17:40:26.406 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;9;TSF:MSG:READ,202-202-0,s=1,c=1,t=37,pt=2,l=2,sg=0:486
    17:40:26.407 [DEBUG] [rs.internal.protocol.MySensorsReader] - 202;1;1;0;37;486
    17:40:27.591 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;9;TSF:MSG:READ,202-202-0,s=1,c=1,t=37,pt=2,l=2,sg=0:466
    17:40:27.592 [DEBUG] [rs.internal.protocol.MySensorsReader] - 202;1;1;0;37;466
    17:40:28.783 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;9;TSF:MSG:READ,202-202-0,s=1,c=1,t=37,pt=2,l=2,sg=0:483
    17:40:28.786 [DEBUG] [rs.internal.protocol.MySensorsReader] - 202;1;1;0;37;483
    17:40:29.967 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;9;TSF:MSG:READ,202-202-0,s=1,c=1,t=37,pt=2,l=2,sg=0:483
    17:40:29.972 [DEBUG] [rs.internal.protocol.MySensorsReader] - 202;1;1;0;37;483
    17:40:31.158 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;9;TSF:MSG:READ,202-202-0,s=1,c=1,t=37,pt=2,l=2,sg=0:463
    17:40:31.163 [DEBUG] [rs.internal.protocol.MySensorsReader] - 202;1;1;0;37;463
    17:40:32.344 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;9;TSF:MSG:READ,202-202-0,s=1,c=1,t=37,pt=2,l=2,sg=0:487
    17:40:32.346 [DEBUG] [rs.internal.protocol.MySensorsReader] - 202;1;1;0;37;487
    17:40:32.431 [DEBUG] [col.serial.MySensorsSerialConnection] - Connecting to /dev/ttyUSB0 [baudRate:115200]
    17:40:32.435 [DEBUG] [col.serial.MySensorsSerialConnection] - Final port list: /dev/ttyUSB0
    17:40:33.530 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;9;TSF:MSG:READ,202-202-0,s=1,c=1,t=37,pt=2,l=2,sg=0:470
    17:40:33.533 [DEBUG] [rs.internal.protocol.MySensorsReader] - 202;1;1;0;37;470
    17:40:34.438 [ERROR] [col.serial.MySensorsSerialConnection] - Can't connect to serial port. Wrong port?
    17:40:34.440 [ERROR] [col.serial.MySensorsSerialConnection] - Failed connecting to bridge...next retry in 10 seconds (Retry No.:32)
    17:40:34.441 [DEBUG] [col.serial.MySensorsSerialConnection] - Shutting down serial connection!
    17:40:34.720 [DEBUG] [rs.internal.protocol.MySensorsReader] - 0;255;3;0;9;TSF:MSG:READ,202-202-0,s=1,c=1,t=37,pt=2,l=2,sg=0:472
    


  • @Igor-Antolić huh,... my mistake, just installed 2.1.0 instead of 2.0.0. It seems it is from 2017-03-07.

    I dont have a good way to find last version of lib. Any suggestion how to check if last stabile version of mysensors java lib?


  • Hero Member

    @Igor-Antolić I'm glad it worked after the update!

    It currently is not possible to automatically update (or check) for the most recent version. There are currently two sources for the binding:

    • the IoT Marketplace
    • The link in the wiki on github

    The most convenient way is the integration in the official openhab2-plugins repository and I'm working on it, but I still have a lot of homework to do.

    Maybe the IoT Marketplace will soon support such mechanisms, there are a few extensions planned.


  • Hero Member

    @Samuel235 said in openHAB 2.0 binding:

    In this case then i will have to wait for this release then as i can't achieve what i need to do with rules. Do we have any idea when the release will be?

    What is it, what you want to achieve? I'm running MQTT too, as a connection between OpenHAB2 and nodered (50% of my rules are now nodered based). My gateways are serial or ethernet based.

    serial / ethernet gateway
    <->
    OpenHAB2 binding
    <->
    MQTT Event bus
    <->
    nodered

    @Samuel235 Are you willing and have the ability to test the MQTT implementation of the binding? Any help is really appreciated!



  • Guys,

    I am getting this in Karaf :

    16:20:33.171 [WARN ] [thome.io.rest.core.item.ItemResource] - Received HTTP PUT request at 'items/MySensorsDevice21_Lock' with an invalid item type 'Status'.
    

    and this in PaperUI

     "ERROR : undefined - undefined"  "some error occured"
    

    when trying to link "Lock status" of an rfid node to an item in PaperUI...

    Is that anything to do with the binding ? Or shall i ask eslewhere ?

    Thanks a lot for your help (in general as well 😉 )


  • Hardware Contributor

    @TimO - I have implemented a work-around for the issue that i was facing. OpenHAB just can't handle a empty MQTT message, so there is a fix for the pulse sensor to work with OpenHAB by changing the message that it send over to the MQTT server.

    If you're interested in how this is done, please refer to: https://forum.mysensors.org/topic/3088/pulse-power-meter-with-openhab/4

    I will be documenting this in possibly better to read steps for people when I get chance to finish the documentation to my new hardware node for the Pulse Sensor.



  • @LastSamurai
    Hello, i'am trying to connect a RGBW node by the serial gateway, is there already a solution for the hexstring format in the bindings or do we need to handle the rgbw items separatly ?
    kind regards
    Roger


  • Hero Member

    @RVMRVM could you give this one a try?

    https://github.com/tobof/openhab2-addons/issues/76

    It is not yet integrated into the main branch. If you could test it and give me some feedback I would be very grateful. 🙂


  • Hardware Contributor

    @RVMRVM Sorry I haven't had the time to test anything yet (was working on another project). Might take me a while to get to.



  • @patrick-schaerer
    hi patrick
    i follow your guide with command to install MPC23017 Binding on openhab2
    sudo chmod openhab.openhab /usr/share/openhab2/addons/org.openhab.binding.mcp23017-1.9.0.jar
    but it not work and has information" chmod: invalid mode: ‘openhab.openhab’
    then i take ":" instead of "." into account like
    sudo chmod openhab:openhab /usr/share/openhab2/addons/org.openhab.binding.mcp23017-1.9.0.jar
    but it same error
    0_1496478264776_upload-ff8c1fc1-81fa-4e92-9e2d-46d4d7ca3f33
    can you help me, please.
    thanks you


  • Hero Member

    @the-trung This thread is OpenHAB and MySensors binding related. Better ask here: https://community.openhab.org

    In your case I suppose you need to switch chmod with chown. 🙂



  • I am trying to make use of the customSensor using org.openhab.binding.mysensors-2.1.0-SNAPSHOT.jar I see the node 12 var4 message arrive but it is not being assigned to my item; am I doing something wrong? I have tried both string and number item types.

    10:37:37.879 [DEBUG] [rsAbstractConnection$MySensorsReader] - 12;0;1;0;27;1023
    10:37:37.880 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 12 found in gateway
    10:37:37.881 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 0 found in node 12
    10:37:37.882 [DEBUG] [ensors.handler.MySensorsThingHandler] - Updating channel: var4(27) value to: 1023
    10:37:37.896 [DEBUG] [ensors.handler.MySensorsThingHandler] - Setting last update for node/child 12/0 to 2017-06-03T10:37:37.000-0400
    10:37:37.901 [DEBUG] [rsAbstractConnection$MySensorsReader] - 12;255;3;0;22;63464
    10:37:37.912 [INFO ] [marthome.event.ItemStateChangedEvent] - Sensor12LastUpdate changed from 2017-06-03T10:37:26.000-0400 to 2017-06-03T10:37:37.000-0400
    10:37:37.925 [INFO ] [marthome.event.ItemStateChangedEvent] - mySMsg01 changed from 1;4;1;0;1;64.2 to 12;0;1;0;27;1023
    10:37:37.935 [INFO ] [marthome.event.ItemStateChangedEvent] - mySMsg01 changed from 12;0;1;0;27;1023 to 12;255;3;0;22;63464
    10:37:41.974 [DEBUG] [rsAbstractConnection$MySensorsReader] - 2;0;1;0;17;544
    10:37:41.975 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 2 found in gateway
    10:37:41.976 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 0 found in node 2
    10:37:41.976 [DEBUG] [ensors.handler.MySensorsThingHandler] - Updating channel: watt(17) value to: 544
    10:37:41.984 [DEBUG] [ensors.handler.MySensorsThingHandler] - Setting last update for node/child 2/0 to 2017-06-03T10:37:41.000-0400
    10:37:41.995 [INFO ] [marthome.event.ItemStateChangedEvent] - watt01 changed from 547 to 544
    10:37:42.005 [DEBUG] [rsAbstractConnection$MySensorsReader] - 2;0;1;0;24;1138982
    10:37:42.006 [INFO ] [marthome.event.ItemStateChangedEvent] - Sensor02LastUpdate changed from 2017-06-03T10:37:27.000-0400 to 2017-06-03
    

    Things

    Bridge mysensors:bridge-eth:ethGatewayPi [ ipAddress="127.0.0.1", tcpPort=5003, sendDelay=200 ]
    {
       /** define things connected to that bridge here */
       humidity         hum01       [ nodeId="1", childId="0" ]
       temperature      temp01      [ nodeId="1", childId="1" ]
       humidity         hum02       [ nodeId="1", childId="2" ]
       temperature      temp02      [ nodeId="1", childId="3" ]
       humidity         hum03       [ nodeId="1", childId="4" ]
       temperature      temp03      [ nodeId="1", childId="5" ]
       power            power01     [ nodeId="2", childId="0" ]
       rgbLight         rgb02       [ nodeId="6", childId="0", requestAck=true ]
       light            relay01     [ nodeId="7", childId="0", requestAck=true ]
       motion           motion01    [ nodeId="8", childId="0", requestAck=true ]
       motion           motion02    [ nodeId="9", childId="0", requestAck=true ]
       light            relay02     [ nodeId="9", childId="1", requestAck=true ]
       cover            cover03     [ nodeId="10", childId="0", requestAck=true, smartSleep=true ]
       cover            cover02     [ nodeId="11", childId="0", requestAck=true, smartSleep=true ]
       customSensor     blind01     [ nodeId="12", childId="0", requestAck=true, smartSleep=true ]
       mySensorsMessage mySMsg01    [ nodeId="999", childId="999" ]
    }
    

    items:

    String blind1BatReading	    "Blind#1 Battery A/D Reading"  	<battery>			{ channel="mysensors:customSensor:ethGatewayPi:blind01:var4" }										
    DateTime Sensor12LastUpdate "Last seen Nd12 [%1$ta %1$tT]"       <clock>    	{ channel="mysensors:customSensor:ethGatewayPi:blind01:lastupdate" }
    

    edit 6/7: I stand corrected, the variables are being updated. I was fooled by the log. For some reason the log does not show the change the way it did it binding 2.0.0. I placed debug messages in my rules and they're updating.



  • @TimO is it possible to configure using paper ui?

    cheers
    Matt



  • @TimO
    I follow your guid and it's ok, then i checks karaf and see there 0_1496630110147_karaf2.png
    is this mean i installed my binding?
    and i have question
    did you fix error : Unable to install bundle openhab-transport-serial
    thanks you so much


  • Hero Member


  • Hero Member

    @carlyler thank you for filing an issue, I'll look into it.


  • Hero Member

    @the-trung yes, the binding seems to be installed. Serial transport is needed for MySensors. I'm not able to answer questions about mcp binding.



  • @TimO Hey Tim, before i start test , i have installed OH2.1 build #925 on 2 new W8 pc's.
    download the org.openhab.binding.mysensors-2.1.0-SNAPSHOT.jar file and put it in the addons folder.
    result:
    2017-06-10 15:01:27.812 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at /start
    2017-06-10 15:01:27.922 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
    2017-06-10 15:01:28.031 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
    2017-06-10 15:01:28.250 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
    2017-06-10 15:01:28.281 [ERROR] [org.openhab.binding.mysensors ] - FrameworkEvent ERROR - org.openhab.binding.mysensors
    org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.mysensors [182]
    Unresolved requirement: Import-Package: gnu.io

    at org.eclipse.osgi.container.Module.start(Module.java:434)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1562)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1476)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
    at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
    at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]
    

    i cannot start the mysensors binding ...

    i have installed it on 3 diff pc's, same result , can you help mee with this, i'am stucked ..

    thanks in advance
    kind regards



  • @RVMRVM

    Did you run feature:install openhab-transport-serial, on OH console?



  • Oh yes, i dit not, that was the problem, now i can start to test the RGB-RGBW , hope that i can run this
    thanks for the quit reaction
    Roger



  • @TimO Hello, i tried the RGB & RGBW , it looks ok but there are no commands that been send to the node and this for every item, a'im new in the openHab world, so that will be the problem.
    the result is the same for RGB & RGBW
    my .things file:

    Bridge mysensors:bridge-eth:gateway [ ipAddress="192.168.2.190", tcpPort=5003, sendDelay=200 ] {
    /** define things connected to that bridge here */
    light:RGBW_23_Status [ nodeId="23", childId="0", requestAck=false]
    rgbwLight:RGBW_23_Color [ nodeId="23", childId="1", requestAck=false ]
    dimmer:RGBW_23_Dimmer [ nodeId="23", childId="2", requestAck=false ]
    }

    my .items file:

    Group GF_Living "Living Room" <video> (gGF)

    /* Indoor Temperatures */
    //Number Temperature_GF_Living "Temperature [%.1f °C]" <temperature> (Temperature, GF_Living)

    Switch RGBW_23_Status "Living" (GF_Living, Lights) { channel="mysensors:bridge-eth:gateway:RGBW_23_Status"}
    Dimmer RGBW_23_Dimmer "Living" <slider> (GF_Living, Lights) ["Lighting"] { channel="mysensors:bridge-eth:gateway:RGBW_23_Dimmer"}
    Color RGBW_23_Color "RGBW Light" <colorwheel> {channel = "mysensors:bridge-eth:gateway:RGBW_23_Color"}

    and my .sitemap file
    sitemap rvms label="test rvms"
    {
    Frame label="RGBW Living" {
    Switch item=RGBW_23_Status label="Button Switch" mappings=[ON="on",OFF="off"]
    Slider item=RGBW_23_Dimmer switchSupport
    Colorpicker item=RGBW_23_Color
    }
    }

    as result we have:
    0_1497172964239_upload-df31d06d-cc9b-47df-9583-831a701cdeed
    and in the paperUI:
    0_1497173108301_upload-088cd943-2a85-4ad4-9197-b76b075f4ffe
    this is what the log-file shows:
    2017-06-11 09:50:48.187 [INFO ] [.dashboard.internal.DashboardService] - Started dashboard at /start
    2017-06-11 09:50:51.161 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'rvms.items'
    2017-06-11 09:50:52.088 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'rvms.sitemap'
    2017-06-11 09:50:52.187 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'rvms.things'
    2017-06-11 09:50:52.978 [INFO ] [basic.internal.servlet.WebAppServlet] - Started Basic UI at /basicui/app
    2017-06-11 09:50:53.006 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
    2017-06-11 09:50:53.073 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
    2017-06-11 09:50:53.404 [INFO ] [assic.internal.servlet.WebAppServlet] - Started Classic UI at /classicui/app
    2017-06-11 09:50:53.555 [WARN ] [.discovery.MySensorsDiscoveryService] - Cannot automatic discover thing node: 0, child: 255 please insert it manually
    2017-06-11 09:50:53.558 [INFO ] [al.protocol.ip.MySensorsIpConnection] - Successfully connected to MySensors Bridge.
    2017-06-11 09:55:56.976 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'rvms.things'
    2017-06-11 09:55:56.988 [WARN ] [rsAbstractConnection$MySensorsWriter] - Interrupted MySensorsWriter
    2017-06-11 09:55:56.989 [WARN ] [rsAbstractConnection$MySensorsReader] - Interrupted MySensorsReader
    2017-06-11 09:55:58.010 [WARN ] [.discovery.MySensorsDiscoveryService] - Cannot automatic discover thing node: 0, child: 255 please insert it manually
    2017-06-11 09:55:58.020 [INFO ] [al.protocol.ip.MySensorsIpConnection] - Successfully connected to MySensors Bridge.
    2017-06-11 10:08:57.483 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'rvms.sitemap'

    so what is wrong here ?
    thanks in advance
    Roger



  • Hi @TimO,

    I also tried the RGB Light and it seems to be working! (I am using Maghac's RGB LED strip sketch)
    Auto discovery worked instantly. I did have to work with the .items file to get the color picker instead of a text input. I also get these two errors every time I send a command:

    16:57:36.770 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'rgbLight01' received command 124,89,100
    16:57:36.809 [INFO ] [marthome.event.ItemStateChangedEvent] - rgbLight01 changed from 359,91,100 to 124,89,100
    16:57:37.117 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable 2 not present
    16:57:37.222 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable 3 not present
    

    As I'm relatively new to MySensors, I was wondering if it is normal that the RGB Light Sensor channel is used for this. Or is this just temporary until an actual RGB channel is made?



  • I've been trying to figure this out for a while. For me openhab discovers 4 things Red, Green, Blue and Status. These are all dimmers and I can't get them all to work together as 1 colour wheel? They all work really well independently but that's as far as I got. I've also tried the .items file but with no luck.



  • Hello!
    I just started to play with OpenHab2 and new binding? thank you for great work.
    But, i discover some strange behavior:
    Openhab2, ethernet gateway, 3 mysensor nodes, all nodes sucessfully detected and configured in PaperUI, but some data looks like not updated. Looking to log i note some suspicious lines like:

    00:28:47.077 [DEBUG] [rsAbstractConnection$MySensorsReader] - 3;1;1;0;0;24.6
    00:28:47.078 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 3 found in gateway
    00:28:47.078 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 1 found in node 3
    00:28:47.078 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable 0 not present
    

    Sorry, i don't know how to dump OpenHab configuration, but item configured.
    Any suggestions?



  • @matt-shepherd What works for me :
    items - just used 1 channel, V_VAR1, but you could keep them separate

    String neoPixelRgb           "RGB LED string"                           (grpLighting)  { channel="mysensors:rgbLight:ethGateway:rgb01:var1" }
    Color neoPixelColor         "RGB LED string"            <colorwheel>    (grpLighting)
    

    rule

    rule "Set RGB value NeoPixelStrip"
    when
        Item neoPixelColor changed
    then
        val hsbValue = neoPixelColor.state as HSBType
    
        val brightness = hsbValue.brightness.intValue
        val redValue = ((((hsbValue.red.intValue * 255) / 100) * brightness) / 100)
        val grnValue = ((((hsbValue.green.intValue * 255) / 100) * brightness) / 100)
        val bluValue = ((((hsbValue.blue.intValue * 255) / 100) * brightness) / 100)
    
        val rgbHexString = String::format("%02X%02X%02X", redValue, grnValue, bluValue)
        sendCommand(neoPixelRgb, rgbHexString)
    end
    
    

    parsed in node

      if (message.type == V_VAR1)
      {
        // Write some debug info
        Serial.print(", New status, V_RGB: ");
        Serial.println(message.getString());
    
        // starting to process the hex code
        String hexstring = message.getString(); //here goes the hex color code coming from through MySensors (like FF9A00)
        long number = (long) strtol( &hexstring[0], NULL, 16);
        RGB_values[0] = number >> 16;
        RGB_values[1] = number >> 8 & 0xFF;
        RGB_values[2] = number & 0xFF;
    
        colorWipe(strip.Color(RGB_values[0], RGB_values[1], RGB_values[2]), 50);
      }
    


  • @TimO Hey all, looks everything seems to work now, but now i have defined the bindings by the paper UI, and work with the rule definition as show by 'doctor64' ....
    thanks for the help
    Roger


  • Hero Member

    @FusedHe3 Thank you for testing and your input!

    The sketch you are using is representing itself as a RGB sensor and the log you've posted looks good.

    About the fiddling with the .items file and the color picker: Thank you! That should'nt be needed anymore, I've changed it here: RGB-Test-Binding


  • Hero Member

    @RVMRVM The definitions carlyler posted looks fine and I've tried to implement this logic into the binding so you won't need the rule anymore. Feel free to test my binding or stay with the rule. Hopefully both would lead to the same result. 🙂


  • Hero Member

    Hey @doctor64 !

    Please open a new topic. This one is getting really huge. 🙂

    Please check if the temperature channel is linked. In PaperUI you may do this by moving to "Configuration" -> "Things" and click on the sensor data.



  • @TimO No problem, glad to help!

    I'll try to alter the sketch and use the new version of the binding as soon as I have my LED strip running again.



  • @TimO Perfect, is OK for RGB & RGBW... but now the datastring you send is a decimal string, not a HEX-string as they used normal, it is not a big problem to change this feature in the node script, if you want to have a decimal string.
    How do you handle the white color, becaus this is not included in the datastring info. maybe by a switch and a other variable .
    something like this:

    0_1497272329084_upload-bc139de4-29ff-4760-ac5e-7746249546fc

    Roger


  • Hero Member

    @RVMRVM Interesting. Do you have a corresponding log for me?

    Here's my test:

    [INFO ] [arthome.event.ItemCommandEvent:43   ] - Item 'mysensors_rgbLight_8a7ca179_rgblight_199_0_rgb' received command 71,46,91
    [DEBUG] [.c.thing.internal.ThingManager:366  ] - Delegating command '71,46,91' for item 'mysensors_rgbLight_8a7ca179_rgblight_199_0_rgb' to handler for channel 'mysensors:rgbLight:8a7ca179:rgblight_199_0:rgb'
    [DEBUG] [.m.c.MySensorsRGBTypeConverter:63   ] - Converting RGB Int to Hex: R d4, G e8, B 7d
    [DEBUG] [b.m.i.gateway.MySensorsGateway:563  ] - Node 199 found in gateway
    [DEBUG] [b.m.i.gateway.MySensorsGateway:567  ] - Child 0 found in node 199
    [DEBUG] [ractConnection$MySensorsWriter:524  ] - Sending to MySensors: 199;0;1;0;40;d4e87d
    


  • @TimO this is the log of the node:
    15:33:19.326> 15054 TSF:MSG:READ,0-0-23,s=1,c=1,t=26,pt=0,l=10,sg=0:231,81,100
    this is the result from the rule routine:
    15:39:17.479> 10919 TSF:MSG:READ,0-0-23,s=1,c=1,t=26,pt=0,l=6,sg=0:FF5E28



  • Hello @TimO !
    I delete all things and items (btw, seems like items not deleted completely, and re-apperas after item re-create), create things again and not see error anymore. Some black magic in action, looks like.
    I will create separate topic if this issue appears again. Thank you!



  • @TimO Just tried the changes you made. Color picker now worked straight away! 😄

    I also checked the sketch and it seems to be declaring itself as an RGB Light, not as a sensor. But could it be that what I see in the PaperUI are just the labels that still need to be changed?

    void presentation()
    {
      // Send the Sketch Version Information to the Gateway
      sendSketchInfo(SN, SV);
      present(CHILD_ID_LIGHT, S_RGB_LIGHT);
    }
    


    One last question: the Variable 2 not present error I get everytime a command is send, is that because those two variables aren't set in the sketch I'm using?

    Thanks!



  • Hi,

    just a quick question:
    OpenHab2 can be used without touching any code right?
    I use mysensors serial gateway. Tried to set it up all day yesterday from skratch. Also with OpenHabian. But no success.
    So it seems i still have to edit files and folders manually in order to get it running right?

    I got Domoticz working after short time. Was expecting OpenHab2 makes it even more easy 😕


  • Hero Member

    @FusedHe3 Please enable DEBUG mode in the karaf console and paste the output around Variable 2 not present here.


  • Hero Member

    @edsteve Yes, that's one goal of the binding. For the serial gateway the hardest part is to determine the path of the serial port. Something like: /dev/ttyUSB0 or /dev/ttyACM0 if you're using Linux.

    What exactly does not work? Please attach a log from the karaf console.



  • @TimO
    I use Nano Neo as Hardware with Armbian Linux and OpenHabian on top. The bundle:list showed me mysensors.
    I don't find any Things. Where do i have to put this info: /dev/ttyUSB0 or /dev/ttyACM0?? In which config file?
    Now i get an error with karaf saying "connection refused" when i try:

    ssh -p 8101 openhab@localhost
    

    Yesterday it worked... the karaf thing make it even more difficult.

    EDIT: I just found out that i have to make a demo.things file with the code for the serial gateway.... And for sure that was not the last file which needs manual editing. I go back to Domoticz. Till OpenHab becomes same easy.



  • @TimO Thanks for investigating!
    Here's the log, but I don't know if it's of any more help.

    18:36:25.233 [DEBUG] [.converter.MySensorsRGBTypeConverter] - Converting RGB Int to Hex: R 05, G 71, B ff
    18:36:25.295 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 10 found in gateway
    18:36:25.321 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 1 found in node 10
    18:36:25.408 [INFO ] [marthome.event.ItemStateChangedEvent] - RGBLEDStrip_Color changed from 15,100,100 to 214,98,100
    18:36:25.346 [DEBUG] [rsAbstractConnection$MySensorsWriter] - Sending to MySensors: 10;1;1;0;40;0571ff
    18:36:25.365 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'RGBLEDStrip_Color' received command 214,98,100
    18:36:25.840 [DEBUG] [rsAbstractConnection$MySensorsReader] - 10;1;1;0;2;1
    18:36:25.863 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 10 found in gateway
    18:36:25.895 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 1 found in node 10
    18:36:25.919 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable 2 not present
    18:36:26.209 [DEBUG] [rsAbstractConnection$MySensorsReader] - 10;1;1;0;3;100
    18:36:26.232 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Node 10 found in gateway
    18:36:26.254 [DEBUG] [rs.internal.gateway.MySensorsGateway] - Child 1 found in node 10
    18:36:26.276 [WARN ] [rs.internal.gateway.MySensorsGateway] - Variable 3 not present
    

    I guess it may have something to do with a V_light and V_dimmer answer that is being send by the node. (As a reminder: I'm using this this one.)


  • Hardware Contributor

    @TimO So I finally got around to testing the RGBW version of the plugin. I tested it with one sensor (light and the battery voltage) and an RGBW node.
    0_1497559852937_upload-304efabd-cb8d-431a-8287-a6203833c303

    Results:

    • RGBW color settings works well. Its a message of lengths 8 (e.g. 00ff5100) instead of the 9 from domoticz (#00ff5100). So I had to change my node's code. But your solution looks cleaner, so I guess thats fine 👍 What didn't work are all the other values beside "color". As you can see I changed the variable 1-4 and it gets send to the node as message type 24-27, which are custom variables... why did you use these?
    • RGBW on/off did not work. The "status" button does nothing. Log below. Would be nice to have a button to send on/off commands to the nodes.
    • Light and Voltage sensors seem to work just fine

    By the way, short question about openhab 2: what is the difference between things and items? Seems like items/sitemaps are used in the "old" frontends to display sensors/actors. Are things the same for the new paperUI? I have just used that one yet. And why do I have to declare the gateway in a file while the rest is auto discovered (also it seems like some of you also added their sensors to the file with the gateway definition)?
    Seems to be hard to find up-to-date easy information on these things, so thanks in advance for an explanation.

    Log from the status button:

    22:55:02.378 [INFO ] [smarthome.event.ItemCommandEvent    ] - Item 'mysensors_rgbwLight_gateway_rgbwlight_10_1_status' received command OFF
    22:55:02.402 [WARN ] [ensors.handler.MySensorsThingHandler] - Variable not found, cannot handle command for thing mysensors:rgbwLight:gateway:rgbwlight_10_1 of type status
    22:55:02.440 [INFO ] [marthome.event.ItemStateChangedEvent] - mysensors_rgbwLight_gateway_rgbwlight_10_1_status changed from ON to OFF
    

  • Hardware Contributor

    By the way has someone running openhab together with an echo (alexa)? I am currently trying to use that combination and at least with the RGBW nodes there seems to be no reaction (yet) to the commands.



  • 0_1497733545612_upload-12d1dea2-7f4f-4571-9891-5ca9c8864170
    Hello,
    With 2 nodes, first has 1 child with id 0 , second has 2 children, id 0 and id 1, I get the following in the logs. Second node is not picked up.
    Used the openhab2 zip and the jar from here http://www.oberfoell.com/openhab2/org.openhab.binding.mysensors-2.1.0-SNAPSHOT.jar for the installation.
    All the configuration was done from the paperui.
    Any thoughts ?
    Best regards,
    Romeo


  • Hero Member

    @frg Please enter log:set DEBUG org.openhab.binding.mysensors in the karaf console and post the debug log of the binding here.


  • Hero Member

    @LastSamurai Thank you for the feedback!!

    I'm glad RGBW seems to work. 🙂
    RGBW status indeed wasn't working, that definately was a bug and is fixed now (for RGB too).

    About your general questions:

    You don't have to define the gateway in the things file. It is not discovered automatically, as this is something that is not very easy to implement (i.e. search for serial connections on windows / linux, search for network devices, is it a gateway or not?)
    You may just use PaperUI: Configurations -> Things and hit the white plus sign in the blue circle and select serial or ethernet gateway. 🙂

    When it comes to things and items: for me, a thing is a sensor. For example the RGBW sensor is a thing in the OpenHab world. There are a few channels (children) that are frequently found, when this sensor is used: one channel for RGBW, one for status and occasionally var1-var4 and battery. The thing is defined by its channels. The thing is a representation of the hardware in this case.
    The items are the representation for the UI and the user. The user uses the Color picker and the thing/hardware needs a string (#aabbccdd). There may be "hardware" behind an item but there is no need to. An example is the lastUpdate channel/item. The information is not send by the sensor, it is generated by the controller/binding.



  • This post is deleted!


  • @Timo
    I attached the file.
    https://notebin.cc/1jhks38r3sw
    If there is something else you need me to do let me know.


  • Hero Member

    @frg Okay, this is interesting. 😄
    After reviewing your log, I have no idea why this message still appears. There are 7 incoming presentation messages, all handled before. After about four minutes after the last presentation message was received there are 7 warnings about already presented childs. I don't see that behaviour in my log.
    It's nothing serious we need to worry about, maybe the category "WARN" is exaggerated for this message. 😉 I'll look for that behaviour in my system, so that I may be able to reproduce it, but at the moment I don't see anything I am able to do here.



  • This post is deleted!


  • @TimO , did you ever get MQTT to work or do you need someone to test?


  • Hero Member

    Hey @Nicklas-Starkel !

    Actually there is a PR for MQTT support which is a huge leap forward and needs testing: https://github.com/tobof/openhab2-addons/pull/75

    I'm 90% done on fulfilling the OH2 development compliance: https://github.com/openhab/openhab2-addons/pull/2066 which I'm working on since weeks (months). 😮

    My road map is:

    1. Finish the work on the compliance. (Maybe this week, for sure next week)
    2. Move repository to 2.2.0 snapshot
    3. Integrate RGB(W)
    4. Integrate MQTT

    RGB(W) needs some more attention, because there is a bug in the conversion and it needs some more testing.

    The current work is a second refactoring with many changes. Also a few options (names) have changed which need some attention by the users because configurations need to be adjusted. Hopefully the names now speak more for itself. 🙂
    I've also extended the JUnit Testing of the binding (which I'll need to quickly fix the RGB(W) bug).

    I need to catch up with the development of the openhab2-addons base. This is done after the OH2 compliance is done. At the moment I can't compile a MQTT testversion of the binding because the repository needs to be moved to 2.2.0 Snapshot.

    Sadly the process for OH2 compliance is at the moment blocking the enhancements of the binding. I had no idea this would take so long.



  • Hello forum! I am very new with mySensors and OpenHAB (you've heard it before). I have OpenHab 2.1 running on Raspberri Pi2. I configured Z-wave binding, things and a few items, and it works fine. Now I am trying to bind OpenHab to a serial gateway build with Arduino Nano. The default example sketch is loaded to Arduino. The latest v2.1.0 mySensors .jar is placed in \openhab2-addons. I configured serial port as /dev/pts/2 but Gateway is offline. I tried to reboot Raspberry, Arduino but mySensors gateway is always offline, while Z-wave is online and operational. What am I doing wrong?


  • Hero Member

    @APL2017 The device is definitely wrong. It should be something like /dev/ttyUSB1. Execute dmesg in the console and look for usb, ch340, ch341 or ft232. 🙂



  • @TimO said in openHAB 2.0 binding:

    dmesg

    Thank you! When I entered serial ports as /dev/ttyUSB0, as reported by dmesg, the mySensors serial gateway binding came alive in OpenHAB. Initially, I got confused by instructions how to setup gateway in https://github.com/tobof/openhab2-addons/wiki/Configuration where I spotted serialPort="/dev/pts/2"



  • Hello i installed openhab 2.1 and the openhab jar 2.1 file in addons directory the gateway (serial) is up and running, in the log i see the senors !! but the autodiscovery stops the second i start it and wont show anny sensors but i do see them in the log if i replace the 2.1 jar with the 2.0 jar the autodiscovery runs but doesnt show anny sensors. i had it all working but decided to start from scratch again.

    Im doing something wrong but cant figure it out.


  • Hero Member

    Hello @rob!

    The autodiscovery is always active since version 2.1 of the binding, so there is no need to start it manually. A click on start will actually restart the scanning.
    Have you checked the inbox folder? What's the debug output?



  • @TimO Thank you for your quick reaction (and good work !!) inbox folder is empty. and here is a copy paste of the log file

    2017-07-05 12:55:28.504 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;159680 TSF:MSG:FPAR REQ,ID=40
    2017-07-05 12:55:28.507 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;159684 TSF:CKU:OK,FCTRL
    2017-07-05 12:55:28.509 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;159687 TSF:MSG:GWL OK
    2017-07-05 12:55:29.520 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;160696 !TSF:MSG:SEND,0-0-40-40,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
    2017-07-05 12:55:29.878 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;161053 TSF:MSG:READ,110-110-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    2017-07-05 12:55:29.881 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;161059 TSF:MSG:BC
    2017-07-05 12:55:29.884 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;161062 TSF:MSG:FPAR REQ,ID=110
    2017-07-05 12:55:29.886 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;161067 TSF:CKU:OK,FCTRL
    2017-07-05 12:55:29.889 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;161070 TSF:MSG:GWL OK
    2017-07-05 12:55:30.227 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;161414 !TSF:MSG:SEND,0-0-110-110,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
    2017-07-05 12:55:30.546 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;161715 TSF:MSG:READ,40-40-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    2017-07-05 12:55:30.551 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;161721 TSF:MSG:BC
    2017-07-05 12:55:30.556 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;161724 TSF:MSG:FPAR REQ,ID=40
    2017-07-05 12:55:30.561 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;161727 TSF:CKU:OK,FCTRL
    2017-07-05 12:55:30.566 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;161730 TSF:MSG:GWL OK
    2017-07-05 12:55:31.547 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;162736 !TSF:MSG:SEND,0-0-40-40,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
    2017-07-05 12:55:31.937 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;163112 TSF:MSG:READ,110-110-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    2017-07-05 12:55:31.943 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;163119 TSF:MSG:BC
    2017-07-05 12:55:31.948 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;163122 TSF:MSG:FPAR REQ,ID=110
    2017-07-05 12:55:31.953 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;163126 TSF:CKU:OK,FCTRL
    2017-07-05 12:55:31.958 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;163129 TSF:MSG:GWL OK
    2017-07-05 12:55:32.300 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;163484 !TSF:MSG:SEND,0-0-110-110,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
    2017-07-05 12:55:33.999 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;165172 TSF:MSG:READ,110-110-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    2017-07-05 12:55:34.002 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;165178 TSF:MSG:BC
    2017-07-05 12:55:34.005 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;165181 TSF:MSG:FPAR REQ,ID=110
    2017-07-05 12:55:34.008 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;165185 TSF:CKU:OK,FCTRL
    2017-07-05 12:55:34.011 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;165188 TSF:MSG:GWL OK
    2017-07-05 12:55:34.369 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;165554 !TSF:MSG:SEND,0-0-110-110,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
    2017-07-05 12:56:07.259 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;198430 TSF:MSG:READ,5-5-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    2017-07-05 12:56:07.265 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;198436 TSF:MSG:BC
    2017-07-05 12:56:07.279 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;198439 TSF:MSG:FPAR REQ,ID=5
    2017-07-05 12:56:07.285 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;198443 TSF:PNG:SEND,TO=0
    2017-07-05 12:56:07.289 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;198447 TSF:CKU:OK
    2017-07-05 12:56:07.295 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;198449 TSF:MSG:GWL OK
    2017-07-05 12:56:08.130 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;199309 !TSF:MSG:SEND,0-0-5-5,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
    2017-07-05 12:56:09.301 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;200465 TSF:MSG:READ,5-5-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    2017-07-05 12:56:09.306 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;200471 TSF:MSG:BC
    2017-07-05 12:56:09.311 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;200474 TSF:MSG:FPAR REQ,ID=5
    2017-07-05 12:56:09.317 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;200478 TSF:CKU:OK,FCTRL
    2017-07-05 12:56:09.320 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;200481 TSF:MSG:GWL OK
    2017-07-05 12:56:10.144 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;201324 !TSF:MSG:SEND,0-0-5-5,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
    2017-07-05 12:56:11.332 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;202501 TSF:MSG:READ,5-5-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    2017-07-05 12:56:11.335 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;202507 TSF:MSG:BC
    2017-07-05 12:56:11.338 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;202510 TSF:MSG:FPAR REQ,ID=5
    2017-07-05 12:56:11.341 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;202514 TSF:CKU:OK,FCTRL
    2017-07-05 12:56:11.344 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;202517 TSF:MSG:GWL OK
    2017-07-05 12:56:12.162 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;203347 !TSF:MSG:SEND,0-0-5-5,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0
    2017-07-05 12:56:13.363 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;204536 TSF:MSG:READ,5-5-255,s=255,c=3,t=7,pt=0,l=0,sg=0:
    2017-07-05 12:56:13.366 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;204542 TSF:MSG:BC
    2017-07-05 12:56:13.369 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;204546 TSF:MSG:FPAR REQ,ID=5
    2017-07-05 12:56:13.371 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;204549 TSF:CKU:OK,FCTRL
    2017-07-05 12:56:13.374 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;204553 TSF:MSG:GWL OK
    2017-07-05 12:56:14.193 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;205371 !TSF:MSG:SEND,0-0-5-5,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0



  • @rob
    As I see from log, gateway unable to send to sensor 5 response to find parent
    2017-07-05 12:56:14.193 [DEBUG] [rsAbstractConnection$MySensorsReader] - 0;255;3;0;9;205371 !TSF:MSG:SEND,0-0-5-5,s=255,c=3,t=8,pt=1,l=1,sg=0,ft=0,st=NACK:0

    I recommend to debug your radio link, may be using MYSController



  • @doctor64 the node 5 i manually added to openhab its a relay but isnt found with discovery (i have like 30 nodes a bunch of hue lights etc etc) everthing worked ok but my pi/openhab was taken down by the wife 😞 so had to rebuild from scratch and now the log shows the sensors but openhab wil not show me them


Log in to reply
 

Suggested Topics

  • 22
  • 2
  • 10
  • 3
  • 135
  • 5

0
Online

11.4k
Users

11.1k
Topics

112.7k
Posts