We have moved at community.getvera.com

Author Topic: Scene scripting help  (Read 3711 times)

Offline ExHempKnight

  • Sr. Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Scene scripting help
« on: October 21, 2011, 11:50:36 am »
I humbly ask for scripting help for a scene.

I've installed the ActiveRFID plugin, and have successfully installed & tested a RFID receiver and 2 key for transmitters (one for me, one for the GF). I also have a Z-wave thermostat.

I would like to create a scene that turns the heat to a lower setpoint when both her and I are out, and turns it back up when one or both of us are home.

For example, she leaves for work before I do. I want the heat to stay at 67, until I leave, at which point it kicks down to 63. Then when she gets home later, it heats back up to 67. Then say we go out to dinner... It should kick back down to 63 until we get home. And so on and so forth.

The only other thing I'm unsure of, is whether or not this will interfere somehow with the scene I currently have which kicks the heat down to 63 when we go to bed.

Any help would be greatly appreciated.

Offline mysticjay

  • Full Member
  • ***
  • Posts: 184
  • Karma: +1/-1
Re: Scene scripting help
« Reply #1 on: October 21, 2011, 11:16:34 pm »
I would imagine something like this should work:

1. Create a New scene

2. Go to Events and Add a New Event that Identifies the trigger from your RFID when you leave

3. Go to commands and select your thermostat and set to what you want it.

Repeat steps above for the trigger from your RFID when you come back  (by creating another scene)

