Page 1 of 1

Blocky script for light not working

Posted: Monday 21 November 2016 11:45
by guantolento
hallo, i made this 4 script blocky to work my light in day and in night.
the script A control if someone is at home. the 2 phone have the geofence installed on. work ok.
the script B tell me if the time is in night or in day mode. work ok.
the script C disable some sequence if someone at home and switch off all light and enable some sequence if nobody at home. work ok.
the script D switch on some light and switch on some sequence. but not work and i don't so why.

Re: Blocky script for light not working

Posted: Monday 21 November 2016 11:46
by guantolento
this is the 4th script.

Re: Blocky script for light not working

Posted: Monday 21 November 2016 12:13
by emme
Ciao,
just a clarification
scirpt D should run ONLY during the neght (should be better to use Time = NightTime instead of using 1 dummy and few time test condition?... just a question :P)

I assume that Geofence will trigger the presences scripts (are they Device Events?)
in script C you set a 10sec delay to set Someone At Home -V-, so script D should run during that time... but I assume that after 10 secs... there are no geofence activation, so the scripts does not trigger....

try to put some debug messages with the status of the tested switches...
Have you also cosidered to use LUA instead?

Re: Blocky script for light not working

Posted: Monday 21 November 2016 12:27
by StanHD
First, replace the Script D "If" Block with the "If" block without the blue "Else If" control. The control you have used will not work without an "Else If".

Re: Blocky script for light not working

Posted: Monday 21 November 2016 12:59
by guantolento
StanHD wrote:First, replace the Script D "If" Block with the "If" block without the blue "Else If" control. The control you have used will not work without an "Else If".
hi stanHD, i made it and the script work now. i take a big mistake. now i reply to the ather user over.

Re: Blocky script for light not working

Posted: Monday 21 November 2016 13:05
by guantolento
emme wrote: scirpt D should run ONLY during the neght (should be better to use Time = NightTime instead of using 1 dummy and few time test condition?... just a question :P)
How i can made it ?
emme wrote: I assume that Geofence will trigger the presences scripts (are they Device Events?)
in script C you set a 10sec delay to set Someone At Home -V-, so script D should run during that time... but I assume that after 10 secs... there are no geofence activation, so the scripts does not trigger....
Yes it's correct for my work
emme wrote: try to put some debug messages with the status of the tested switches...
Have you also cosidered to use LUA instead
I'm new in this word... do yuo think LUA is Better ???

Re: Blocky script for light not working

Posted: Monday 21 November 2016 13:13
by Egregius
ANY language is better than blockly ;)

Re: Blocky script for light not working

Posted: Monday 21 November 2016 13:54
by emme
to use Nighttime variable (that runs from sunset to sunrise) you have to use LUA instead of blocky (...looks like it miss the parameter... should be inplemented?)

in LUA, your script will looks like:

Code: Select all

local GN = 'Memo Giorno / Notte -V-'
local GEOTOT = 'Geofence Totale -V-'
local INCASA = 'Someone At Home -V-'

commandArray = {}

    if (otherdevices[GN] = 'On' and ((otherdevices[GEOTOT] = 'On') and (otherdevices[INCASA] = 'On'))) then
    
-- Clausola IF alternativa
-- if (timeofday['Nighttime'] = true and ((otherdevices[GEOTOT] = 'On') and (otherdevices[INCASA] = 'On'))) then    

        commandArray['Cameretta Comò - S1'] = 'On'
        commandArray['Scene:Rientro Notturno Esterno'] = 'On'
        commandArray['Scene:Rientro Notturno Interno'] = 'On'
        commandArray['Group:Ronda Luci Zona Giorno'] = 'Inactive'
        commandArray['Group:Ronda Luci Zone Notte'] = 'Inactive'
    end

return commandArray
I have a doubt about multiple commandarray that should be converted in commandArray[1] = {['Updatedevice'] = '999|1|0'} but I don't know if this could be done for activatig groups and scenarios.... (maybe some LUA guru would help us :P)

Re: Blocky script for light not working

Posted: Tuesday 22 November 2016 0:52
by guantolento
Thankyou, tomorrow i try this with some test.

Inviato dal mio GT-I9301I utilizzando Tapatalk

