Author Topic: Scene control - Unchanged/ON/OFF - would like "TOGGLE" added for convenience  (Read 5665 times)

Offline guessed

  • Master Member
  • *******
  • Posts: 5294
  • Karma: +90/-22
  • Release compat is not a bolted-on afterthought
In Scenes, for Switch devices, Vera presents the options:

    Unchanged
    ON
    OFF

I'd like another option added:

    TOGGLE

Which will flip the current power state (ON->OFF, OFF->ON).  This is a convenience to avoid writing Luup on the Scene, so that folks can attach a single "Scene" to a Scene controller Button and have it toggle the Lights (or controlled Power outlet) much as a Scene controller would usually do (and without having to dedicate a button to an "ALL-OFF" type Scene)

Offline LibraSun

  • Hero Member
  • *****
  • Posts: 542
  • Karma: +0/-0
I second this request, as I look forward to implementing remotes within my Vera network, and think a "Toggle" option would maximize button assignment options.

Vera Model I running UI4 (Firmware 1.1.1338), died in 2015
Vera Plus running UI7 (Firmware 1.7.2935)

Offline glaso

  • Jr. Member
  • **
  • Posts: 59
  • Karma: +0/-0
+1 It would be great

@guessed Wich luup code could I use to achieve this toggle behaviour?

Offline Ap15e

  • Beta Testers
  • Sr. Hero Member
  • *****
  • Posts: 2000
  • Karma: +11/-0
No need to write Lua code:

Scene -> 'Advanced' tab -> 'Pick a device' ... -> 'Add' -> select 'ToggleState' -> SAVE ...

Offline Henk

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 823
  • Karma: +3/-0
@guessed

I found the option Ap15e pointed out.

what i dont get is... how does this change the scene and what can i do with it?

Currently i have two scenes, lights ON and lights OFF with according timers.
Can i combine them to one scene with the toggle command?
| Vera2 @ UI4 1.1.1350 / 3.20 | Vera Lite @ UI5 | Vera 3 @ UI5 | 2x Merten  504519 | 1x Duewi  064374 | 1x Everspring SM103 doorbell mod |1 Y-cam IP cam | various LUUP plugins |

Offline guessed

  • Master Member
  • *******
  • Posts: 5294
  • Karma: +90/-22
  • Release compat is not a bolted-on afterthought
There are times with Remote control devices, where you have someone pressing the button that can "see" what state things are in, where the Toggle makes more sense than discrete "on" and "off" buttons (which are great for Home Automation/Macros etc)

Offline LibraSun

  • Hero Member
  • *****
  • Posts: 542
  • Karma: +0/-0
It's now 8 years later, and I *STILL* would like a "Toggle" option added to Vera scenes. Why? For example, I'd like my Aeon Minimote's BUTTON 1 to be able to trigger a scene that alternately turns a lamp on and off, without needing to assign the explicit "On" and "Off" tasks to separate buttons and scenes.

"Toggle" would streamline operations a great deal, without adding complexity, not to mention free up expensive hardware components and valuable controller RAM.

I second this request, as I look forward to implementing remotes within my Vera network, and think a "Toggle" option would maximize button assignment options.
Vera Model I running UI4 (Firmware 1.1.1338), died in 2015
Vera Plus running UI7 (Firmware 1.7.2935)

Offline tomtcom

  • Hero Member
  • *****
  • Posts: 848
  • Karma: +20/-30
It's now 8 years later, and I *STILL* would like a "Toggle" option added to Vera scenes. Why? For example, I'd like my Aeon Minimote's BUTTON 1 to be able to trigger a scene that alternately turns a lamp on and off, without needing to assign the explicit "On" and "Off" tasks to separate buttons and scenes.

"Toggle" would streamline operations a great deal, without adding complexity, not to mention free up expensive hardware components and valuable controller RAM.

I second this request, as I look forward to implementing remotes within my Vera network, and think a "Toggle" option would maximize button assignment options.

LOL, you are right. I use my minimotes with LUA code for each scene/button mapping. Someone on this forum had it so here is one example:

local switchOnOff = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", 41)
    if (switchOnOff == "1") then
      -- Switch is on
      luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "0"}, 41)
    else -- switch is off
     luup.call_action("urn:upnp-org:serviceId:SwitchPower1", "SetTarget", {newTargetValue = "1"}, 41)
    end

Offline LibraSun

  • Hero Member
  • *****
  • Posts: 542
  • Karma: +0/-0
Nice contribution, thanks!

I'd also like to bring the devs' attention to this thread on a different forum, wherein the same "Toggle State" suggestion is discussed - http://www.vesternet.com/resources/application-notes/apnt-41#.WV6qoogrJPY

Unfortunately, they refer to an "Advanced" tab that seemingly no longer exists under VeraPlus and UI7 (I looked), but at least the tech-savvy types can cobble something similar together with LUA, thanks to your code snippet.

