Navigation

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

    bkl

    @bkl

    8
    Reputation
    15
    Posts
    830
    Profile views
    2
    Followers
    0
    Following
    Joined Last Online

    bkl Follow

    Best posts made by bkl

    • openHAB binding

      Hi

      I have been playing a bit with creating a binding for openHAB.
      And it is now in a state where i think it is ready for some more testing.

      Links
      GitHub (https://github.com/bloft/openhab)
      Download (http://bkl.linux.dk/org.openhab.binding.mysensors-1.8.0-SNAPSHOT.jar)

      Features

      • Serial Gateway supported Only
      • Supported all sensors (1.6)
      • Discovery of devices (sort of)
      • Support requesting values from openhab

      Experimental / Not Tested

      • Ethernet Gateway
      • Error handling of Gateway (restart of connection)
      • I_CONFIG support add mysensors:metric=true to mysensors:metric=false to openhab.cfg

      Not Working

      • Auto assign of Node ID

      Howto Use

      1. Add jar to addons dir
      2. Modify openhab.cfg add "mysensors:port=/dev/ttyUSB0"
      3. Add items

      Configure ethernet gateway
      Modify openhab.cfg set

      mysensors:type=ethernet
      mysensors:host=<host ip>
      mysensors:port=5003
      

      This is still untested so please report if it is working or not.

      Auto discovery
      Every time a Presentation is detected, example of usage is printed to the openhab.log on INFO

      Example of items:

      Number  Humidity              "Hjemmebio [%s %%Rh]"   <water>         (gBio,gHumidity)        {mysensors="3;0;V_HUM"}
      Number  Temperature           "Hjemmebio [%s °C]"     <temperature>   (gBio,gTemperature)     {mysensors="3;1;V_TEMP"}
      Switch  Motion                "Hjemmebio [%s]"        <motion>        (gBio,gMotion)          {mysensors="3;2;V_TRIPPED"}
      Number  Light                 "Hjemmebio [%s]"        <slider>        (gBio,gLightLevel)      {mysensors="3;3;V_LIGHT_LEVEL"}
      
      posted in OpenHAB
      bkl
      bkl
    • RE: openHAB binding

      @andredts
      Thanks for the feedback, this is now fixed.

      posted in OpenHAB
      bkl
      bkl
    • RE: openHAB binding

      @NickBuilder

      Hi

      No need for a new version, baudrate is configurable

      just set.
      mysensors:baudrate=38400

      posted in OpenHAB
      bkl
      bkl

    Latest posts made by bkl

    • RE: openHAB binding

      Hi @Kodiak80

      Your are missing the " item definition should be.

      Number  Temperature           "Temp [%s °C]"     <temperature>   (gBio,gTemperature)     {mysensors="105;1;V_TEMP"}
      

      The values is just

      node-id;child-sensor-id;sub-type
      
      posted in OpenHAB
      bkl
      bkl
    • RE: openHAB binding

      @NickBuilder
      From what i know sendCommand should be the way to go.

      myElecVar.sendCommand(0);
      

      That should send the value to your sensor, and then update its value of pulseCount

      posted in OpenHAB
      bkl
      bkl
    • RE: openHAB binding

      @NickBuilder

      Hi

      No need for a new version, baudrate is configurable

      just set.
      mysensors:baudrate=38400

      posted in OpenHAB
      bkl
      bkl
    • RE: openHAB binding

      @skatun

      My code was just to show how the integration between openhab and mysensors is working.
      And correct my led strip is controlled by a single P9813 chip,

      You could try and change NUM_LEDS but this will also increase the number of Sensors in openhab/mysensors
      Or you could group them togetter in the sketch.

      posted in OpenHAB
      bkl
      bkl
    • RE: openHAB binding

      Hi @skatun

      I have some RGB lights, using mysensors and openhab

      Item configuration

      Color	Light_6_0		"Light Left"						(gBio,gLights)		{mysensors="6;0;V_RGB"}
      

      Sketch

      #include <MySensor.h>
      #include <ChainableLED.h>
      #include <SPI.h>
      
      #define NODE_ID 6
      
      #define NUM_LEDS 1
      
      int counter[NUM_LEDS];
      
      int current[NUM_LEDS][3];
      int step[NUM_LEDS][3];
      
      unsigned long SLEEP_TIME = 10;
      
      MySensor gw;
      //ChainableLED leds(7, 8, 1);
      ChainableLED leds(5, 6, NUM_LEDS);  // CLK, DATA, LEDS
      
      void setup() {   
        leds.init();
        for(byte childId = 0; childId < NUM_LEDS; childId++) {
          counter[childId] = 0;
          current[childId][0] = 0;
          current[childId][1] = 0;
          current[childId][2] = 0;
          step[childId][0] = 0;
          step[childId][1] = 0;
          step[childId][2] = 0;
          leds.setColorRGB(childId, current[childId][0], current[childId][1], current[childId][2]); // Turn of on startup
        }
        
        // Initialize library and add callback for incoming messages
        gw.begin(incomingMessage, NODE_ID, true);
        // Send the sketch version information to the gateway and Controller
        gw.sendSketchInfo("RGB Led", "1.2");
        for(byte childId = 0; childId < NUM_LEDS; childId++) {
         gw.present(childId, S_RGB_LIGHT);
        }
      }
      
      
      void loop()  {
        // Alway process incoming messages whenever possible
        gw.process();
      
        for(byte childId = 0; childId < NUM_LEDS; childId++) {
          if(counter[childId] >= 0) {
            counter[childId]--;
            int i = 1020 - counter[childId];
            current[childId][0] = calculateVal(step[childId][0], current[childId][0], i);
            current[childId][1] = calculateVal(step[childId][1], current[childId][1], i);
            current[childId][2] = calculateVal(step[childId][2], current[childId][2], i);
            
            leds.setColorRGB(childId, current[childId][0], current[childId][1], current[childId][2]);
          }
        }
        
        gw.wait(SLEEP_TIME);
      }
      
      void incomingMessage(const MyMessage &message) {
        // We only expect one type of message from controller. But we better check anyway.
        if (message.type==V_RGB) {
          String hexstring = message.getString();
          long number = (long) strtol( &hexstring[0], NULL, 16);
          int colorR = number >> 16;
          int colorG = number >> 8 & 0xFF;
          int colorB = number & 0xFF;
          
           // Write some debug info
           Serial.print("Incoming change for sensor:");
           Serial.print(message.sensor);
           Serial.print(", Red: ");
           Serial.print(colorR);
           Serial.print(", Green: ");
           Serial.print(colorG);
           Serial.print(", Blue: ");
           Serial.print(colorB);
           Serial.print(", New status: ");
           Serial.println(message.getString());
      
            setColor(message.sensor, colorR, colorG, colorB);
           //leds.setColorRGB(message.sensor, colorR, colorG, colorB);
         } 
      }
      
      void setColor(byte led, int R, int G, int B) {
        step[led][0] = calculateStep(current[led][0], R);
        step[led][1] = calculateStep(current[led][1], G);
        step[led][2] = calculateStep(current[led][2], B);
      
        counter[led] = 255;
      }
      
      int calculateStep(int prevValue, int endValue) {
        int step = endValue - prevValue; // What's the overall gap?
        if (step) {                      // If its non-zero, 
          step = 255/step;              //   divide by 1020
        } 
        return step;
      }
      
      int calculateVal(int step, int val, int i) {
      
        if ((step) && i % step == 0) { // If step is non-zero and its time to change a value,
          if (step > 0) {              //   increment the value if step is positive...
            val += 1;           
          } 
          else if (step < 0) {         //   ...or decrement it if step is negative
            val -= 1;
          } 
        }
        // Defensive driving: make sure val stays in the range 0-255
        if (val > 255) {
          val = 255;
        } 
        else if (val < 0) {
          val = 0;
        }
        return val;
      }
      

      The sketch may be a bit over complicated, but the important part is the incomingMessage, all the rest is because I like to fade between the colors.

      Hope it help you.

      posted in OpenHAB
      bkl
      bkl
    • RE: openHAB binding

      Hi @Harry-Gomez

      If you make a guide to make openhab work with a non standard serial port, then i will make it part of the first post.

      posted in OpenHAB
      bkl
      bkl
    • RE: openHAB binding

      Hi @Francois

      Yes i am using the standard relay sketch.

      I thing i found you problem, try and change V_BINARY to V_STATUS

      posted in OpenHAB
      bkl
      bkl
    • RE: openHAB binding

      Hi @Francois

      The syntax look OK.

      This is what i have working.

      Switch  Relay_10_0              "Relay 1"                       <none>                                  {mysensors="10;0;V_STATUS"}
      

      Try and turn on debug log for mysensors

      Add this to logback.xml

      <logger name="org.openhab.binding.mysensors" level="DEBUG" />
      
      posted in OpenHAB
      bkl
      bkl
    • RE: openHAB binding

      @andredts
      Thanks for the feedback, this is now fixed.

      posted in OpenHAB
      bkl
      bkl
    • RE: openHAB binding

      @andredts
      It was a bug in the code. If you download the new jar then it should be fixed.

      posted in OpenHAB
      bkl
      bkl