Page 1 of 1

Store variable in script

Posted: Monday 03 December 2018 16:51
by poudenes
Hi All,

I have a script that now work with user variables. But its only needed for the script.
Can i store variable into script so it will update when needed and not update all the time into dB?

I have VarKodiStop and VarKodiPlay
When there is a action it update this variable otherwise it will go into a loop.

Want move those 2 into the script.

Code: Select all

local Version = '18.12.03'

return {
    active = true,
	on = {
	    devices = {[KodiStatus] = { 'at nighttime' }},
	},
	-- logging = {marker = 'KODI Control ' ..Version..'...........'},
	execute = function(domoticz, device)

-- KODI PAUZE
    if (domoticz.devices(SceneMovie).active and domoticz.devices(LogitechKodi).active) then
        if (domoticz.devices(KodiStatus).state == 'Paused') then 
            domoticz.variables(VarKodiStop).set(0)
            domoticz.variables(VarKodiPlay).set(0)
            
            -- HALLOWEEN            
            if (domoticz.time.matchesRule 'on 23/10-04/11') then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            -- X-MAS
            elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            -- NORMAL
            else
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            end
            -- SENSOR DINING ROOM ON            
            if (domoticz.devices(SensorDiningRoomDoor).active) then
                domoticz.helpers.Off(domoticz,BulbDressoirAll,nil,nil,nil)
            -- SENSOR DINING ROOM OFF    
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if (domoticz.time.matchesRule 'on 23/10-04/11') then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- X-MAS
                elseif (domoticz.time.matchesRule 'on 20/12-31/12') then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                end
            end
            domoticz.devices(BulbBalcony1).dimTo(100)
            domoticz.devices(BulbToiletAll).dimTo(100)
            domoticz.devices(BulbKitchenSinkAll).dimTo(100)
            domoticz.devices(BulbKitchenAll).dimTo(100)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 50 &')
            -- domoticz.log('------------------------==<[ KODI STAAT OP PAUZE ]>==-----------------------', domoticz.LOG_FORCE)

-- KODI VIDEO
        elseif (domoticz.devices(KodiStatus).state  == 'Video' and domoticz.variables(VarKodiPlay).value == 0) then
            domoticz.variables(VarKodiStop).set(0)
            domoticz.variables(VarKodiPlay).set(1)
            -- HALLOWEEN            
            if (domoticz.time.matchesRule 'on 23/10-04/11') then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(20)
            -- X-MAS
            elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(20)
            -- NORMAL
            else
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(20)
            end
            -- SENSOR DINING ROOM ON            
            if (domoticz.devices(SensorDiningRoomDoor).active) then
                domoticz.helpers.Off(domoticz,BulbDressoirAll,nil,nil,nil)
            -- SENSOR DINING ROOM OFF
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if (domoticz.time.matchesRule 'on 23/10-04/11') then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- X-MAS
                elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                end
            end
            domoticz.helpers.Off(domoticz,BulbKitchenSinkAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbKitchenAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbToiletAll,nil,nil)
            domoticz.helpers.RGB(domoticz,BulbBalcony1,25,'Blue',nil)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 10 &')
            -- domoticz.log('------------------------==<[ KODI IS FILM AAN AFSPELEN ]>==-----------------', domoticz.LOG_FORCE)

-- KODI TV SHOW 
        elseif (domoticz.devices(KodiStatus).state  == 'TV Shows' and domoticz.variables(VarKodiPlay).value == 0) 
        then
            domoticz.variables(VarKodiStop).set(0)
            domoticz.variables(VarKodiPlay).set(1)
            -- HALLOWEEN             
            if (domoticz.time.matchesRule 'on 23/10-04/11') then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(50)
            -- X-MAS
            elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(20)
            -- NORMAL
            else
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(50)
            end
            
            -- SENSOR DINING ROOM ON           
            if (domoticz.devices(SensorDiningRoomDoor).active) then
                domoticz.helpers.Off(domoticz,BulbDressoirAll,nil,nil,nil)
            -- SENSOR DINING ROOM OFF
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if (domoticz.time.matchesRule 'on 23/10-04/11') then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- X-MAS
                elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                end
            end
            domoticz.helpers.Off(domoticz,BulbKitchenSinkAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbKitchenAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbToiletAll,nil,nil)
            domoticz.helpers.RGB(domoticz,BulbBalcony1,25,'Blue',nil)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 10 &')
            -- domoticz.log('------------------------==<[ KODI IS SERIE AAN AFSPELEN ]>==----------------', domoticz.LOG_FORCE)

-- KODI SPEELT NIKS        
        elseif (domoticz.devices(KodiStatus).state  == 'On') 
        then
            domoticz.variables(VarKodiStop).set(1)
            domoticz.variables(VarKodiPlay).set(0)
            -- HALLOWEEN             
            if (domoticz.time.matchesRule 'on 23/10-04/11') then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            -- X-MAS
            elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            -- NORMAL
            else
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            end
            
            -- SENSOR DINING ROOM ON          
            if (domoticz.devices(SensorDiningRoomDoor).active) then
                domoticz.helpers.Off(domoticz,BulbDressoirAll,nil,nil,nil)
            -- SENSOR DINING ROOM OFF
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if (domoticz.time.matchesRule 'on 23/10-04/11') then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- X-MAS
                elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                end
            end   
            domoticz.helpers.Off(domoticz,BulbKitchenSinkAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbKitchenAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbToiletAll,nil,nil)
            domoticz.helpers.RGB(domoticz,BulbBalcony1,75,'Blue',nil)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 50 &')
            -- domoticz.log('------------------------==<[ KODI SPEELT NIKS AF ]>==-----------------------', domoticz.LOG_FORCE)
	    end
	end
end
}

