Re: bibliothèque de fonctions pour scripts LUA
Publié : 03 mars 2018, 16:46
non j'ai confondu dzvents et lua
comme tu l'as remarqué c'est du dzvents
vais l'adapter en lua
comme tu l'as remarqué c'est du dzvents
vais l'adapter en lua
Reprenez le contrôle de votre domotique
https://easydomoticz.com/forum/
Code : Tout sélectionner
function telegram(msg)
commandArray[#commandArray+1] = {['OpenURL'] = 'https://api.telegram.org/bot'..TELEGRAM_API_key..'/sendMessage?chat_id='..chat_ID .. '&text=' .. msg}
endCode : Tout sélectionner
function makeVariable(name,value)
local url = 'curl '..domoticzURL..'/json.htm?type=command¶m=saveuservariable&vname='..url_encode(name)..'&vtype=2&vvalue='..url_encode(value)
local output = json:decode(os.capture(url, false))
if output.status=="Variable name already exists!" then
log('Variable existante',debug)
local url = 'curl '..domoticzURL..'/json.htm?type=command¶m=updateuservariable&vname='..url_encode(name)..'&vtype=2&vvalue='..url_encode(value)
local output = json:decode(os.capture(url, false))
if output.status=="Ok" then
log('Mise a jour variable existante')
else
error('Mise a jour de variable existante impossible')
end
elseif output.status=="Ok!" then
log('Creation de variable avec les parametres')
else
error('Creation de variable impossible')
end
endCode : Tout sélectionner
script = ' [Test] ' ; commandArray={}
if devicechanged['Bouton Test']=='On' then
print('\n--------------------------------------------- '..script..' --------------------------------------------------------')
print('Debut de test')
os.execute( 'curl "http://192.168.0.38:8080/json.htm?type=command¶m=updateuservariable&vname=Libre1&vtype=2&vvalue=TEST1"' )
print('Fin de test')
end
return commandArray--------------------------------------------- [Test] --------------------------------------------------------
2018-03-21 09:23:04.426 dzVents: Debut de test
2018-03-21 09:23:14.424 Error: EventSystem: Warning!, lua script *** LUA: Test has been running for more than 10 seconds
Code : Tout sélectionner
if uservariables['Test'] == nil then Code : Tout sélectionner
commandArray['Variable:Libre3']=''