I though I’d create a separate discussion stream and make make use of the child board. (One for lolodomo)
A number of battery operated sensors (e.g thermometers) constantly keep transmitting, so I was wondering if the current plugin could be adapted (or a simple second version be created) that could work as a proximity sensor?
For example, if i was to identify a 433mhz device as ‘me’, it could be set to constantly look for me, and then when I’m found, I could set Vera up to then trigger suitable scenes according? (So basically the rfxrtx433 would also be able to act as a sort of Motion/Proximity Sensor)
Assuming all this is possible, it could then evolve (or a stand alone plugin be duplicated) to identify each member of the family, and maybe even be used to tell you if the kids (or a pet) have stray too far from the house?
Now, I’m not sure what the best RFXCOM supported 433mhz device to use for this, but tests with a simple Oregon Scientific temperature sensor shows it would work really well to identify people who are in the house, or if the car has pulled into the drive.
I see what you mean, that would be possible using sensors transmitting often like weather sensors.
I think you have already everything you need. What you have to check is the variable “BatteryDate” and more precisely the difference between the current date and time and BatteryDate. A soon as it exceeds a certain delay, it would mean the RFXtrx has not received data from this sensor during the elapsed time, and you could conclude that the sensor has moved away.
Thanks, if you ever feel like developing a spin off of your plugin in the future - you have one customer right here (maybe more??)
A benefit of having this as a separate plugin would be that it could be set up as a motion sensor device, so green when the item is in range an red when out (i.e tripped) it would also make it much easier for working in to scenes.
And (correct me if I’m wrong) but could it potentially use undecoded 433mhz protocols too, as all that’s required is some sort of 433mhz signal/device identifier that can be captured by the transciever - and cross referenced to a value you specify via the settings?
I’m looking to see what the smallest battery operated 433mhz device is out there that regulary transmits information.
UPDATE - Some of the 433.92mhz devices I’m looking at include the anti-lost marketed ones, such as
Can anyone help me with the code for a proximity sensor, I’d like it to switch on a Virtual Switch if a device is not found for a period of time, however the following seems to go ok, but does not seem to work
-- Picking the devices
local SENSOR = 42 -- The anti-lost sensor device number
local VSWITCH = 15 -- The virtual switch device number
-- Add any parameters
local DELAY = 6 -- Seconds
-- Picking the services
local SES_SID = "urn:micasaverde-com:serviceId:HaDevice1"
local VSWI_SID = "urn:upnp-org:serviceId:VSwitch1"
luup.call_delay( "turnOnVswitch", DELAY)
-- Turn on the virtual switch if the anti-lost sensor hasn't been updated in the past x seconds
function turnOnVswitch()
local update = luup.variable_get( SES_SID, "BatteryDate", SENSOR)
if (os.time() - update>= DELAY) then
luup.call_action( VSWI_SID, "Status", {newTargetValue= "1"}, VSWITCH)
end
end
I’m trying various versions of the above but no joy so far…
[size=2]UPDATE: I realised I had the wrong service listed, i had urn:upnp-org:serviceId:TemperatureSensor1 rather than urn:micasaverde-com:serviceId:HaDevice1, but it still does not work .[/size]
[code]-- Picking the devices
local SENSORID= 42 – The anti-lost sensor device ID number
local VSWITCHID = 15 – The virtual switch device ID number
– Picking the services
local SENSERV = “urn:micasaverde-com:serviceId:HaDevice1”
local VSWISERV = “urn:upnp-org:serviceId:VSwitch1”
– Run
luup.call_action( “turnOnVswitch”)
– Function is to turn on the virtual switch if the anti-lost sensor hasn’t been updated in the past x seconds
function turnOnVswitch()
local update = luup.variable_get(SENSERV, “BatteryDate”, SENSORID)
if (os.time() - update >= 6) then
luup.call_action( VSWISERV, “Status”, {newTargetValue= “1”}, VSWITCHID)
end
end[/code]
L’action ne s’appelle pas “Status”. Vérifie dans le wiki, je n’ai plus le nom en tête.
Et rajoute un luup.log(“toto”) dans le if pour être certain que tu passes bien dedans.
Thanks for responding lolodomo - and thank god for google translate (I recall some French from school but not enough to talk technical
OK, now ‘Status’ is the binary value on the Virtual Switch plugin variable for on or off, but thinking about it, I will change the code so it runs a scene when it does not see the ‘sensor’.
Let me see if I can get that to work. (This is my first real attempt a coding anything
;D ;D ;D
Sorry, it was my intention to use French. I am often at the same time on two forums, this one and another french forum, that could explain my mistake.
I was just telling you that Status is not the name of the callback.
Don’t forget to put quotes around “SetLoadLevelTarget”.
So why does the Virtual Switch Variable list shows the on or off (1 or 0) value in a field called 'Status' - is that irrelevant then?
The variables that a device has and the actions that you perform on the device exist in two separate namespaces. So you’ll find yourself using one set of names with luup.variable_set() and a different set of names for luup.call_action().
The other piece of code I tried (to avoid the Virtual Switch) was to run a scene when the sensor was out of range - pulling bits form other posts i came up with the following, but this did not work either.
[code]-- Picking the devices
local SENSORID= 42 – The anti-lost sensor device ID number
– Picking the services
local SENSERV = “urn:micasaverde-com:serviceId:HaDevice1”
– Run
luup.call_action( “AlarmBell”)
– Function is to trigger an alarm via a scene on if the anti-lost sensor has not been updated in the past x seconds
function AlarmBell()
local update = luup.variable_get(SENSERV, “BatteryDate”, SENSORID)
if (os.time() - update >= 3) then
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”,“RunScene”,{SceneNum=“18”},0)
end
end[/code]
The log suggests something like " GetLuaInterface can’t find device type"
Forgive the question, but what am I missing?
Also, this is just a one off check, how do I make it check regularly?
Sorry to keep asking for help, but I just love the scope of using the rfxrtx plugin as a proximity (Anti-Lost) sensor, but being such a novice, coding does not come naturally.
The code I’ve got so far is the last one posted above, but to help I’ve pasted it in again below, my expectation is that if the batteryDate is more that 3 seconds old that the OS clock time, then it would run a scene?
[code]-- Picking the devices
local SENSORID= 42 – The anti-lost sensor device ID number
– Picking the services
local SENSERV = “urn:micasaverde-com:serviceId:HaDevice1”
– Run
luup.call_action( “AlarmBell”)
– Function is to trigger an alarm via a scene on if the anti-lost sensor has not been updated in the past x seconds
function AlarmBell()
local update = luup.variable_get(SENSERV, “BatteryDate”, SENSORID)
if (os.time() - update >= 3) then
luup.call_action(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”,“RunScene”,{SceneNum=“18”},0)
end
end[/code]
It tells me message sent successfully but nothing occurs.
I’d love to be able to create a standard Motion Sensor device that simply looks for a defined