Re: Store variable in script

Posted: Monday 03 December 2018 16:57
by emme
you can use data section into your script

have a look at the wiki:
https://www.domoticz.com/wiki/DzVents:_ ... ptional.29

Re: Store variable in script

Posted: Monday 03 December 2018 18:47
by waaren
poudenes wrote: Monday 03 December 2018 16:51 I have a script that now work with user variables. But its only needed for the script.
Can i store variable into script so it will update when needed and not update all the time into dB?
It can be done like the example below but be aware that when you change the state or dimlevel of a device then this wil also be send to the database.

Code: Select all

local Version = '18.12.03'

return {
    active = true,
	on = {
	    devices = {[KodiStatus] = { 'at nighttime' }},
	},
	-- logging = {marker = 'KODI Control ' ..Version..'...........'},
    
      data        =   {     KodiStop        =   { initial = 0     },
                            KodiPlay        =   { initial = 0     },
                      },
    
	execute = function(domoticz, device)

        local function setStopPlay(stop,play)
            domoticz.data.KodiStop) = stop
            domoticz.data.KodiPlay) = play
        end

            -- KODI PAUZE
    if (domoticz.devices(SceneMovie).active and domoticz.devices(LogitechKodi).active) then
        if (domoticz.devices(KodiStatus).state == 'Paused') then 
            setStopPlay(0,0)
            
            -- HALLOWEEN            
            if (domoticz.time.matchesRule 'on 23/10-04/11') then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            -- X-MAS
            elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            -- NORMAL
            else
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            end
            -- SENSOR DINING ROOM ON            
            if (domoticz.devices(SensorDiningRoomDoor).active) then
                domoticz.helpers.Off(domoticz,BulbDressoirAll,nil,nil,nil)
            -- SENSOR DINING ROOM OFF    
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if (domoticz.time.matchesRule 'on 23/10-04/11') then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- X-MAS
                elseif (domoticz.time.matchesRule 'on 20/12-31/12') then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                end
            end
            domoticz.devices(BulbBalcony1).dimTo(100)
            domoticz.devices(BulbToiletAll).dimTo(100)
            domoticz.devices(BulbKitchenSinkAll).dimTo(100)
            domoticz.devices(BulbKitchenAll).dimTo(100)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 50 &')
            -- domoticz.log('------------------------==<[ KODI STAAT OP PAUZE ]>==-----------------------', domoticz.LOG_FORCE)

-- KODI VIDEO
        elseif (domoticz.devices(KodiStatus).state  == 'Video' and domoticz.data.KodiPlay == 0) then
            setStopPlay(0,1)
            -- HALLOWEEN            
            if (domoticz.time.matchesRule 'on 23/10-04/11') then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(20)
            -- X-MAS
            elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(20)
            -- NORMAL
            else
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(20)
            end
            -- SENSOR DINING ROOM ON            
            if (domoticz.devices(SensorDiningRoomDoor).active) then
                domoticz.helpers.Off(domoticz,BulbDressoirAll,nil,nil,nil)
            -- SENSOR DINING ROOM OFF
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if (domoticz.time.matchesRule 'on 23/10-04/11') then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- X-MAS
                elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                end
            end
            domoticz.helpers.Off(domoticz,BulbKitchenSinkAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbKitchenAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbToiletAll,nil,nil)
            domoticz.helpers.RGB(domoticz,BulbBalcony1,25,'Blue',nil)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 10 &')
            -- domoticz.log('------------------------==<[ KODI IS FILM AAN AFSPELEN ]>==-----------------', domoticz.LOG_FORCE)

