SceneController



  • Hi I have made a wall controller, but I'm using S_LIGHT as presentation. Is it possible to make it as S_SCENECONTROLLER1 insted. Then I only have one device and the node, insted of as now 4 devices and a node?

    I dont know if it possible. What I want is to make is a MySensor device that acts like a scene controller.

    Regards dalhoj


  • Admin

    I haven't played with scene-controllers. Do you run a Vera controller or have something else?



  • I have the vera controller, and would like to make a node that acts like ie. The battery operated remotes you can get in z wave, so you can trigger scenes.


  • Hero Member

    Actually this is a pretty good idea.
    A zwave scene controller is roughly $50..i have an Aeon one. and yeah its ok function wise, but its pretty ugly. I thought i would open it up and wire its buttons to a nicer wall plate.( Something like the Clipsal Saturn plate...which is going to make it very $$$ but would look great.)

    So to save $$ by using a mysensors battery board/devDuino2 running a "scene Controller" sketch would be pretty nice!

    @hek - the Vera device files used by a scene controller are
    urn:schemas-micasaverde-com:device:SceneController:1
    D_SceneController1.xml

    Do you think these are able to be controlled by a mySensor device?


  • Admin

    @gregl

    Yes it is possible. Just don't know when I have time to do the necessary tests. Anyone want do do some tests on what variables we need to activate/deactivate scenes etc?

    I think ** NumButtons**, sl_SceneActivated and ** sl_SceneDeactivated** is involved.


  • Hero Member

    @hek said:

    sl_SceneActivated

    @hek - ill have a crack....but any idea where on vera these files reside?


  • Admin

    @gregl

    Ok, added missing scene controller device (the SCENE_ON / SCENE_OFF variables was already there) to the 1.4 development branch.

    https://github.com/mysensors/Arduino/blob/development/libraries/MySensors/MyMessage.h#L58
    https://github.com/mysensors/Vera/blob/development/L_Arduino.lua#L74

    But I have no idea what happens if you create a SceneController device from your Arduino. When do you specify NumButtons? At creation time? That would be problematic as we today have no way of specifying custom data when doing sensor-presentation from Arduino.

    Edit: My post number 500!



  • @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



  • Im not home at the moment so I cant test, but found the guide to set up a z wave remote

    http://wiki.zwaveeurope.com/index.php?title=KFOB_VERA

    So I think you will have each button on the node to send a scene_on with the id of the button and then deactivate the scene again.

    And then just a picture of my wall plate in danish design, with the arduino behind.
    https://dl.dropboxusercontent.com/u/3260168/arduinotryk01.jpg



  • 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;
        }
      }
    }

  • Hero Member

    Sweet!! Thanks @hhg exactly what I need.



  • I tried this out last night and discovered an interesting issue. A scene will activate once and deactivate once, but all subsequent changes are not applied. I confirmed in my Vera logs that the messages make it through to the unit, but the subsequent application of scene never happens after the first time.

    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.


  • Admin

    @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.

    This most surely is the problem! I will have to make a mental note of it and fix it the next time I mess with the Vera plugin code.



  • @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



  • @hhg

    Worked like a charm!



  • hey guys, trying to set this one up, i have the widget displaying, but no control happening

    pretty new to all of this so any help would be appreciated.

    dayve



  • Hi

    After the Node and Scenecontroller shows up in the Vera UI you have to create a scene and then asign the scenecontroller as a trigger:
    arduino_trigger.png

    For button 1 the scene number is 0
    for button 2 the scene number is 1 and so on.

    Hope is helps 😉



  • @Dalhoj thanks for that, it seems super obvious now in retrospect.



  • @Dalhoj is it possible to have one button stop/start the same scene, as an on/off switch for a light for example?


  • Hero Member

    @dayve218

    If you use PLEG you could do it like this:

    Condition ----------------- Action
    LightOn AND Button = Turn Light Off

    LightOff AND Button = Turn Light On


  • Admin

    @dayve218

    Some "scene controllers" I've seen triggers "scene off" when you push-and-hold button for say one a second.



  • how would i make that happen?

    @korttoma i dont, PLEG is infinitely confusing to me.



  • I dont know if you can have a 1 sec press!

    but i uses LUUP and a simple ex could be turn on a lamp and if the lamp if on turn it off:

    local relay1 = 114 --Light ID

    local relay1_status = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", relay1) --Status of Light

    if (relay1_status == "0") then
    luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="1" }, relay1)
    else
    luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="0" }, relay1)
    end

    Or you can use a toggle from the advanced scene menu:
    upload-cb06931d-0aaa-4ee3-b90f-345180b5247c

    That is how I do it.


  • Admin

    @Dalhoj said:

    I dont know if you can have a 1 sec press!

    I mean that the Arduino checks if user presses button for one sec and send the SCENE_OFF. You probably shouldn't let Vera handle this.



  • Hey! Any pictures of scene controller installations? I'm planning on DIY'ing some "aesthetically pleasing" ones 🙂



  • @hek said:

    I mean that the Arduino checks if user presses button for one sec and send the SCENE_OFF. You probably shouldn't let Vera handle this.

    I would make the Arduino send ie. for button 1 send scene ID 0 at short press and scene ID 1 for long press and so on.

    @Nuubi Here is two of my scene controllers:

    The first one is installed in my bedtable upload-c29b281d-083c-4b73-a4df-b27240ee9e31 and is a combination of a scenecontroller and a relaysensor for controling the 3 leds.

    The 2. is installed in the living room, and is a 8 button scenecontroller.
    upload-aee5fc51-3dea-4a00-b592-db58744e1e87
    It controlles

    • the lights in the living room
    • Blinds Open / Close
    • a power outlet On/Off
    • pause/plays my XBMC Medie Center
    • starts my Yamaha reciver and starts playing net radio
    • stops the radion again and turn of the reciver
    • turns up / down the volume on the reciver

    That is what I use it for at the moment.



  • @Dalhoj what enclosures are they? They look really slick!




Log in to reply
 

Suggested Topics

  • 1
  • 1
  • 5
  • 1
  • 6
  • 10

63
Online

11.4k
Users

11.1k
Topics

112.7k
Posts