Menu

Action type toggle-value needed

Damago
2011-02-07
2012-12-14
  • Damago

    Damago - 2011-02-07

    What is the correct way to create an action to toggle value to an opposite state. The "cycle-on-off" unfortunately always leaves the value in 'off' state when it finishes execution.

    Usage scenarios:
    1) whenever I approach house in the car, I do press remote control button. I would like to blink the gate lamp a few times when the remote signal is received. Unfortunately the lamp can be in on or off state before and I don't want to change it.
    2) when something happens I would like to reverse the lamps used - switch on the lamps that were off, and vice-versa. This is usefull if you would like to use different set of lights during the day and different during the night.

    I know you CAN write complicated rules which will do this but addition of a single 'toggle-on-off' action type would solve the problem. Functionality should be identical to 'cycle-on-off' except for the 3-4 lines of code.

    The action would allow then: to blink and leave in the same state (if the number of repetitions is even), blink and leave in opposite state (if number of repetitions is odd, for instance 1)

     
  • jef2000

    jef2000 - 2011-02-07

    Hi,

    I'm currently working on the topic. Would something like this fullfill your needs?

                    <action type="repeat-list" period="800ms" count="3">
                        <action type="toggle-value" id="door_light"/>
                    </action>

    I created a "toggle-value" action that just toggle switching objects once. Then a "repeat-list" action that just repeats a list of actions periodically a predefined number of times.
    I'll also extend all delay values to accept milliseconds format.
    All actions in the list are started at the same time, but you can delay some of them using the delay="x" parameter like on any action like this:
                    <action type="repeat-list" period="2" count="3">
                        <action type="toggle-value" id="door_light"/>
                        <action type="toggle-value" id="door_light" delay="200ms"/>
                    </action>

    Jean-François

     
  • Othmar

    Othmar - 2011-02-08

    Wow,

    that's a cool idea. This opens a nice new playground for linknx. I'm looking forward to the new release.

    Othmar

     
  • jef2000

    jef2000 - 2011-02-09

    This is not yet the official release, but if you want to give it a try…
    http://ouaye.net/linknx/other/linknx-0.0.1.28RC1.tar.gz
    This is already close to what release 0.0.1.28 will be.
    The only thing I still see in my todo list is a simple way to compare object values without having to use LUA. But I'm still not sure what's the best way to do it, because if I just implement value comparison, one day somebody will ask if he can specify an offset, or want to add a multiplication factor to one of the values, or a combination of 3 values, or…. You know how good people can be at finding new needs. ;-)

    Jean-François

     
  • JensH

    JensH - 2011-02-11

    Hi Jean-François,
    ./configure …make .. make install works,
    toggle works, repeat works ….I have not yet tested the listener/read thing… if this is already implemented?

    So we have to think of something new … :-)))

    No honestly, thank you very much - I'll let it run and report back if something (bad) happens. :-)
    best Regards, Jens

     
  • Damago

    Damago - 2011-03-02

    Hi,

    This is completely satisfactory. Those two things: "toggle-value" action and "copy-value" action are making action writing much more flexible. Currently my linknx.conf counts nearly 1500 lines. With those two extensions I will be able to go down by at least a hundred lines.

    Yours

    Damago1

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.