Of course, I'd much rather have this functionality built-in to Vera's native OS, if at all possible.  ;)
Vera Model I running UI4 (Firmware 1.1.1338), died in 2015
Vera Plus running UI7 (Firmware 1.7.2935)

Offline tomtcom

  • Hero Member
  • *****
  • Posts: 848
  • Karma: +20/-30
Nice contribution, thanks!

I'd also like to bring the devs' attention to this thread on a different forum, wherein the same "Toggle State" suggestion is discussed - http://www.vesternet.com/resources/application-notes/apnt-41#.WV6qoogrJPY

Unfortunately, they refer to an "Advanced" tab that seemingly no longer exists under VeraPlus and UI7 (I looked), but at least the tech-savvy types can cobble something similar together with LUA, thanks to your code snippet.

Of course, I'd much rather have this functionality built-in to Vera's native OS, if at all possible.  ;)

I agree and you are right. I think the DIY aspect of Vera versus other controllers is why you don't see certain options available because you have full access to PLEG or lua code. This keeps the maintenance and updates to the Vera core less of a burden but then requires the burden to do "basic options" on the user. I liked Vera and dealt with their shortcomings to have a perceived higher level of control with coding tidbits and such but as we advance in IoT and more controllers, these options are built in and supporting newer devices faster where Vera lags.

It's always about the trade offs in my opinion. Which can you tolerate and which can you not tolerate.

Offline LibraSun

  • Hero Member
  • *****
  • Posts: 542
  • Karma: +0/-0
Perhaps you could help me troubleshoot a bit?

I tried implementing this (my first-ever!) Luup code, by first editing the snippet shared above and pasting it into a new (manual) Scene ? with no devices assigned ? in my VeraPlus, under "Also, execute the following Luup code:" ....

Code: [Select]
local switchOnOff = luup.variable_get("urn:schemas-upnp-org:device:BinaryLight:1", "Status", 25)
if (switchOnOff == "1")
then -- Device is on
luup.call_action("urn:schemas-upnp-org:device:BinaryLight:1", "SetTarget", {newTargetValue = "0"}, 25)
else -- Device is off
luup.call_action("urn:schemas-upnp-org:device:BinaryLight:1", "SetTarget", {newTargetValue = "1"}, 25)
end

I got the urn: string from my controlled device's Advanced > "Device_Type" text box, and the identifier (25) from "ID". The device is one of the outlets in my Zooz Zen20 power strip (device #20, acting as "Parent" to #25).

Yet when I manually run the scene, nothing happens, and the plugged-in lamp remains off. For the record, the lamp operates fine using an Aeon MiniMote whose Button 1 executes a different Scene designed to turn it ON, so I know all the components of my Vera network are operational. Furthermore, I see (after a super-quick flash of some red text) the word "Success" in green following each click of the "Play" button for this scene in the Vera UI.

Any clues where I'm going wrong here?? Thanks!

 - Libra
Vera Model I running UI4 (Firmware 1.1.1338), died in 2015
Vera Plus running UI7 (Firmware 1.7.2935)

Offline jswim788

  • Sr. Member
  • ****
  • Posts: 427
  • Karma: +15/-2
That URN doesn't look right.  You want the service ID, not the device_type.  Try "urn:upnp-org:serviceId:SwitchPower1".  You need to hover your mouse over the "Status" variable in the advanced tab to see it.

Offline LibraSun

  • Hero Member
  • *****
  • Posts: 542
  • Karma: +0/-0
Once again, guessed, you nailed it! Thanks for the assist. After making that correction, I decided to further streamline the code (using variables) I'm using to toggle ON/OFF status of my various devices. Here's a copy if anyone wishes to use it:

Code: [Select]
local deviceUrn = "urn:upnp-org:serviceId:SwitchPower1"
local deviceId = 20
local switchOnOff = luup.variable_get(deviceUrn, "Status", deviceId)
if (switchOnOff == "1")
then -- Device is on
luup.call_action(deviceUrn, "SetTarget", {newTargetValue = "0"}, deviceId)
else -- Device is off
luup.call_action(deviceUrn, "SetTarget", {newTargetValue = "1"}, deviceId)
end

USAGE NOTE: Simply replace the string** after deviceUrn = with that of your intended device, and do the same with the number after deviceId = .

**I find the easiest way to copy/paste the needed URN string is to open the Vera UI in Chrome Browser, go to Devices .. [controlled device] > .. Advanced > .. Variables tab .. right-click the word "Status" .. select "Inspect" from the context menu .. in the "Elements" pane that opens, double-click the string within quotes after title="" in the highlighted HTML code .. CTRL-C to Copy onto the clipboard .. later, when building the new Scene, use CTRL-V to Paste the copied string wherever needed in your Luup code.


Vera Model I running UI4 (Firmware 1.1.1338), died in 2015
Vera Plus running UI7 (Firmware 1.7.2935)

Offline DaveS2

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
The advanced Tab with toggle option exists if you login through home.getvera.com.  If I use a mobile app to login the advanced Tab doesn't appear.