Page 6 of 19
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 21:26
by Raspberry Piet
This is what i made so far from the examples.
(i also speak better russian than lua)
Code: Select all
x = tonumber(uservariables['Tag_Green'])
commandArray = {}
if ( uservariables["Tag_Green"] ~= "AWAY" ) and (otherdevices["TAG"]=='Off') then
print('<b style="color:#0099FF">Tag_Green AANWEZIG RSSI:'..x .. ' dBm</b>')
commandArray['TAG']='On'
elseif ( uservariables["Tag_Green"] == "AWAY" ) and (otherdevices["TAG"]=='On') then
print('<b style="color:Red">Tag_Green AFWEZIG</b>')
commandArray['TAG']='Off'
elseif ( uservariables["Tag_Green"] ~= "AWAY" ) then
print('<b style="color:#0099FF">Tag_Green AANWEZIG RSSI:'..x .. ' dBm</b>')
commandArray['UpdateDevice']='2606|0|'..tostring(uservariables['Tag_Green'])
end
if ( uservariables["Tag_Green"] ~= "AWAY" ) and tonumber(x) <= -68 and tonumber(x) >= -76 then
print('<b style="color:#0099FF">Tag_Green EETKAMER RSSI:'..x .. ' dBm</b>')
end
if ( uservariables["Tag_Green"] ~= "AWAY" ) and tonumber(x) <= -77 and tonumber(x) >= -87 then
print('<b style="color:#0099FF">Tag_Green WOONKAMER RSSI:'..x .. ' dBm</b>')
end
return commandArray
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 21:30
by jvdz
What is the result in the log when you use this code? It will show the current processed info:
Code: Select all
commandArray = {}
for variableName, variableValue in pairs(uservariablechanged) do
print("variableName:", variableName, " variableValue:", variableValue)
if (variableName == 'Zhenya_SitRm') then
if tonumber(variableValue) <= -51 and tonumber(variableValue) >= -71 then
commandArray['ZSitRoomBT'] = "On"
end
end
if (variableName == 'Zhenya_SitRm') then
if variableValue == "AWAY" then
commandArray['ZSitRoomBT'] = "Off"
end
end
end
return commandArray
ps. what is the name of the script you use?
Jos
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 21:32
by woody4165
Thanks
I understand that you have an uservariable that is updated by the script.
The you have a switch, TAG, that is updated within this script.
What is doing this?
Code: Select all
commandArray['UpdateDevice']='2606|0|'..tostring(uservariables['Tag_Green'])
Is it an uservariable event driven or device driven?
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 21:41
by Raspberry Piet
woody4165 wrote:Thanks
I understand that you have an uservariable that is updated by the script.
The you have a switch, TAG, that is updated within this script.
What is doing this?
Code: Select all
commandArray['UpdateDevice']='2606|0|'..tostring(uservariables['Tag_Green'])
Is it an uservariable event driven or device driven?
I put the RSSI value in a virtual custom sensor (idx2606) for graph.
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 21:42
by jmleglise
Raspberry Piet wrote:It is possible with the Nut app to make the Nut Beacon beep (find keys when lost), is it somehow possible to do the same through a script?
What this has to do with Domoticz ? What is the use case ?
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 21:44
by blackdog65
Hi Jos
I get
Code: Select all
2016-05-16 20:39:35.105 LUA: variableName:
2016-05-16 20:39:35.105 LUA: Zhenya_SitRm
2016-05-16 20:39:35.105 LUA: variableValue:
2016-05-16 20:39:35.105 LUA: -79
2016-05-16 20:39:36.086 LUA: variableName:
2016-05-16 20:39:36.087 LUA: Sean_Hall
2016-05-16 20:39:36.087 LUA: variableValue:
2016-05-16 20:39:36.087 LUA: -79
2016-05-16 20:39:36.115 LUA: variableName:
2016-05-16 20:39:36.115 LUA: Sean_SitRm
2016-05-16 20:39:36.115 LUA: variableValue:
2016-05-16 20:39:36.115 LUA: -80
2016-05-16 20:39:38.947 LUA: variableName:
2016-05-16 20:39:38.948 LUA: Zhenya_SitRm
2016-05-16 20:39:38.948 LUA: variableValue:
2016-05-16 20:39:38.948 LUA: -78
2016-05-16 20:39:38.979 LUA: variableName:
2016-05-16 20:39:38.980 LUA: Zhenya_Hall
2016-05-16 20:39:38.980 LUA: variableValue:
2016-05-16 20:39:38.980 LUA: -88
showing both NUTs as seen by my sitting room raspi and my hall raspi
and my script is "script_variable_bt2.lua"
Sean
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 21:49
by jvdz
I don't see the LUA error out there, so what is shown when that is happening?
Jos
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 22:04
by blackdog65
Sorry Jos,
It triggers a fault when the variable switches to "AWAY"
Code: Select all
2016-05-16 21:01:05.868 Error: EventSystem: in script_variable_bt2.lua: [string "--script_variable_bt2.lua..."]:6: attempt to compare nil with number
Would this be when the script attempts "tonumber" when the variable string is "AWAY"?
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 22:06
by blackdog65
Raspberry Piet wrote:
I put the RSSI value in a virtual custom sensor (idx2606) for graph.
Very pretty! How do you do this?
Sean
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 22:12
by Westcott
Perhaps when the beacon is away, the reported value is NIL?
blackdog65 wrote:Sorry Jos,
It triggers a fault when the variable switches to "AWAY"
Code: Select all
2016-05-16 21:01:05.868 Error: EventSystem: in script_variable_bt2.lua: [string "--script_variable_bt2.lua..."]:6: attempt to compare nil with number
Would this be when the script attempts "tonumber" when the variable string is "AWAY"?
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 22:17
by Raspberry Piet
blackdog65 wrote:Raspberry Piet wrote:
I put the RSSI value in a virtual custom sensor (idx2606) for graph.
Very pretty! How do you do this?
Sean
Setup => Hardware => Dummy=> Create Virtual Sensors
(Domoticz Beta version needed i think)
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 22:17
by jvdz
Maybe something like this works:
Code: Select all
commandArray = {}
for variableName, variableValue in pairs(uservariablechanged) do
numVal = tonumber(variableValue)
--
if numVal == nil then numVal = 0 end
if (variableName == 'Zhenya_SitRm') then
if variableValue == "AWAY" then
commandArray['ZSitRoomBT'] = "Off"
elseif numVal <= -51 and numVal >= -71 then
commandArray['ZSitRoomBT'] = "On"
end
end
end
return commandArray
Jos
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 22:27
by blackdog65
@Jos, Yes! I just need to fiddle with my numbers now for accurate switching... MANY MANY THANKS!
@Raspberry Piet Spasiba bolshoi moi drook
Sean
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 22:36
by Raspberry Piet
blackdog65 wrote:
@Raspberry Piet Spasiba bolshoi moi drook
Sean
I'm glad there is google translate. I lied, i dont speak russian.
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 22:39
by jvdz
Our language probably sounds as foreign to Sean as Russian anyways
Re: How to check presence of Beacon ?
Posted: Monday 16 May 2016 22:42
by Raspberry Piet
jmleglise wrote:Raspberry Piet wrote:It is possible with the Nut app to make the Nut Beacon beep (find keys when lost), is it somehow possible to do the same through a script?
What this has to do with Domoticz ? What is the use case ?
When i lost my keys AND phone at the same time
No, you're right. It was just something that came up to my mind.
Re: How to check presence of Beacon ?
Posted: Tuesday 17 May 2016 8:59
by blackdog65
jvdz wrote:Our language probably sounds as foreign to Sean as Russian anyways
This is why when English people hear something garbled and unintelligible, we describe it as sounding like "Double Dutch".
Bizarrely, the Dutch language is The English Language's closest relative... go figure
Sean
Re: How to check presence of Beacon ?
Posted: Tuesday 17 May 2016 18:12
by woody4165
I'm still getting issues on reboot
The status is
active(exited) after reboot
the log says:
Code: Select all
2016-05-17 17:58:23,835 - root - CRITICAL - Error : hci0 interface not Running. Do you have a BLE device connected to hci0 ? Check with hciconfig !
pi@raspberrypi:~$ hciconfig
hci0: Type: BR/EDR Bus: UART
BD Address: xx:xx:xx:xx:xx:xx ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING
RX bytes:717 acl:0 sco:0 events:42 errors:0
TX bytes:1532 acl:0 sco:0 commands:42 errors:0
in /etc/init.d/check_beacon_presence
DAEMON_USER=root
I have 3 Nut and all visible with a BLE scanner
Any idea what I should do or check?
Re: How to check presence of Beacon ?
Posted: Tuesday 17 May 2016 20:05
by Raspberry Piet
Hmmm. This is odd. I left my Nut Tag at the same place this whole night and day.
Looking at the RSSI graph of this Tag it shows a clear difference when someone is at home or all left (for work)
When no one is at home the signal is quite stable according to the graph.
When i want to use it for indoor positioning system it would be better when the signal is stable as well when someone is at home.
Maybe it is some device that interferes the bluetooth signal... Have to investigate further.
Is there already somebody with this same experience?
Re: How to check presence of Beacon ?
Posted: Wednesday 18 May 2016 0:35
by blackdog65
I found placing a bottle of "Dr. Pepper" next to my tag caused a 25 point move. Took me a while to figure it out.
Stranger still, cups of tea or coffee had not affected it before
....... Maybe I'll stick with tea
Sean