Navigation

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

    hhg

    @hhg

    2
    Reputation
    5
    Posts
    556
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    hhg Follow

    Best posts made by hhg

    • RE: SceneController

      In 1.4b1 1.4b1 (18848a2) Scene Controller support is present, and works fine

      Present with:

      gw.present(CHILD_ID, S_SCENE_CONTROLLER); 
      

      And it shows as a generic scene controller in Vera:
      upload-af0688b3-9110-434f-a57c-aa34e808e0fe

      The sketch to support a 4 button wall controller:

      // Simple SceneController 
      
      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      
      #define CHILD_ID 3
      // PIN for the buttons
      byte buttons[] = {3, 4, 5, 6};
      #define NUMBUTTONS sizeof(buttons)
      byte pressed[NUMBUTTONS], justpressed[NUMBUTTONS], justreleased[NUMBUTTONS];
      
      MySensor gw;
      Bounce debouncer[NUMBUTTONS];
      
      int oldValue[NUMBUTTONS];
      
      MyMessage msgOn(CHILD_ID,V_SCENE_ON);
      MyMessage msgOff(CHILD_ID,V_SCENE_OFF);
      
      void setup()  
      {  
        gw.begin();
      
        /// Make input & enable pull-up resistors on switch pins
        for (short i=0; i < NUMBUTTONS; i++){
        
          pinMode(buttons[i], INPUT);
          digitalWrite(buttons[i], HIGH);
          oldValue[i] = -1;
          // After setting up the button, setup debouncer
          debouncer[i].attach(buttons[i]);
          debouncer[i].interval(5);
          
        }
        
        
        
        // Send the Sketch Version Information to the Gateway
        gw.sendSketchInfo("LK 4-Tryk", "1.0");
        // Register binary input sensor to gw (they will be created as child devices)
        gw.present(CHILD_ID, S_SCENE_CONTROLLER); 
      }
      
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
        for (short i=0; i < NUMBUTTONS; i++){
          debouncer[i].update();
          // Get the update value
          int value = debouncer[i].read();
       
          if (value != oldValue[i]) {
             // Send in the new value
             if (value==HIGH) {
               gw.send(msgOff.set(i));
             }
             else {
               gw.send(msgOn.set(i));
             }
             oldValue[i] = value;
          }
        }
      }
      posted in Development
      hhg
      hhg
    • RE: SceneController

      @androbot said:

      I'm suspecting this is due to the "setVariableIfChanged" nature of the code in conjunction with the split V_SCENE_ON/V_SCENE_OFF messages. In other words, it's not a single variable that is toggling, it's two separate ones.

      Nice spottet!

      Change line 182 in L_Arduino.lua from

       if ((value ~= curValue) or (curValue == nil)) then
      

      to:

      if ((value ~= curValue) or (curValue == nil) or (serviceId == "urn:micasaverde-com:serviceId:SceneController1")) then
      

      So the sl_SceneActivated/sl_SceneDeactivated variables are updated unconditionally

      posted in Development
      hhg
      hhg

    Latest posts made by hhg

    • RE: Relays and Scene Controller on same Node v1.4

      @Dalhoj j

      Looking at your code from post #1 I think you have a sensor id conflict.

      The relays are presented in the loop in line 37:

      gw.present(sensor, S_LIGHT);
      

      where sensor is looping over 1 to 5

      But in line 62 the Scene Controller is presented with sensor id 3 (CHILD_ID defined in line 14 to 3)

      gw.present(CHILD_ID, S_SCENE_CONTROLLER); 
      

      So sensor id 3 is redefined. Will that work?

      Or do I misread your code?

      posted in My Project
      hhg
      hhg
    • RE: SceneController

      @androbot said:

      I'm suspecting this is due to the "setVariableIfChanged" nature of the code in conjunction with the split V_SCENE_ON/V_SCENE_OFF messages. In other words, it's not a single variable that is toggling, it's two separate ones.

      Nice spottet!

      Change line 182 in L_Arduino.lua from

       if ((value ~= curValue) or (curValue == nil)) then
      

      to:

      if ((value ~= curValue) or (curValue == nil) or (serviceId == "urn:micasaverde-com:serviceId:SceneController1")) then
      

      So the sl_SceneActivated/sl_SceneDeactivated variables are updated unconditionally

      posted in Development
      hhg
      hhg
    • RE: SceneController

      In 1.4b1 1.4b1 (18848a2) Scene Controller support is present, and works fine

      Present with:

      gw.present(CHILD_ID, S_SCENE_CONTROLLER); 
      

      And it shows as a generic scene controller in Vera:
      upload-af0688b3-9110-434f-a57c-aa34e808e0fe

      The sketch to support a 4 button wall controller:

      // Simple SceneController 
      
      #include <MySensor.h>
      #include <SPI.h>
      #include <Bounce2.h>
      
      #define CHILD_ID 3
      // PIN for the buttons
      byte buttons[] = {3, 4, 5, 6};
      #define NUMBUTTONS sizeof(buttons)
      byte pressed[NUMBUTTONS], justpressed[NUMBUTTONS], justreleased[NUMBUTTONS];
      
      MySensor gw;
      Bounce debouncer[NUMBUTTONS];
      
      int oldValue[NUMBUTTONS];
      
      MyMessage msgOn(CHILD_ID,V_SCENE_ON);
      MyMessage msgOff(CHILD_ID,V_SCENE_OFF);
      
      void setup()  
      {  
        gw.begin();
      
        /// Make input & enable pull-up resistors on switch pins
        for (short i=0; i < NUMBUTTONS; i++){
        
          pinMode(buttons[i], INPUT);
          digitalWrite(buttons[i], HIGH);
          oldValue[i] = -1;
          // After setting up the button, setup debouncer
          debouncer[i].attach(buttons[i]);
          debouncer[i].interval(5);
          
        }
        
        
        
        // Send the Sketch Version Information to the Gateway
        gw.sendSketchInfo("LK 4-Tryk", "1.0");
        // Register binary input sensor to gw (they will be created as child devices)
        gw.present(CHILD_ID, S_SCENE_CONTROLLER); 
      }
      
      
      //  Check if digital input has changed and send in new value
      void loop() 
      {
        for (short i=0; i < NUMBUTTONS; i++){
          debouncer[i].update();
          // Get the update value
          int value = debouncer[i].read();
       
          if (value != oldValue[i]) {
             // Send in the new value
             if (value==HIGH) {
               gw.send(msgOff.set(i));
             }
             else {
               gw.send(msgOn.set(i));
             }
             oldValue[i] = value;
          }
        }
      }
      posted in Development
      hhg
      hhg
    • RE: My sensorboard MYS 1.0beta

      @Mrlynx
      Nice board. Looking forward to more info. Would like to buy 5 boards/kits

      posted in Hardware
      hhg
      hhg
    • RE: SceneController

      @hek

      If you want buttons on the device widget I think you need to at some custom D_.xml and D_.js files (See AtiRemote in the rfxtrx code tree as an example)
      But in my experience the generic Scene Controller works fine "as is" - Just sent the "Button number" as the value:

      -- On button press
      luup.variable_set("urn:micasaverde-com:serviceId:SceneController1","sl_SceneActivated", button_no, device_no)
      			
      -- On button release                                                                                       
      luup.variable_set("urn:micasaverde-com:serviceId:SceneController1","sl_SceneDeactivated", button_no, device_no)
      

      Please note: I have not tried this with MySensors - The above is from another Vera plugin I have written

      posted in Development
      hhg
      hhg