We have moved at community.getvera.com

Author Topic: Christmas Lights off when raining  (Read 4210 times)

Offline mikemsd

  • Jr. Member
  • **
  • Posts: 86
  • Karma: +0/-0
Christmas Lights off when raining
« on: December 04, 2010, 12:18:20 pm »
In case anyone wants to do something similar, I thought I would share my LUA code. There's probably a better way to write this, but I'm an amateur. If anyone has any suggestions for me on how to possibly better write this, I'd appreciate comments.

This first one is set to run 15 Minutes before Sunset and 1 Hour before Sunrise. It checks if one of the various rain conditions is active, and if so, it doesn't bother turning the lights on.

Code: [Select]
local lul_tmp = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1","Condition",9)
if (lul_tmp=="Showers" or lul_tmp=="Rain" or lul_tmp=="Rain Showers" or lul_tmp=="Thunderstorm" or lul_tmp=="Scattered Showers" or lul_tmp=="Light rain" or lul_tmp=="Heavy Rain" or lul_tmp=="Rain and Snow")
then
else
  luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="1" },15)
end

This second one is set to run every 5 minutes to see if it has started raining, and if so, turn off the lights.

Code: [Select]
local lul_tmp = luup.variable_get("urn:upnp-micasaverde-com:serviceId:Weather1","Condition",9)
if (lul_tmp=="Showers" or lul_tmp=="Rain" or lul_tmp=="Rain Showers" or lul_tmp=="Thunderstorm" or lul_tmp=="Scattered Showers" or lul_tmp=="Light rain" or lul_tmp=="Heavy Rain" or lul_tmp=="Rain and Snow")
then
  luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="0" },15)
end

There is a third scene that runs at Midnight, and also at 15 Minutes after Sunrise to turn off the Lights.
Vera2 (UI4 1.5.408), 2x Trane Thermostats, 9x GE 45606 Dimmers, 1x GE 45613 3-Way Dimmer kit, 1x Intermatic HA04 Outdoor Module, 1x Intermatic HA09 Remote.

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Christmas Lights off when raining
« Reply #1 on: December 05, 2010, 11:39:00 am »
That looks about right.  At some point this will get fixed:
    http://bugs.micasaverde.com/view.php?id=1038

and then you'll be able to do it without Luup code, as the Weather Plugin will send "events" that you can use in regular Scenes.  That'll also avoid the need for the polling code.


NOTE: The Weather plugin only refreshes the Weather data every 30 minutes.  If you'd find it more useful, it's possible for me to add an event to represent when the data is modified, then you could attach to that instead of using call_timer.

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: Christmas Lights off when raining
« Reply #2 on: December 05, 2010, 12:51:28 pm »
Quote
If you'd find it more useful, it's possible for me to add an event

Yes, please. One could even think of an event for 'weather condition has changed' etc.

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Christmas Lights off when raining
« Reply #3 on: January 03, 2011, 03:42:33 pm »
Quote
If you'd find it more useful, it's possible for me to add an event

Yes, please. One could even think of an event for 'weather condition has changed' etc.

@Ap15e,
I tried this last night, and had a modified .json file that would give me the events... in theory.  I could get as far as registering the notification event in Vera, but it never fired.  It was also very "hacky" as you had to enter a value on "0" into a field during the Event Creation (it defaulted to "0", but was still ugly).

I've attached it if you'd like to experiment with it a little, but it's not working for me right now, and certainly not ready for prime time.

In theory, it would fire each time the Plugin refreshes any of the data fields, so would only be useful for people doing Luup-based scenes.

Offline strangely

  • Beta Testers
  • Master Member
  • *****
  • Posts: 3722
  • Karma: +34/-2
  • Vera 1,3 & V light
Re: Christmas Lights off when raining
« Reply #4 on: January 03, 2011, 04:31:32 pm »
This would be a nice addition to the EtherRain plugin so that it could turn off watering if it was raining... if the main issue ever gets fixed be fixed that is.
Kwickset locks, HA01C, HA14C, HA02C, HA03C, HA05C, HA04C, HA07C, HA09C, Aeon HEM, GE 45604, 45606, 45609, ZDP100, VRF01-1LZ, WDTC-20, HA18WD, WDHA-12R, HRDS1, HM-TS001, AC1-ZW, TV-IP110, BL-C210A, LUUP control- EtherRain8, DSC Alarm, HDMI matrix, HR24-200, Panasonic TV, SQblaster