Combination Virtual switch plugin (UI5)

hello

I have some code that does not work well since I put the combination switch

[sup]local partielactif = luup.variable_get(“urn:micasaverde-com:serviceId:SecuritySensor1”,“Armed”,46)
local mode = luup.variable_get(“urn:utz-com:serviceId:GCal1”,“gcalval”, 70)
local controle = luup.variable_get(“urn:upnp-org:serviceId::SwitchPower1”,“Status”,74)
if (partielactif == “0”) and (mode == “alarmpartielle”) then
return true
else
return false
end[/sup]

this code is good but this

[sup]local partielactif = luup.variable_get(“urn:micasaverde-com:serviceId:SecuritySensor1”,“Armed”,46)
local mode = luup.variable_get(“urn:utz-com:serviceId:GCal1”,“gcalval”, 70)
local controle = luup.variable_get(“urn:upnp-org:serviceId::SwitchPower1”,“Status”,74)
if (partielactif == “0”) and (mode == “alarmpartielle”) and (controle == “1”)then
return true
else
return false
end[/sup]

have you a idea ?

another question

i have a sensor security in a combination swith but i would like if my sensor is not triggered for 20 minutes (a time) activate a scéne

thanks David

[quote=“davidd1205, post:41, topic:171904”]local controle = luup.variable_get("urn:upnp-org:serviceId::SwitchPower1","Status",74) [/quote]

There is a double colon there that looks suspiciously wrong.

I recommend that you use the Countdown Timer plugin for this. Whenever the Security sensor trips, have it Restart the timer, and when the timer completes, have it activate the scene.

Hi Akash,

Sorry for not replying sooner; I was on holiday and didn’t have a big screen and keyboard to make a detailed reply.

This should be doable with some virtual switches and a Combination Switch. (Also you could do it with Luup.)

I’ll restate what I think your requirements are. Hopefully this matches your real requirements…

During day time, when the door opens, no lights turn on. It doesn’t matter if you are “at home” or not “at home” during the day time, the lights stay as they were (probably off).
During night time, nothing happens it you are “at home”. It doesn’t matter if the door opens when you are “at home”, nothing happens.
During night time AND when you are not “at home”, opening the door turns on the lights.
At any time, opening the door resets the “at home” virtual switch to “on”. This is needed in case you arrive home during the daytime, and then open the door later that night. In this case you don’t want any lights to come on for that second door opening.
Closing the door has no effect. It is up to you to turn off the lights manually.

[ol][li]Create a Virtual Switch, call it At Home.[/li]
[li]Create a scene, call it Leaving Home. Make this scene turn the At Home virtual switch off, and all your lights off. Make your remote button activate this scene.[/li]
[li]Create a Virtual Switch, call it Day time.[/li]
[li]Create a scene, call it Dawn. Make this scene turn the Day time virtual switch on. Assign a schedule that happens whenever you consider day time to start (it may be a fixed time of day, or it might be sunrise, whatever you want).[/li]
[li]Create a scene, call it Dusk. Make this scene turn the Day time virtual switch off. Assign a schedule that happens whenever you consider day time to stop (it may be a fixed time of day, or it might be sunset, whatever you want).[/li]
[li]Create a Combination Switch, call it Away and Night. Configure the switch with two conditions: At Home is off, Day time is off. Set the threshold to 2.[/li]
[li]Create a scene, call it Door opened. Make this scene turn the At Home virtual switch on, and make it press the Trigger Poke button on the Away and Night Combination Switch. Add a trigger from the door sensor: A sensor is tripped.[/li]
[li]Create a scene, call it Coming Home. Make this scene turn all your lights on. Add a trigger from the Away and Night Combination Switch: Triggered Poked while virtual switch is on.[/li][/ol]

Version 10 has been submitted, testing the Heliotrope plugin for sun position. With this you can build sunrise-sunset tests directly into a Combination Switch. Attached is an example that is on from sunset until roughly midnight.

Hello @futzle,

That is brilliant! What a fantastic combination (excuse the pun) of tools you have provided. Thank you for the great work.

I was on v7 and had to uninstall and reinstall to get to v8. I’ve got mine configured to auto-update, but it never does. What do you need to do to force an update of the plugin code without uninstalling and reinstalling the plugin?

