How to check presence of Beacon ?

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.
korniza
Posts: 175
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi
Domoticz version: V3.6028
Location: Greece
Contact:

Re: How to check presence of Beacon ?

Postby korniza » Saturday 21 May 2016 16:23

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. :lol:
Also it did not read battery or button status of beacon which would be great to have.
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)

micbou
Posts: 88
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi
Domoticz version:
Location: NL
Contact:

Re: How to check presence of Beacon ?

Postby micbou » Saturday 21 May 2016 20:08

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

jmleglise
Posts: 190
Joined: Tuesday 13 January 2015 0:27
Target OS: Raspberry Pi
Domoticz version: V3.5113
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Postby jmleglise » Saturday 21 May 2016 20:29

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.
Raspberry Pi2 + RFXTRX433E + KMTronic USB relay card
Blinds Somfy RTS, Blinds Bubendorff, Portal Somfy Evolvia 400, IP Video Doorbell ATZ-DBV01P, chacon IO, Oregon THN132ES, THN122N, Chinese PIR sensor PT2262, Bluetooth low energy dongle, iBeacon

micbou
Posts: 88
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi
Domoticz version:
Location: NL
Contact:

Re: How to check presence of Beacon ?

Postby micbou » Saturday 21 May 2016 20:35

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.

jmleglise
Posts: 190
Joined: Tuesday 13 January 2015 0:27
Target OS: Raspberry Pi
Domoticz version: V3.5113
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Postby jmleglise » Saturday 21 May 2016 22:00

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
blocky_presence.jpg (25.88 KiB) Viewed 1002 times
Raspberry Pi2 + RFXTRX433E + KMTronic USB relay card
Blinds Somfy RTS, Blinds Bubendorff, Portal Somfy Evolvia 400, IP Video Doorbell ATZ-DBV01P, chacon IO, Oregon THN132ES, THN122N, Chinese PIR sensor PT2262, Bluetooth low energy dongle, iBeacon

micbou
Posts: 88
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi
Domoticz version:
Location: NL
Contact:

Re: How to check presence of Beacon ?

Postby micbou » Saturday 21 May 2016 22:09

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?

jmleglise
Posts: 190
Joined: Tuesday 13 January 2015 0:27
Target OS: Raspberry Pi
Domoticz version: V3.5113
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Postby jmleglise » Saturday 21 May 2016 22:16

I don't undesrtand your question . What do you call away and home status ?
Raspberry Pi2 + RFXTRX433E + KMTronic USB relay card
Blinds Somfy RTS, Blinds Bubendorff, Portal Somfy Evolvia 400, IP Video Doorbell ATZ-DBV01P, chacon IO, Oregon THN132ES, THN122N, Chinese PIR sensor PT2262, Bluetooth low energy dongle, iBeacon

micbou
Posts: 88
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi
Domoticz version:
Location: NL
Contact:

Re: How to check presence of Beacon ?

Postby micbou » Saturday 21 May 2016 22:18

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?

Image

jmleglise
Posts: 190
Joined: Tuesday 13 January 2015 0:27
Target OS: Raspberry Pi
Domoticz version: V3.5113
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Postby jmleglise » Saturday 21 May 2016 22:26

- 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.
Raspberry Pi2 + RFXTRX433E + KMTronic USB relay card
Blinds Somfy RTS, Blinds Bubendorff, Portal Somfy Evolvia 400, IP Video Doorbell ATZ-DBV01P, chacon IO, Oregon THN132ES, THN122N, Chinese PIR sensor PT2262, Bluetooth low energy dongle, iBeacon

micbou
Posts: 88
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi
Domoticz version:
Location: NL
Contact:

Re: How to check presence of Beacon ?

Postby micbou » Saturday 21 May 2016 22:32

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.

jmleglise
Posts: 190
Joined: Tuesday 13 January 2015 0:27
Target OS: Raspberry Pi
Domoticz version: V3.5113
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Postby jmleglise » Saturday 21 May 2016 22:52

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.
Raspberry Pi2 + RFXTRX433E + KMTronic USB relay card
Blinds Somfy RTS, Blinds Bubendorff, Portal Somfy Evolvia 400, IP Video Doorbell ATZ-DBV01P, chacon IO, Oregon THN132ES, THN122N, Chinese PIR sensor PT2262, Bluetooth low energy dongle, iBeacon

