because i thought it was a problem with the lua.json (because it's the origin file, i did'nt touch this file)
so this is the script i use :
---------------------------------
-- Script to calculate duration and distance between two points using Google Maps
-- Autor : woody4165 based on Neutrino Traffic with Waze
-- Date : 9 April 2016
-- Need a text device (using duration) or an integer (using mins)
---------------------------------
commandArray={}
time = os.date("*t")
day = tonumber(os.date("%w"))
idx = '198'
-- If a weekday and time between 7AM and 9AM
if ((day > 0 and day < 6) and (time.hour > 6 and time.hour < 10)) then
-- Every 10 minutes
if((time.min % 10)==0) then
--import JSON.lua library
json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
-- variables --
-- Coordinates starting point
fromx="xx.yyyyyyy"
fromy="xx.yyyyyyy"
-- Coordinates destination point
tox="xx.yyyyyyy"
toy="xx.yyyyyyy"
-- Google Api Key
key = 'MY API KEY'
-- get data from Google Maps and decode it in gmaps
local jsondata = assert(io.popen('curl "
https://maps.googleapis.com/maps/api/di ... key='..key..'"'))
local jsondevices = jsondata:read('*all')
jsondata:close()
local gmaps = json:decode(jsondevices)
-- Read from the data table, and extract duration and distance in text
distance = gmaps.routes[1].legs[1].distance.text
duration = gmaps.routes[1].legs[1].duration_in_traffic.text
-- mins is only the number part of duration (for evaulation purpose or to return a number in a number device)
for minutes in string.gmatch(duration, "%d+") do mins = tonumber(minutes) end
-- send a Telegram message with status update (replace xxxxxxx with chatid and yyyyyyyyy with bot key)
-- In case you don't want to receive Telegram message, just remove or comment next two lines
message = mins..' mins to go to office at '..time.hour..':'..time.min..' !!!'
os.execute('curl --data chat_id=xxxxxxxxxx--data-urlencode "text='..message..'" "
https://api.telegram.org/botyyyyyyyyyyy ... endMessage" ')
-- return a text to the device (eg. 12 mins)
commandArray[1]={['UpdateDevice'] =idx..'|0|' .. tostring(duration)}
end
end
return commandArray