see http://forum.micasaverde.com/index.php/topic,7750.msg78644.html#msg78644

Cool. Thanks.

@futzle,

I have your plug in and it is very helpful.

But i have a querry on which i need some guidance

If i have the conditions as created in the combination switch (i.e.night plus movement) and the virtual switch is activated. This activation should reset the countdown time.

The concept of the idea is to have during the day have a different timing than at night. ie 15 minutes light of and during the night time 2 minutes.

by using the virtual day/night switch i choose between one or the other timer

The querrie is how to reset the countime timmer triggered by the combination switch. The automatisation does not work

please advice

Huib

Huib, it’s not clear to me what you mean. I’ll restate what I think you mean, and then answer that. If I’m wrong about what you want, please correct me.

At any time of day, movement turns on a light and then, after the timer’s duration has completed, the light turns off. Any movement while the light is on will restart the timer.

During daytime, the timer is 15 minutes. During night time, the timer is 2 minutes.

[ol][li]Create a Countdown Timer device. Call it Light timer.[/li]
[li]Create a scene. Call it Daytime start. Create a schedule for this scene that comes on when daytime begins (sunrise or a fixed time). Go to the Advanced tab and add an action for Light timer: SetTimerDuration value 900 (15 minutes).[/li]
[li]Create a scene. Call it Night start. Create a schedule for this scene that comes on when daytime ends (sunset or a fixed time). Go to the Advanced tab and add an action for Light timer: SetTimerDuration value 120 (2 minutes).[/li]
[li]Now create scenes that connect the sensor to the timer and light devices, as described here.[/li][/ol]

Note that there are no Combination Switch devices in this setup. It’s not needed.

[list]

[ul][li]Create a scene, call it Door opened. Make this scene turn the At Home virtual switch on, and make it press the Trigger button on the Away and Night Combination Switch. Add a trigger from the door sensor: A sensor is tripped.[/li]
[li]Create a scene, call it Coming Home. Make this scene turn all your lights on. Add a trigger from the Away and Night Combination Switch: Triggered while virtual switch is on.[/li][/ul]

Hi Futzle,

Thank you for your reply and instructions, you interpreted my scenario perfectly! :slight_smile:

I followed your instructions to a “T”, but it does not seem to work…

Here is what happens…
I created all the virtual switches, combination switch and scenes.

I run the Leave Home scene followed by the Coming Home scene from MIOS, it works. All the lights turn on.

However, when I run the Leave Home scene, followed by the Door Opened scene, the lights do not turn on. This is not the expected behavior, as I am simulating the first opening of the door, not subsequent openings. It is the correct behavior for the scene to not turn the lights on after the At Home switch is on.

One issue I noticed is that in the Door Open scene, you state “make it press the Trigger button on the Away and Night Combination Switch.” I select the Trigger button and then save the scene. When I go back to look at it, it’s greyed out.

Is that a bug? I believe that this may be why the scenes are not functioning as they should.

Again, thank you for taking the time to assist me. :slight_smile:

Akash

@futzle,

possibly i a little to vague in my querry;

  1. i have in the bathroom a motion sensor
  2. a scenee starts the light in case of motion
  3. the change of status of the light triggers the count down times
  4. the motion sensor resets the countdown time by a scene
  5. at completion of the countdown times the light goes off by a scene

the lights goes on and after the set periode (15 minutes) the light goes off
bu also at night after 15 minutes the light will go off

now i have created avirtual swich (day/night) with is controled by the scedule
and in case it is day time the scene indicated above is valid

further i created a combination switch (virtual switch (day/night) and movement sensor) with triggers the combination swicht
i have created a second countdown time for 2 minutes which is also reseted by the movement sensor.
now the combination switch (if triggerd) must activate the 2 minuter timer, to have the light go out after two minutes after the last movement

in day time the line of events are; movement, light on, delay 15 minutes, light off
in night time the line of event is; night switch. movement; lights on, delay 2 miutes, light off

my problem is that i can not trigger a scene by the comnination switch to start the 2nd timer

thanks for you advice
huib

[quote=“akash1221, post:53, topic:171904”]One issue I noticed is that in the Door Open scene, you state “make it press the Trigger button on the Away and Night Combination Switch.” I select the Trigger button and then save the scene. When I go back to look at it, it’s greyed out.
Is that a bug? I believe that this may be why the scenes are not functioning as they should.[/quote]