-- KODI TV SHOW 
        elseif (domoticz.devices(KodiStatus).state  == 'TV Shows' and domoticz.data.KodiPlay == 0) 
        then
            setStopPlay(0,1)
            -- HALLOWEEN             
            if (domoticz.time.matchesRule 'on 23/10-04/11') then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(50)
            -- X-MAS
            elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(20)
            -- NORMAL
            else
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(50)
            end
            
            -- SENSOR DINING ROOM ON           
            if (domoticz.devices(SensorDiningRoomDoor).active) then
                domoticz.helpers.Off(domoticz,BulbDressoirAll,nil,nil,nil)
            -- SENSOR DINING ROOM OFF
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if (domoticz.time.matchesRule 'on 23/10-04/11') then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- X-MAS
                elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                end
            end
            domoticz.helpers.Off(domoticz,BulbKitchenSinkAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbKitchenAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbToiletAll,nil,nil)
            domoticz.helpers.RGB(domoticz,BulbBalcony1,25,'Blue',nil)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 10 &')
            -- domoticz.log('------------------------==<[ KODI IS SERIE AAN AFSPELEN ]>==----------------', domoticz.LOG_FORCE)

-- KODI SPEELT NIKS        
        elseif (domoticz.devices(KodiStatus).state  == 'On') 
        then
            setStopPlay(1,0)
            -- HALLOWEEN             
            if (domoticz.time.matchesRule 'on 23/10-04/11') then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            -- X-MAS
            elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            -- NORMAL
            else
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            end
            
            -- SENSOR DINING ROOM ON          
            if (domoticz.devices(SensorDiningRoomDoor).active) then
                domoticz.helpers.Off(domoticz,BulbDressoirAll,nil,nil,nil)
            -- SENSOR DINING ROOM OFF
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if (domoticz.time.matchesRule 'on 23/10-04/11') then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- X-MAS
                elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                end
            end   
            domoticz.helpers.Off(domoticz,BulbKitchenSinkAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbKitchenAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbToiletAll,nil,nil)
            domoticz.helpers.RGB(domoticz,BulbBalcony1,75,'Blue',nil)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 50 &')
            -- domoticz.log('------------------------==<[ KODI SPEELT NIKS AF ]>==-----------------------', domoticz.LOG_FORCE)
	    end
	end
end
}

Re: Store variable in script

Posted: Tuesday 04 December 2018 10:46
by poudenes
Thanks Waaren. I will look into the script to understand the way of work :D
waaren wrote: Monday 03 December 2018 18:47
poudenes wrote: Monday 03 December 2018 16:51 I have a script that now work with user variables. But its only needed for the script.
Can i store variable into script so it will update when needed and not update all the time into dB?
It can be done like the example below but be aware that when you change the state or dimlevel of a device then this wil also be send to the database.

Code: Select all

local Version = '18.12.03'

return {
    active = true,
	on = {
	    devices = {[KodiStatus] = { 'at nighttime' }},
	},
	-- logging = {marker = 'KODI Control ' ..Version..'...........'},
    
      data        =   {     KodiStop        =   { initial = 0     },
                            KodiPlay        =   { initial = 0     },
                      },
    
	execute = function(domoticz, device)

        local function setStopPlay(stop,play)
            domoticz.data.KodiStop) = stop
            domoticz.data.KodiPlay) = play
        end

            -- KODI PAUZE
    if (domoticz.devices(SceneMovie).active and domoticz.devices(LogitechKodi).active) then
        if (domoticz.devices(KodiStatus).state == 'Paused') then 
            setStopPlay(0,0)
            
            -- HALLOWEEN            
            if (domoticz.time.matchesRule 'on 23/10-04/11') then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            -- X-MAS
            elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            -- NORMAL
            else
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            end
            -- SENSOR DINING ROOM ON            
            if (domoticz.devices(SensorDiningRoomDoor).active) then
                domoticz.helpers.Off(domoticz,BulbDressoirAll,nil,nil,nil)
            -- SENSOR DINING ROOM OFF    
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if (domoticz.time.matchesRule 'on 23/10-04/11') then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- X-MAS
                elseif (domoticz.time.matchesRule 'on 20/12-31/12') then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                end
            end
            domoticz.devices(BulbBalcony1).dimTo(100)
            domoticz.devices(BulbToiletAll).dimTo(100)
            domoticz.devices(BulbKitchenSinkAll).dimTo(100)
            domoticz.devices(BulbKitchenAll).dimTo(100)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 50 &')
            -- domoticz.log('------------------------==<[ KODI STAAT OP PAUZE ]>==-----------------------', domoticz.LOG_FORCE)

