Page 8 of 19
Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 16:23
by korniza
Still I have
FHEM as prefered solution as it supports even more PRESENCE types (wifi, SNMP, BLE remote/local). it is 100% stable and memory footprint is so small. The delay is less than 3 sec!
The only issue is that community is german speaking so for people that do not understand German, google translate is their friend.
Also it did not read battery or button status of beacon which would be great to have.
Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 20:08
by micbou
Anybody out the that wouldn't mind helping me get started here? I just want to use the beacon to set to HOME and AWAY for myself and my wife.
I appreciate all the help
Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 20:29
by jmleglise
Micbou,
Describe a bit more your need. What do you want to do with this information ?
Because, you already have this information in uservariable.
If you succeed to install the system, you have done the most difficult.
Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 20:35
by micbou
jmleglise wrote:Micbou,
Describe a bit more your need. What do you want to do with this information ?
Because, you already have this information in uservariable.
If you succeed to install the system, you have done the most difficult.
This is what I want. When I (Tag_Michel with device IDX 23 ) am not home I want a switch to show AWAY and the same for my wife (Tag_Vanessa with device IDX 20). Obviously I'd like it to show 'HOME' when I am at home. When both me and my wife (Tag_Vanessa with device IDX 20) aren't in the house I want the alarm to trigger to 'AWAY'. Also when I come home I want a TTS switch to welcome me home with some news.
Is there a way to do this w/ Blocky? I have build 2 virtual switches, but they don't show an off and on state.
Thanks again for your patience and help...
To add: my log stopped working. When checking status I get
Code: Select all
Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.
Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 22:00
by jmleglise
If you want to go into alarm and TTS things, I advise you to start discover Lua. You 're going to struggle a bit several days, and then you will go much more far than with blocky.
However , that is a starting point in blocky :