It’s a visual bug in MiOS (see here). Check the scene’s Advanced tab to make sure the action is really there.

I’m not 100% sure, but I think what is happening is that the moment you open the door, the Away and Night combination switch is switching off an instant too soon (because opening the door turns on the At Home virtual switch at the same moment, actually a moment before). You can test this by temporarily taking out the action of Door Opened (step 7). Try this and tell me if it works. If yes, then the remaining task is to attach the deleted action to a different event (say, closing the door, or using a Countdown Timer with a two-second delay).

[quote=“huib, post:54, topic:171904”]possibly i a little to vague in my querry;

bu also at night after 15 minutes the light will go off

in night time the line of event is; night switch. movement; lights on, delay 2 miutes, light off[/quote]

Sorry huib, I’m still not getting it. Is the amount of delay 2 or 15 minutes at night?

I think it’s a mistake to put the motion sensor in as a condition of the Combination Switch. For momentary things you are better off using the Combination Switch’s Trigger Poke button, and using the events Triggered Poked while switch on and Triggered Poked while switch off. Keep the daytime/nighttime condition in the Combination Switch. See the example I’ve been concurrently showing Akash for an example.

(But it’s still possible to do away with the Combination Switch entirely and use one timer with durations that change for day and night, as I described earlier. Do try it, because I think it’s simpler than what you’re trying.)

It's a visual bug in MiOS (see [url=http://forum.micasaverde.com/index.php/topic,9425.msg63555.html#msg63555]here[/url]). Check the scene's Advanced tab to make sure the action is really there.

Yes, I confirmed that in the Advanced Tab it’s there.

You can test this by temporarily taking out the action of Door Opened (step 7). Try this and tell me if it works. If yes, then the remaining task is to attach the deleted action to a different event (say, closing the door, or using a Countdown Timer with a two-second delay).

By temporarily taking out the action, do you mean remove the door tripped trigger? (sorry for being a newb :P)

Thanks,
Akash

I mean here is your new step 7:

Create a scene, call it [b]Door opened[/b]. Make this scene press the [b]Trigger[/b] button on the [b]Away and Night[/b] Combination Switch. Add a trigger from the door sensor: [b]A sensor is tripped[/b].

Note that it’s missing something compared to the original step 7. Edit the scene so that it now matches the above, or delete it and start over from the (new) step 7.

This is just for testing. There’s still a flaw but I want to see if it’s helped with the reported problem.

[quote=“Dolphran, post:26, topic:171904”]Here’s how I used the Combination switch as a toggle:
Lets say I want to toggle a light on and off on each press of a scene controller button.
Let’s call the light LightToBeToggled
Let’s call the scene controller button SCB
Create Two Combination Switches - IsOff and IsOn
IsOff is set to be ON when the LightToBeToggled is OFF
IsOn is set to be ON when the LightToBeToggled is ON
Create Two Scenes - LTBTOn and LBTBOff
LTBTOn Turns on LightToBeToggled and is Triggered by Combination Switch IsOff being On
LTBTOff Turns off LightToBeToggled and is Triggered by Combination Switch IsOn being On
Now create a scene called ToggleLight
ToggleLight activates the Trigger button of BOTH IsOn and IsOff
ToggleLight is Triggered by SCB being pressed.

Now every press of SCB toggles the light.

I actually added another virtual switch EnableToggle, which is an AND condition in both IsOn and IsOff, This allows me to disable the toggle behavior.

Note that there is a race condition here which means that another possible outcome of this logic is the light continually blinking on and off. Since this doesn’t happen I assume that all triggers are evaluated before any scenes are activated. This could change in a future rev of Vera, and this setup would stop working. (I’m using UI5 1.5.408)[/quote]

This is exactly what I’m needing. Thank you. I am having a problem though. When I create ToggleLight and select the two trigger buttons and save. The trigger buttons do not seem to retain that setting. If I go back into the settings of that scene, the two triggers are no longer selected. I can’t seem to figure out why. Anyone ave any thoughts?

J

http://forum.micasaverde.com/index.php?topic=10995.msg80867.msg#80867