How to make a toggle switch on an AEO KeyFob Gen5

#1

I recently bought an AEN KeyFob Gen5. I didnt like the idea of us a single press for on and then double press the same button for off on the lights I was using it to control. So I wrote a simple piece of LUUP to make a switch toggle. I know nothing about code and this is the fuirst thing Ive written but it seems to do the trick nicely.

Thougt I’d share it in case anyone else wanted to do the same

local device = enter your device ID that you want to control i.e., 5 local lmp_status = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", device) if (lmp_status == "0") then luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "40"}, device) end if (lmp_status > "0") then luup.call_action("urn:upnp-org:serviceId:Dimming1", "SetLoadLevelTarget", {newLoadlevelTarget = "0"}, device) end

Note: newLoadlevelTarget = “40”. I am using a dimmable device and this sets the dim level to 40%. You can change this number to suit.

#2

You really don’t need LUUP code to do it if it is a z-wave switch. Just create a scene, and go into the advanced editor. Select your switch, and select the ToggleState action under HaDevice1. You now have a scene that will toggle the switch.

Cindy

1 Like
#3

[quote=“shallowearth, post:2, topic:194132”]You really don’t need LUUP code to do it if it is a z-wave switch. Just create a scene, and go into the advanced editor. Select your switch, and select the ToggleState action under HaDevice1. You now have a scene that will toggle the switch.

Cindy[/quote]

I had tried that and it didnt work for me, which is why I ended up with the code.

#4

Weird, I use the toggle command on my minimote which is the same code under the cover as the key fob. What switch are you controlling?

Have you tried calling the toggle command from the LUA (the problem with your code is that unless your switches support instant status, if you are toggling a lot it is unlikely that Vera will have the right up todate state, you might have to wait 30-5 minutes between each press to test it).

luup.call_action(“urn:upnp-org:serviceId:HaDevice1”, “ToggleState”, {} , device)

Or something similar, not 100% sure what would go in the 3rd parameter since it is empty.

#5

Im using Popp dimmable plug sockets.

#6

The ToggleState action (undet HaDevice1 on the Scenes) is amazing!!! I’ve been looking for this over a year!

It works great on lights… Now I have a difficulty with blinds. How to make it up, stop and down with the same button? The ToggleStates only changes between opening and closing them… How can I stooped it on the same button?