Page 1 of 1

Switch execute twice if selected from Android app

Posted: Wednesday 27 April 2016 7:52
by woody4165
Hi

I made this simple script just to test izSynth

Code: Select all

--
commandArray = {}

if (devicechanged['Oggi'] == "On") then

    giorni = {"Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato", "Domenica"}
    mesi = {"Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre"}

    mese = os.date("%m")
    giorno_sett = os.date("%w")
    giorno = os.date("%d")
    anno = os.date("%Y")

    data = os.date("%d %B %Y")
    ora = os.date("%H e %M")
    temp = otherdevices_svalues["TempExt"]
    pos = string.find(temp, ";")-1
    temp = string.sub(temp,1,pos)
    message = "Oggi è "..giorni[tonumber(giorno_sett)].." "..tostring(giorno).." "..mesi[tonumber(mese)].." "..tostring(anno).." e sono le "..ora..". La temperatura esterna è "..temp.." gradi centigradi. Buona giornata!"
    messaggio2= '/home/pi/domoticz/scripts/izsynth -t "'..message..'"'
    prova = os.execute(messaggio2)
    commandArray["Oggi"] = "Off"

else
    return 
end



return commandArray

Strange thing is that if I set to On the device switch from the webpanel all is ok, if I do it from Android app I get the os.execute done twice (I hear twice the message from speaker, one over the other).

Don't know if it's right to set to Off the switch that way or if there is something wrong

Any advice?

Thanks