Triggering from energy use

I have a CPAP machine plugged into a SmartSwitch, and I want to trigger a scene to turn out lights when the CPAP starts drawing power. The SmartSwitch is always left on, but the power draw is usually zero.

I’m new to this environment, but the best approach I can come up with is to schedule a trigger every couple of minutes for the scene which has attached Lua to check the wattage value of the smart switch and bail out if the power draw is zero.

However, this polling seems silly. Can anyone suggest a better approach?

Go look on the Notifications tab. Is there an event for “power goes over”? If so, you could create a scene that uses this event as a trigger.

Edit: no, there’s not. That’s a silly omission. Another candidate for my Combination Virtual Switch, I guess.

@Dogar,

The concept of Power Event Device was cover by @AP15e who has since removed open support from the forum. His concept was covered in thread http://forum.micasaverde.com/index.php/topic,8291.msg53692.html#msg53692.

Being a CPAP could be is a critical machine and normally only draws power during supply, I appreciate what you are trying to achieve most robust solution. I would still proceed down the Sceen and lupp coding run on schedule to update Variable Container plugin. However, if desired, I belive you may get a better picture of what is occurring if you tie a few plugings togther.

  1. Create a Sceen and lupp coding to run on schedule (interval based - not polling) to monitor the Watts and update Variable Container. You could also capture date/time if required.
  2. Create a second Sceen to trigger off Variable Container as is contains (as @futzle identifies) values goes above to trigger turning off the lights.
  3. If required, you can no do the reverse and turn the lights back on, create a third Sceen to trigger off Variable Container values goes below etc… turn on the lights.

If you wanted to capture this holistically to establish the pattern on which this is occurring, look at capturing the history using “dataMine” plugin.

Other options being this type of equipment could be to create flashing lights but one of the always stated, if this is used in life support device this is not the recommended product.

Example
local TimeVentAct = os.date()
local lul_watts1=luup.variable_get(“urn:micasaverde-com:serviceId:EnergyMetering1”,“Watts”, Comment1 )
local lul_tmp = luup.variable_get(“urn:upnp-org:serviceId:SwitchPower1”, “Status”, Comment1)
if (( tonumber(lul_watts1)>0 ) and (lul_tmp == “1”))
then
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”,“Variable1”,TimeVentAct, Comment2)
luup.variable_set(“urn:upnp-org:serviceId:VContainer1”,“Variable2”,lul_watts1, Comment2)
else
return false
end

Comment 1 - this is the device id of the Smartswitch
Comment 2 - this is the device id of the Variable Container

I put two conditions in the above and that is the device is on and consuming power. You could also change the “Variable” in the Variable Container e.g. Variable1 to Date and Variable2 to Watts etc and that way it is human readable; however, if you do this, you’ll need to reflect this in the code. You’ll also need to consider reset the Variable Container back to zero and this can be achieve by adding a another Scene.

Also, there’s an open feature request asking power events be added for the SmartSwitch.

The SmartSwitch is a really nice device and one of my favorites, but I’ve experienced a few bugs in using them, so using them commercially, or for critical setups should be carefully considered.

A couple of things I’ve noticed are:

  1. Occasionally the device does not report wattage.
  2. The device will lock up, requiring removal of power to reset.
  3. The device will turn On or Off unexpectedly.