Navigation

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

    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
    • RE: openHAB binding

      @andredts
      Can you try and post the sketch you are using? Or are you using the RelayWithButtonActuator Example?

      I don't thing that the inverted logic should have anything to do with it.

      posted in OpenHAB
      bkl
      bkl
    • RE: openHAB binding

      @BastienVH

      https://github.com/openhab/openhab/wiki/Serial-Binding

      Note2: If you are using non standard serial ports you have to adapt start.sh to have the serial port included. the java command line should then include the following parameters:

      -Dgnu.io.rxtx.SerialPorts=/dev/ttyAMA0
      whereas ttyAMA0 is the path to your serial port. Please be aware to change all scripts you might use for startup (debug, automatic start in linux,...)

      posted in OpenHAB
      bkl
      bkl
    • RE: Pulse Power Meter with OpenHAB?

      @TommySharp

      Hi

      I have it working, using my own binding.

      It is not impossible to read the state of an item in openhab, the difficult part is getting it initialized, and restored when you restart openhab.

      First. You need to define an item (you properly already have that done)
      Second. You need to configure a persistence to restart the value on startup, by adding restoreOnStartup
      Third. You need to initialize the item. The can be done by stating openhab in console mode, and type the command "openhab send <item> <command>", where <command> is is the value you want to set.

      Hope that helps

      posted in OpenHAB
      bkl
      bkl
    • RE: openHAB binding

      @BastienVH

      Hi.

      The "Unknown: MySensors message:" log, should only appear if there is not item configured to the nessage sensor and type.
      I will change this message to some thing more meaningful

      So the problem is that your items is not configured or not configured correctly.

      Try add this to you logback.xml

      <logger name="org.openhab.binding.mysensors" level="DEBUG" />
      

      After editing the items file, you should see something like.

      19:59:48.085 DEBUG o.o.b.m.i.MySensorsGenericBindingProvider[:85]- New Item "Humidity_skur (Type=NumberItem, State=Uninitialized)" based on configuration "1;0;V_HUM"
      19:59:48.087 DEBUG o.o.b.m.i.MySensorsGenericBindingProvider[:85]- New Item "Temperature_skur (Type=NumberItem, State=Uninitialized)" based on configuration "1;1;V_TEMP"
      19:59:48.088 DEBUG o.o.b.m.i.MySensorsGenericBindingProvider[:85]- New Item "Light (Type=ColorItem, State=Uninitialized)" based on configuration "2;0;V_RGB"
      19:59:48.090 DEBUG o.o.b.m.i.MySensorsGenericBindingProvider[:85]- New Item "Humidity_3 (Type=NumberItem, State=Uninitialized)" based on configuration "3;0;V_HUM"
      19:59:48.091 DEBUG o.o.b.m.i.MySensorsGenericBindingProvider[:85]- New Item "Motion_3 (Type=SwitchItem, State=Uninitialized)" based on configuration "3;2;V_TRIPPED" 
      19:59:48.094 DEBUG o.o.b.m.i.MySensorsGenericBindingProvider[:85]- New Item "Light_3 (Type=NumberItem, State=Uninitialized)" based on configuration "3;3;V_LIGHT_LEVEL"
      19:59:48.095 DEBUG o.o.b.m.i.MySensorsGenericBindingProvider[:85]- New Item "Watt_4 (Type=NumberItem, State=Uninitialized)" based on configuration "4;1;V_WATT"
      19:59:48.097 DEBUG o.o.b.m.i.MySensorsGenericBindingProvider[:85]- New Item "Kwh_4 (Type=NumberItem, State=Uninitialized)" based on configuration "4;1;V_KWH"
      19:59:48.098 DEBUG o.o.b.m.i.MySensorsGenericBindingProvider[:85]- New Item "PulseCount_4 (Type=NumberItem, State=Uninitialized)" based on configuration "4;1;V_VAR1"
      

      This is from my setup where it works.
      Or an error saying

      Unable to parse "..." need to be in the format <number>;<number>;<type>
      
      posted in OpenHAB
      bkl
      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