Re: Blocky script for light not working

Posted: Thursday 24 November 2016 10:04
by guantolento
i take some test with LUA same my start Blocky an now the system work with this script:

Script someone at home

Code: Select all

local A = 'Geofence Cristiano -V-'
local B = 'Geofence Chiara -V-'
local C = 'Geofence Totale -V-'
local D = 'Someone At Home -V-'

commandArray = {}

if (devicechanged[A] == 'On') or (devicechanged[B] == 'On') then
    commandArray[C] = 'On'
    commandArray[D] = 'On AFTER 12'
    commandArray['Scene:Ronda Luci Zona Giorno'] = 'Inactive'
    commandArray['Scene:Ronda Luci Zone Notte'] = 'Inactive'
    print ("Scene Ronda Luci Zone Giorno - Notte INACTIVE")
end
    
return commandArray
it's possible make the command 'Inactive AFTER 12' or not???
the script work ok, but in the log i cant' see the print line, why ?

Script Nobody at home

Code: Select all

local A = 'Geofence Cristiano -V-'
local B = 'Geofence Chiara -V-'
local C = 'Geofence Totale -V-'
local D = 'Someone At Home -V-'

commandArray = {}

if (otherdevices[A] == 'Off') and (devicechanged[B] == 'Off') or (devicechanged[A] == 'Off') and (otherdevices[B] == 'Off')  then
    commandArray[C] = 'Off'
    commandArray[D] = 'Off AFTER 120'
    commandArray['Scene:Spegni Luci Zona Giorno'] = 'On AFTER 120'
    commandArray['Scene:Spegni Luci Zona Notte'] = 'On AFTER 120'
    commandArray['Scene:Ronda Luci Zona Giorno'] = 'Active'
    commandArray['Scene:Ronda Luci Zone Notte'] = 'Active'
    print ("Scene Ronda Luci Zone Giorno - Notte ACTIVE")
end

return commandArray
the script work ok, but in the log i cant' see the print line, why ?

thankyou all, good morning.

Re: RE: Re: Blocky script for light not working

Posted: Thursday 24 November 2016 10:53
by guantolento
guantolento wrote:i take some test with LUA same my start Blocky an now the system work with this script:

Script someone at home

Code: Select all

local A = 'Geofence Cristiano -V-'
local B = 'Geofence Chiara -V-'
local C = 'Geofence Totale -V-'
local D = 'Someone At Home -V-'

commandArray = {}

if (devicechanged[A] == 'On') or (devicechanged[B] == 'On') then
    commandArray[C] = 'On'
    commandArray[D] = 'On AFTER 12'
    commandArray['Scene:Ronda Luci Zona Giorno'] = 'Inactive'
    commandArray['Scene:Ronda Luci Zone Notte'] = 'Inactive'
    print ("Scene Ronda Luci Zone Giorno - Notte INACTIVE")
end
    
return commandArray
it's possible make the command 'Inactive AFTER 12' or not???
the script work ok, but in the log i cant' see the print line, why ?

Script Nobody at home

Code: Select all

local A = 'Geofence Cristiano -V-'
local B = 'Geofence Chiara -V-'
local C = 'Geofence Totale -V-'
local D = 'Someone At Home -V-'

commandArray = {}

if (otherdevices[A] == 'Off') and (devicechanged[B] == 'Off') or (devicechanged[A] == 'Off') and (otherdevices[B] == 'Off')  then
    commandArray[C] = 'Off'
    commandArray[D] = 'Off AFTER 120'
    commandArray['Scene:Spegni Luci Zona Giorno'] = 'On AFTER 120'
    commandArray['Scene:Spegni Luci Zona Notte'] = 'On AFTER 120'
    commandArray['Scene:Ronda Luci Zona Giorno'] = 'Active'
    commandArray['Scene:Ronda Luci Zone Notte'] = 'Active'
    print ("Scene Ronda Luci Zone Giorno - Notte ACTIVE")
end

return commandArray
the script work ok, but in the log i cant' see the print line, why ?

thankyou all, good morning.
I take a mistake watching in the log tab.
The print its ok.

Inviato dal mio GT-I9301I utilizzando Tapatalk