Page 2 of 2

Re: Fibaro RGBW control by Fibaro switch

Posted: Tuesday 15 November 2016 11:24
by emme
uh.. :(
sorry

Re: Fibaro RGBW control by Fibaro switch

Posted: Tuesday 15 November 2016 11:34
by piokuc
No
It no works ok. Because when i Turn OFF KINKIET for about some time it Turn ON automatical.
I dont know what is it.

Re: Fibaro RGBW control by Fibaro switch

Posted: Tuesday 15 November 2016 12:01
by emme
leave only the script and remove the secondary dependecy from devices....

Re: Fibaro RGBW control by Fibaro switch

Posted: Tuesday 15 November 2016 12:02
by piokuc
i have only script. But problem is in script

Re: Fibaro RGBW control by Fibaro switch

Posted: Tuesday 15 November 2016 12:07
by piokuc
ok
I corrected script and now works fast and good:

Code: Select all

commandArray = {}
    if devicechanged['Kinkiet'] and otherdevices['Kinkiet'] == 'On' then
        if otherdevices['Switch2'] == 'Off' then
            commandArray['Switch2'] = 'On'
        end
    end

    if devicechanged['Kinkiet'] and otherdevices['Kinkiet'] == 'Off' then
        if otherdevices['Switch2'] == 'On' then
            commandArray['Switch2'] = 'Off'
        end
    end

    if devicechanged['Switch2'] and otherdevices['Switch2'] == 'On' then
        if otherdevices['Kinkiet'] == 'Off' then
            commandArray['Kinkiet'] = 'On'
        end
    end

    if devicechanged['Switch2'] and otherdevices['Switch2'] == 'Off' then
        if otherdevices['Kinkiet'] == 'On' then
            commandArray['Kinkiet'] = 'Off'
        end
    end
return commandArray
BTW
Problem which i post with setting SLAVE/SECONDARY device also should be repaired by developer.

@emme thanks for your HELP :)

Re: Fibaro RGBW control by Fibaro switch

Posted: Tuesday 15 November 2016 12:55
by piokuc
BTW
I can use script lua to control relay by GPIO from directory /scripts to use it in GUI in menu EVENTS ?

Code: Select all

-- script_device_Zaluzje_pietro.lua
 
local sensor = 'Zaluzje pietro'
 
commandArray = {}
 
if (devicechanged[sensor] == 'On') then
print ("Odsloniecie zaluzji na pietrze przez przekaznik na GPIO 19")
os.execute ("/usr/local/bin/gpio export 19 in")
os.execute ("/usr/local/bin/gpio export 19 out")
os.execute ("sleep 0.1")
os.execute ("/usr/local/bin/gpio export 19 in")
end
 
if (devicechanged[sensor] == 'Off') then
print ("Zasloniecie zaluzji na pietrze przez przekaznik na GPIO 16")
os.execute ("/usr/local/bin/gpio export 16 in")
os.execute ("/usr/local/bin/gpio export 16 out")
os.execute ("sleep 0.1")
os.execute ("/usr/local/bin/gpio export 16 in")
end

if (devicechanged[sensor] == 'Stop') then
print ("Ustawienie zaluzji na pietrze w pozycji MY przez przekaznik na GPIO 13")
os.execute ("/usr/local/bin/gpio export 13 in")
os.execute ("/usr/local/bin/gpio export 13 out")
os.execute ("sleep 0.1")
os.execute ("/usr/local/bin/gpio export 13 in")
end
 
return commandArray

Re: Fibaro RGBW control by Fibaro switch

Posted: Wednesday 16 November 2016 12:31
by emme
GPIO needs to be exported BEFORE domoticz Start (see http://www.domoticz.com/wiki/GPIO )
then you can see them as devices

Re: Fibaro RGBW control by Fibaro switch

Posted: Wednesday 16 November 2016 12:41
by piokuc
yes ok but if now i use script in directory i can not exported GPIO. But if i want use scipt in event i must exported ?

Re: Fibaro RGBW control by Fibaro switch

Posted: Wednesday 16 November 2016 12:53
by emme
if you want to use GPIO it would be better to export them and configure the hardware in domoticz

Running from a script is not a good idea:
each os.execute is a different thread, so except the first, all others generate an error for missing gpio definition
by the time the os.execute finish, all the settings regard the GPIO are lost... no more output, no more input

If you have always connected a switch to a gpio... than configure it as hardware ;)

Re: Fibaro RGBW control by Fibaro switch

Posted: Wednesday 16 November 2016 12:55
by piokuc
but how control gpio in lua script by Events menu ?