Scene scripting help

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.

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)

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.

@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.

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.

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.

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)

  1. 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)

  1. 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

  1. Fill in for the other conditions :slight_smile:

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

  1. 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

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?

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
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
  1. 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", 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

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]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[/code]

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.