Repeat steps above (by creating 2 additional scenes for your GF's RFID trigger)

So you would end up with 4 scenes. (Or Lua code could simplify this)


Vera 2 (1.1.1338), Trane TZEMT400BB3,ML IWD600S(2), ML IWS1000S(2) , FI8905W, Aeon DSB04100-ZWUS, GE 45609(2), GE 45606(2), GE 45608, GE 45614 (5), LFM-20(2), Kwikset 99100-011 (5) , Hawking HRMD1, Droid X and Xoom as Remotes, Harmony Link

Offline mysticjay

  • Full Member
  • ***
  • Posts: 184
  • Karma: +1/-1
Re: Scene scripting help
« Reply #2 on: October 21, 2011, 11:20:27 pm »
If I may ask, what  RFID receiver and transmitters you have working with the ActiveRFID plugin?
Vera 2 (1.1.1338), Trane TZEMT400BB3,ML IWD600S(2), ML IWS1000S(2) , FI8905W, Aeon DSB04100-ZWUS, GE 45609(2), GE 45606(2), GE 45608, GE 45614 (5), LFM-20(2), Kwikset 99100-011 (5) , Hawking HRMD1, Droid X and Xoom as Remotes, Harmony Link

Offline ExHempKnight

  • Sr. Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Re: Scene scripting help
« Reply #3 on: October 22, 2011, 12:44:35 am »
If I may ask, what  RFID receiver and transmitters you have working with the ActiveRFID plugin?

I got the USB RSSI receiver and 2 8m transmitters from Cliste Electronics. Though it appears their website has since closed.

Offline mysticjay

  • Full Member
  • ***
  • Posts: 184
  • Karma: +1/-1
Re: Scene scripting help
« Reply #4 on: October 22, 2011, 01:13:06 am »
@ExHempKnight -thx for the info.

I think 4 scenes is all you need. I have a sensor that does the following - I was able to get that working with 2 scenes..

1. When sensor gets tripped(door opens), call my cell phone and connect home phone

2. When the door opens(sensor), turn certain lights on and turn them off (only if they were off to start with, if they were on before, I don't want to turn them off)...

I assume the RFID proximity should work the same way.... similar to a sensor tripping event.
Vera 2 (1.1.1338), Trane TZEMT400BB3,ML IWD600S(2), ML IWS1000S(2) , FI8905W, Aeon DSB04100-ZWUS, GE 45609(2), GE 45606(2), GE 45608, GE 45614 (5), LFM-20(2), Kwikset 99100-011 (5) , Hawking HRMD1, Droid X and Xoom as Remotes, Harmony Link

Offline ExHempKnight

  • Sr. Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Re: Scene scripting help
« Reply #5 on: October 22, 2011, 02:18:25 pm »
Thanks for the suggestion, but unfortunately, it isn't that simple. I just set up the 4 scenes you described.

When both transmitters are home, heat is up.

When just one transmitter leaves, heat goes down.

I also tried it with just 2 scenes, with 2 events per scene (both transmitters), with the same result as above.

I want the heat to be low only when BOTH sensors leave. It seems the scenes can do "IF" functions, just not "AND" functions. Looks like I need some Lua.

Offline ExHempKnight

  • Sr. Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Re: Scene scripting help
« Reply #6 on: October 26, 2011, 08:18:27 pm »
So I'm still stumped. Can anyone provide the beginnings of code to be able to make the system perform as I'd like? I'm really new at Lua coding.

Offline mysticjay

  • Full Member
  • ***
  • Posts: 184
  • Karma: +1/-1
Re: Scene scripting help
« Reply #7 on: October 26, 2011, 09:44:17 pm »
Here's the basics :

1. You'd want to remember you getting out, your GF getting out (or both out) which you could do so by something like this

Set a Variable to remember that you're out (this should be in your RFID lua code when the RFID gets tripped), You could set this Variable for the Thermostat device - where 10 below is the device # - So presumably for the Thermostat

a. RFID 1 lua code (in the scene where your rfid is tripped for out)
luup.variable_set("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat","ExHempKnight_RFID", "OUT", 10)


b. RFID 2 lua code ( in the scene where your gf rfid is tripped for out) - Again change 10 below to your Thermostate Device #
luup.variable_set("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat","ExHempKnight_GF_RFID", "OUT", 10)



2. Follow this with checking both variables (on both your scene and gf scene)

local ExHempKnight_OUT = luup.variable_get("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat","ExHempKnight_RFID", 10)
local ExHempKnight_GF_OUT = luup.variable_get("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat","ExHempKnight_GF_RFID", 10)


3. Set the Thermosate for AND condition


if ExHempKnight_OUT=="OUT" and ExHempKnight_GF_OUT=="OUT" then
   --Set thermostat to desired heat set point, below 10 is your thermo device id, I'm assuming if you give value
   --63 is the temp you want to set when both or out
   luup.call_action("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat","SetCurrentSetpoint",{ NewCurrentSetpoint="63" },10)
end


4. Fill in for the other conditions :)

Hope this gets you started.... Here are the steps and this should work for when both of you are out and temp set for 63 - let me know if that works as I thought it would....

1. Create a scene with Event for your RFID is OUT,  Add the following code in Lua Tab
local serviceVar="urn:upnp-org:serviceId:TemperatureSetpoint1_Heat"
local thermoID=10

--SET Variable that you're out
luup.variable_set(serviceVar,"ExHempKnight_RFID", "OUT", thermoID)

--GET variabels et
local ExHempKnight_OUT = luup.variable_get(serviceVar,"ExHempKnight_RFID", 10)
local ExHempKnight_GF_OUT = luup.variable_get(serviceVar,"ExHempKnight_GF_RFID", 10)

--Do Both are out condition

if ExHempKnight_OUT=="OUT" and ExHempKnight_GF_OUT=="OUT" then
       --63 is the temp you want to set when both or out
   luup.call_action(serviceVar,"SetCurrentSetpoint",{ NewCurrentSetpoint="63" },10)
end



2. Create a scene with Event for your GF RFID is OUT,  Add the following code in Lua Tab
local serviceVar="urn:upnp-org:serviceId:TemperatureSetpoint1_Heat"
local thermoID=10

--SET Variable that you're out
luup.variable_set(serviceVar,"ExHempKnight_GF_RFID", "OUT", thermoID)

--GET variabels et
local ExHempKnight_OUT = luup.variable_get(serviceVar,"ExHempKnight_RFID", 10)
local ExHempKnight_GF_OUT = luup.variable_get(serviceVar,"ExHempKnight_GF_RFID", 10)

--Do Both are out condition

if ExHempKnight_OUT=="OUT" and ExHempKnight_GF_OUT=="OUT" then
       --63 is the temp you want to set when both or out
   luup.call_action(serviceVar,"SetCurrentSetpoint",{ NewCurrentSetpoint="63" },10)
end




« Last Edit: October 26, 2011, 10:05:25 pm by mysticjay »
Vera 2 (1.1.1338), Trane TZEMT400BB3,ML IWD600S(2), ML IWS1000S(2) , FI8905W, Aeon DSB04100-ZWUS, GE 45609(2), GE 45606(2), GE 45608, GE 45614 (5), LFM-20(2), Kwikset 99100-011 (5) , Hawking HRMD1, Droid X and Xoom as Remotes, Harmony Link

Offline ExHempKnight

  • Sr. Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Re: Scene scripting help
« Reply #8 on: October 27, 2011, 07:16:08 pm »
local ExHempKnight_OUT = luup.variable_get("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat","ExHempKnight_RFID", 10)
local ExHempKnight_GF_OUT = luup.variable_get("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat","ExHempKnight_GF_RFID", 10)

local ExHempKnight_OUT = luup.variable_get("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat","ExHempKnight_RFID", 10)
local ExHempKnight_GF_OUT = luup.variable_get("urn:upnp-org:serviceId:TemperatureSetpoint1_Heat","ExHempKnight_GF_RFID", 10)



In the above sections... Are the 10's for the thermostat ID, or the RFID fob ID's?

Offline mysticjay

  • Full Member
  • ***
  • Posts: 184
  • Karma: +1/-1
Re: Scene scripting help
« Reply #9 on: October 27, 2011, 07:32:18 pm »
Use the following(10 is for thermo id), I just realized why it was bit confusing -- We're not doing anything with the RFID device ID's because in the scene event, you would select the particular RFID device is tripped..

1. Create a scene with Event for your RFID is OUT,  Add the following code in Lua Tab

Code: [Select]
local serviceVar="urn:upnp-org:serviceId:TemperatureSetpoint1_Heat"
local thermoID=10

--SET Variable that you're out
luup.variable_set(serviceVar,"ExHempKnight_RFID", "OUT", thermoID)

--GET variabels et
local ExHempKnight_OUT = luup.variable_get(serviceVar,"ExHempKnight_RFID", thermoID)
local ExHempKnight_GF_OUT = luup.variable_get(serviceVar,"ExHempKnight_GF_RFID", thermoID)

--Do Both are out condition

if ExHempKnight_OUT=="OUT" and ExHempKnight_GF_OUT=="OUT" then
       --63 is the temp you want to set when both or out
   luup.call_action(serviceVar,"SetCurrentSetpoint",{ NewCurrentSetpoint="63" },thermoID)
end


2. Create a scene with Event for your GF RFID is OUT,  Add the following code in Lua Tab

Code: [Select]

local serviceVar="urn:upnp-org:serviceId:TemperatureSetpoint1_Heat"
local thermoID=10

--SET Variable that you're out
luup.variable_set(serviceVar,"ExHempKnight_GF_RFID", "OUT", thermoID)

--GET variabels et
local ExHempKnight_OUT = luup.variable_get(serviceVar,"ExHempKnight_RFID", thermoID)
local ExHempKnight_GF_OUT = luup.variable_get(serviceVar,"ExHempKnight_GF_RFID", thermoID)

--Do Both are out condition

if ExHempKnight_OUT=="OUT" and ExHempKnight_GF_OUT=="OUT" then
       --63 is the temp you want to set when both or out
   luup.call_action(serviceVar,"SetCurrentSetpoint",{ NewCurrentSetpoint="63" },thermoID)
end



« Last Edit: October 27, 2011, 07:38:56 pm by mysticjay »
Vera 2 (1.1.1338), Trane TZEMT400BB3,ML IWD600S(2), ML IWS1000S(2) , FI8905W, Aeon DSB04100-ZWUS, GE 45609(2), GE 45606(2), GE 45608, GE 45614 (5), LFM-20(2), Kwikset 99100-011 (5) , Hawking HRMD1, Droid X and Xoom as Remotes, Harmony Link

Offline ExHempKnight

  • Sr. Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
Re: Scene scripting help
« Reply #10 on: October 28, 2011, 05:00:12 pm »
I'm assuming I change the thermostat ID to it's device number in my system, and change the Exhempknight_RFID and Exhempknight_GF_RFID to the actual RFID devices names (just our first names)? Like this:

Code: [Select]
local serviceVar="urn:upnp-org:serviceId:TemperatureSetpoint1_Heat"
local thermoID=3

--SET Variable that you're out
luup.variable_set(serviceVar,"Chris", "OUT", thermoID)

--GET variabels et
local Chris_OUT = luup.variable_get(serviceVar,"Chris", thermoID)
local Emily_OUT = luup.variable_get(serviceVar,"Emily", thermoID)

--Do Both are out condition

if Chris_OUT=="OUT" and Emily_OUT=="OUT" then
       --63 is the temp you want to set when both or out
   luup.call_action(serviceVar,"SetCurrentSetpoint",{ NewCurrentSetpoint="63" },thermoID)
end

Offline mysticjay

  • Full Member
  • ***
  • Posts: 184
  • Karma: +1/-1
Re: Scene scripting help
« Reply #11 on: October 28, 2011, 06:46:27 pm »
It is not needed for those to be the RFID device names - but what you have there should work. We're simply setting a variable to some value, this could be anything you want.
Vera 2 (1.1.1338), Trane TZEMT400BB3,ML IWD600S(2), ML IWS1000S(2) , FI8905W, Aeon DSB04100-ZWUS, GE 45609(2), GE 45606(2), GE 45608, GE 45614 (5), LFM-20(2), Kwikset 99100-011 (5) , Hawking HRMD1, Droid X and Xoom as Remotes, Harmony Link