- blocky_presence.jpg (25.88 KiB) Viewed 5264 times
Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 22:09
by micbou
jmleglise wrote:If you want to go into alarm and TTS things, I advise you to start discover Lua. You 're going to struggle a bit several days, and then you will go much more far than with blocky.
However , that is a starting point in blocky :
blocky_presence.jpg
thanks. Could you help me 1 step back and show me how to add the 'away' and 'home' status?
Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 22:16
by jmleglise
I don't undesrtand your question . What do you call away and home status ?
Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 22:18
by micbou
jmleglise wrote:I don't undesrtand your question . What do you call away and home status ?
in your blocky you state if the tags are "AWAY" the alarm goes on. How do I set the switch to "AWAY"
like in the wiki where can I get the uservariable from?

Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 22:26
by jmleglise
- You create in domoticz manually 1 uservariable for each beacon.
- the python script update those uservariables accordingly of the presence of the beacons.
- you use those uservariables in your domoticz logic
So if your installation of the script (from the wiki) works, that means that the uservariables are always up to date : Away, home, or the RSSI of the beacon, accordingly to the mode that you chose in the python script.
Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 22:32
by micbou
jmleglise wrote:- You create in domoticz manually 1 uservariable for each beacon.
- the python script update those uservariables accordingly of the presence of the beacons.
- you use those uservariables in your domoticz logic
So if your installation of the script (from the wiki) works, that means that the uservariables are always up to date : Away, home, or the RSSI of the beacon, accordingly to the mode that you chose in the python script.
Ok so here's what I did.
SETUP > User Variable
Variable name Tag_Michel
Variable type: String
Variable Value AWAY
ADD
Variable name Tag_Vanessa
Variable type: String
Variable Value AWAY
ADD
is that all? So does my domoticz now know when the value isn't AWAY because it sends a signal to the RPi3 and do I also need to set up switches?
Again, sorry for being such a noob and thanks for you patience.
Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 22:52
by jmleglise
It's Ok for the uservariable.
And,
-Did you configure the python script ?
-Is the uservariable updated accordingly to the presence of beacon ? Refresh the domoticz uservariable page : "AWAY" shall be replaced by "Home" or a negativ number.
Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 23:09
by micbou
Its working! Pfewwww... this was a tough one for me.
Lets hope I can keep the service up
Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 23:24
by jmleglise
Switch On or Off an "Alarm" Switch automatically.
Assume that the beacon uservariables begin by "Tag"
It's a variable script !
script_variable_autoArmAlarm.lua
Code: Select all
--Variable scripts receive 7 tables from Domoticz: otherdevices, otherdevices_lastupdate, otherdevices_svalues, otherdevices_idx, , uservariables, uservariables_lastupdate and uservariablechanged
commandArray = {}
--beaconAway=0
beaconHome=0
for variableName, variableValue in pairs(uservariables) do
if string.sub(variableName,1,3)=="Tag" and variableValue ~= "AWAY" then
beaconHome=beaconHome+1
--else
-- beaconAway=beaconAway+1
end
end
if otherdevices['Alarm'] == 'On' and beaconHome>=1 then -- switch Off Alarm because 1 beacon come back Home
table.insert (commandArray, { ['Alarm'] ='Off' } )
-- print("switch Off")
elseif otherdevices['Alarm'] == 'Off' and beaconHome==0 then -- switch On Alarm because all beacon are away
table.insert (commandArray, { ['Alarm'] ='On' } )
-- print("switch On")
end
return commandArray
Re: How to check presence of Beacon ?
Posted: Saturday 21 May 2016 23:36
by micbou
jmleglise wrote:Switch On or Off an "Alarm" Switch automatically.
Assume that the beacon uservariables begin by "Tag"
It's a variable script !
script_variable_autoArmAlarm.lua
Code: Select all
--Variable scripts receive 7 tables from Domoticz: otherdevices, otherdevices_lastupdate, otherdevices_svalues, otherdevices_idx, , uservariables, uservariables_lastupdate and uservariablechanged
commandArray = {}
--beaconAway=0
beaconHome=0
for variableName, variableValue in pairs(uservariables) do
if string.sub(variableName,1,3)=="Tag" and variableValue ~= "AWAY" then
beaconHome=beaconHome+1
--else
-- beaconAway=beaconAway+1
end
end
if otherdevices['Alarm'] == 'On' and beaconHome>=1 then -- switch Off Alarm because 1 beacon come back Home
table.insert (commandArray, { ['Alarm'] ='Off' } )
-- print("switch Off")
elseif otherdevices['Alarm'] == 'Off' and beaconHome==0 then -- switch On Alarm because all beacon are away
table.insert (commandArray, { ['Alarm'] ='On' } )
-- print("switch On")
end
return commandArray
ah, this I can read. Thanks!
So I just go to 'SETUP' > 'More options' > 'Event's > LUA and paste above and then Im good to go?
Re: How to check presence of Beacon ?
Posted: Sunday 22 May 2016 0:47
by jmleglise
Yes probably,
But as far as I'm concerned, I use the old way : I prefer to write the script in filesystem.
=> in domoticz/script/lua
Re: How to check presence of Beacon ?
Posted: Sunday 22 May 2016 0:57
by micbou
jmleglise wrote:Yes probably,
But as far as I'm concerned, I use the old way : I prefer to write the script in filesystem.
=> in domoticz/script/lua
that's a few steps to advanced for me
I'm noticing that the NUT's sometimes go into 'AWAY' status even though they are more than in reach of the Bluetooth signal. Do you have this experience as well?
Re: How to check presence of Beacon ?
Posted: Sunday 22 May 2016 10:10
by jmleglise
With my hardware, up to a distance of 7m, I've experienced no probleme. Beyond, it's more uncertain. If you need a distance between 7-12m, you should, extend the timeout parameter in the python script. Perhaps, the distance depends of the battery life too.
Re: How to check presence of Beacon ?
Posted: Sunday 22 May 2016 13:46
by korniza
Don't take it wrong, but I like to share the experience I have using FHEM.
I just installed another raspberry to the rooms that NUT get out of range. I installed on the new raspberry (slave) a bluetooth dongle and followed the guide on
http://www.fhemwiki.de/wiki/Anwesenheitserkennung
On slave device there is no domoticz required of full FHEM installation! just 3 services to run and using collectord I can now walk around home without losing the presence flag. As FHEM supports rooms, now I know where any bluetooth device is present! So for the panic buttons it is usefull to know where button is pressed and run different scenarios (if it pressed on bedroom, turn on the bedroom lamp etc).
Next step: Add an extra raspberry or lower power device to garden attached with usb bluetooth dongle, so I can get garden lights turned on/off.
Re: How to check presence of Beacon ?
Posted: Wednesday 25 May 2016 23:09
by jmleglise
hello everybody,
To fine tune the timeout of each beacon, here is a new script to understand how your beacon works :
Code: Select all
wget https://raw.githubusercontent.com/jmleglise/mylittle-domoticz/master/Presence%20detection%20%28beacon%29/test_beacon.py
Re: How to check presence of Beacon ?
Posted: Thursday 26 May 2016 20:17
by micbou
@ korniza , I have two questions as I like what you've did:
- how did you configure the panic button on the NUTs?
- how to run FHEM next to Domoticz in slave mode?
Thanks