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
}