Ah, that's another thing that apparently needs some polishing. I wanted to only update the text devices when their location has changed significantly (I use the "radius" variable for that again). I get the "old" distance from the text device itself. However, new text devices automatically contain the text "Hello world!", so you won't find any distance in there, and the script stops because LUA doesn't want to work with empty strings. I tried to solve it with the 'if prev_distance == nil then prev_distance = 1000 end" line, to give it an initial value that is large enough so that the text device gets updated, but it doesn't even get to that point apparently. You could change the contents of the text field into something like "(1000 km)" by hand, but I don't find that a very elegant solution. I think I found a better solution now:mcmikev wrote:Just discovered that It is not the switch name but device name of the iphone
Changed that and now I get more
But get error from line 53
2016-09-14 12:16:19.411 Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_time_checkphones.lua: /home/pi/domoticz/scripts/lua/script_time_checkphones.lua:53: bad argument #1 to 'sub' (string expected, got nil)
Please change these lines
Code: Select all
prev_dist = tonumber(string.sub(string.match(otherdevices['Position ' .. user], '%(.*%)'), 2,-5))
if prev_distance == nil then prev_distance = 1000 end
Code: Select all
prev_distance_str = string.match(otherdevices['Position ' .. user], '%(.*%)') or '(1000 km)'
prev_dist = tonumber(string.sub(prev_distance_str, 2,-5))