-- KODI VIDEO
        elseif (domoticz.devices(KodiStatus).state  == 'Video' and domoticz.data.KodiPlay == 0) then
            setStopPlay(0,1)
            -- HALLOWEEN            
            if (domoticz.time.matchesRule 'on 23/10-04/11') then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(20)
            -- X-MAS
            elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(20)
            -- NORMAL
            else
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(20)
            end
            -- SENSOR DINING ROOM ON            
            if (domoticz.devices(SensorDiningRoomDoor).active) then
                domoticz.helpers.Off(domoticz,BulbDressoirAll,nil,nil,nil)
            -- SENSOR DINING ROOM OFF
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if (domoticz.time.matchesRule 'on 23/10-04/11') then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- X-MAS
                elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                end
            end
            domoticz.helpers.Off(domoticz,BulbKitchenSinkAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbKitchenAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbToiletAll,nil,nil)
            domoticz.helpers.RGB(domoticz,BulbBalcony1,25,'Blue',nil)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 10 &')
            -- domoticz.log('------------------------==<[ KODI IS FILM AAN AFSPELEN ]>==-----------------', domoticz.LOG_FORCE)

-- KODI TV SHOW 
        elseif (domoticz.devices(KodiStatus).state  == 'TV Shows' and domoticz.data.KodiPlay == 0) 
        then
            setStopPlay(0,1)
            -- HALLOWEEN             
            if (domoticz.time.matchesRule 'on 23/10-04/11') then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(50)
            -- X-MAS
            elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(20)
            -- NORMAL
            else
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(50)
            end
            
            -- SENSOR DINING ROOM ON           
            if (domoticz.devices(SensorDiningRoomDoor).active) then
                domoticz.helpers.Off(domoticz,BulbDressoirAll,nil,nil,nil)
            -- SENSOR DINING ROOM OFF
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if (domoticz.time.matchesRule 'on 23/10-04/11') then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- X-MAS
                elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                end
            end
            domoticz.helpers.Off(domoticz,BulbKitchenSinkAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbKitchenAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbToiletAll,nil,nil)
            domoticz.helpers.RGB(domoticz,BulbBalcony1,25,'Blue',nil)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 10 &')
            -- domoticz.log('------------------------==<[ KODI IS SERIE AAN AFSPELEN ]>==----------------', domoticz.LOG_FORCE)

-- KODI SPEELT NIKS        
        elseif (domoticz.devices(KodiStatus).state  == 'On') 
        then
            setStopPlay(1,0)
            -- HALLOWEEN             
            if (domoticz.time.matchesRule 'on 23/10-04/11') then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            -- X-MAS
            elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            -- NORMAL
            else
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            end
            
            -- SENSOR DINING ROOM ON          
            if (domoticz.devices(SensorDiningRoomDoor).active) then
                domoticz.helpers.Off(domoticz,BulbDressoirAll,nil,nil,nil)
            -- SENSOR DINING ROOM OFF
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if (domoticz.time.matchesRule 'on 23/10-04/11') then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- X-MAS
                elseif (domoticz.time.matchesRule 'on 01/12-31/12') then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                end
            end   
            domoticz.helpers.Off(domoticz,BulbKitchenSinkAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbKitchenAll,nil,nil)
            domoticz.helpers.Off(domoticz,BulbToiletAll,nil,nil)
            domoticz.helpers.RGB(domoticz,BulbBalcony1,75,'Blue',nil)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 50 &')
            -- domoticz.log('------------------------==<[ KODI SPEELT NIKS AF ]>==-----------------------', domoticz.LOG_FORCE)
	    end
	end
end
}

Re: Store variable in script

Posted: Tuesday 05 March 2019 15:14
by poudenes
Hi All,

Can I also change these variables from other scripts?