micbou
Posts: 88
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi
Domoticz version:
Location: NL
Contact:

Re: How to check presence of Beacon ?

Postby micbou » Saturday 21 May 2016 23:09

Its working! Pfewwww... this was a tough one for me.
Lets hope I can keep the service up

jmleglise
Posts: 190
Joined: Tuesday 13 January 2015 0:27
Target OS: Raspberry Pi
Domoticz version: V3.5113
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Postby jmleglise » Saturday 21 May 2016 23:24

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
Raspberry Pi2 + RFXTRX433E + KMTronic USB relay card
Blinds Somfy RTS, Blinds Bubendorff, Portal Somfy Evolvia 400, IP Video Doorbell ATZ-DBV01P, chacon IO, Oregon THN132ES, THN122N, Chinese PIR sensor PT2262, Bluetooth low energy dongle, iBeacon

micbou
Posts: 88
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi
Domoticz version:
Location: NL
Contact:

Re: How to check presence of Beacon ?

Postby micbou » Saturday 21 May 2016 23:36

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?

jmleglise
Posts: 190
Joined: Tuesday 13 January 2015 0:27
Target OS: Raspberry Pi
Domoticz version: V3.5113
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Postby jmleglise » Sunday 22 May 2016 0:47

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
Raspberry Pi2 + RFXTRX433E + KMTronic USB relay card
Blinds Somfy RTS, Blinds Bubendorff, Portal Somfy Evolvia 400, IP Video Doorbell ATZ-DBV01P, chacon IO, Oregon THN132ES, THN122N, Chinese PIR sensor PT2262, Bluetooth low energy dongle, iBeacon

micbou
Posts: 88
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi
Domoticz version:
Location: NL
Contact:

Re: How to check presence of Beacon ?

Postby micbou » Sunday 22 May 2016 0:57

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 8-)

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?

jmleglise
Posts: 190
Joined: Tuesday 13 January 2015 0:27
Target OS: Raspberry Pi
Domoticz version: V3.5113
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Postby jmleglise » Sunday 22 May 2016 10:10

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.
Raspberry Pi2 + RFXTRX433E + KMTronic USB relay card
Blinds Somfy RTS, Blinds Bubendorff, Portal Somfy Evolvia 400, IP Video Doorbell ATZ-DBV01P, chacon IO, Oregon THN132ES, THN122N, Chinese PIR sensor PT2262, Bluetooth low energy dongle, iBeacon

korniza
Posts: 175
Joined: Thursday 27 August 2015 18:12
Target OS: Raspberry Pi
Domoticz version: V3.6028
Location: Greece
Contact:

Re: How to check presence of Beacon ?

Postby korniza » Sunday 22 May 2016 13:46

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). :D

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.
Attachments
Home, Sweet Home.png
Home, Sweet Home.png (212.68 KiB) Viewed 859 times
>>>> Google Home <<<<<
SBC: Odroid XU4 * Raspberry Pi2 * banana Pi v1
Peripherals: rfxtrx433E, aeon z-stick gen5, bluetooth dongles
Extended Software packages: Xeoma (video NVR), FHEM (extra home automation software)

jmleglise
Posts: 190
Joined: Tuesday 13 January 2015 0:27
Target OS: Raspberry Pi
Domoticz version: V3.5113
Location: FRANCE
Contact:

Re: How to check presence of Beacon ?

Postby jmleglise » Wednesday 25 May 2016 23:09

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

Code: Select all

sudo python test_beacon.py
Raspberry Pi2 + RFXTRX433E + KMTronic USB relay card
Blinds Somfy RTS, Blinds Bubendorff, Portal Somfy Evolvia 400, IP Video Doorbell ATZ-DBV01P, chacon IO, Oregon THN132ES, THN122N, Chinese PIR sensor PT2262, Bluetooth low energy dongle, iBeacon

micbou
Posts: 88
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi
Domoticz version:
Location: NL
Contact:

Re: How to check presence of Beacon ?

Postby micbou » Thursday 26 May 2016 20:17

@ 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


Return to “Other questions and discussions”

Who is online

Users browsing this forum: emme and 6 guests