(SOLVED) Convert dzvent Domoticz script to HA

Hi All,

Maybe a question thats not aswer full. But i want convert 1 script from Domoticz to HA.
Its a lot with if this then else etc etc.

Can someone help me out how to start this convertion?

local Version = '2019.06.23'

return {
    active = true,
	on = {
	
	devices = {[KodiStatus] = { 'at nighttime' }},
	},

	-- logging = {marker = 'KODI Control ' ..Version..'...........'},
	execute = function(domoticz, device)

-- KODI PAUZE
    if ((domoticz.devices(SceneMovie).active or domoticz.devices(SceneTV).active) and 
        (domoticz.devices(LogitechIPTV).active or domoticz.devices(LogitechKodi).active)
        ) then
        
        if (domoticz.devices(KodiStatus).state == 'Paused') then 

            domoticz.globalData.KodiPlayVar = 0 
            domoticz.globalData.KodiStopVar = 0
            
            -- HALLOWEEN            
            if domoticz.helpers.halloween(domoticz) then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            
            -- X-MAS
            elseif domoticz.helpers.xmas(domoticz) 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)
            
            -- SENSOR DINING ROOM OFF    
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if domoticz.helpers.halloween(domoticz) then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- X-MAS
                elseif domoticz.helpers.xmas(domoticz) then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- BDAY    
                elseif domoticz.helpers.bday(domoticz) then
                    domoticz.helpers.RGB(domoticz,BulbDressoir1,nil,'Red',nil)
                    domoticz.helpers.KELVIN(domoticz,BulbDressoir2,nil,0,nil)
                    domoticz.helpers.RGB(domoticz,BulbDressoir3,nil,'Blue',nil)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                end
            end
            domoticz.helpers.RGB(domoticz,BulbBalcony1,nil,'Blue',nil)
            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.globalData.KodiPlayVar == 0) then

            domoticz.globalData.KodiPlayVar = 1 
            domoticz.globalData.KodiStopVar = 0
            
            -- HALLOWEEN            
            if domoticz.helpers.halloween(domoticz) then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(20)
            -- X-MAS
            elseif domoticz.helpers.xmas(domoticz) 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)
            -- SENSOR DINING ROOM OFF
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if domoticz.helpers.halloween(domoticz) then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- X-MAS
                elseif domoticz.helpers.xmas(domoticz) then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- BDAY    
                elseif domoticz.helpers.bday(domoticz) then
                    domoticz.helpers.RGB(domoticz,BulbDressoir1,nil,'Red',nil)
                    domoticz.helpers.KELVIN(domoticz,BulbDressoir2,nil,0,nil)
                    domoticz.helpers.RGB(domoticz,BulbDressoir3,nil,'Blue',nil)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                end
            end
            domoticz.helpers.Off(domoticz,BulbKitchenSinkAll)
            domoticz.helpers.Off(domoticz,BulbKitchenAll)
            domoticz.helpers.Off(domoticz,BulbToiletAll)
            domoticz.helpers.Off(domoticz,SwitchCooker)
            domoticz.helpers.RGB(domoticz,BulbBalcony1,25,'Blue',nil)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 30 &')
            --domoticz.log('------------------------==<[ KODI IS FILM AAN AFSPELEN ]>==-----------------', domoticz.LOG_FORCE)

-- KODI TV SHOW 
        elseif (domoticz.devices(KodiStatus).state  == 'TV Shows' and domoticz.globalData.KodiPlayVar == 0) 
        then

            domoticz.globalData.KodiPlayVar = 1 
            domoticz.globalData.KodiStopVar = 0
            
            -- HALLOWEEN             
            if domoticz.helpers.halloween(domoticz) then
                domoticz.devices(BulbLivingroomWall).dimTo(70)
                domoticz.devices(BulbLivingroomWindow).dimTo(50)
            -- X-MAS
            elseif domoticz.helpers.xmas(domoticz) 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)
            -- SENSOR DINING ROOM OFF
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if domoticz.helpers.halloween(domoticz) then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- X-MAS
                elseif domoticz.helpers.xmas(domoticz) then
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                -- BDAY    
                elseif domoticz.helpers.bday(domoticz) then
                    domoticz.helpers.RGB(domoticz,BulbDressoir1,nil,'Red',nil)
                    domoticz.helpers.KELVIN(domoticz,BulbDressoir2,nil,0,nil)
                    domoticz.helpers.RGB(domoticz,BulbDressoir3,nil,'Blue',nil)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(25)
                end
            end
            domoticz.helpers.Off(domoticz,BulbKitchenSinkAll)
            domoticz.helpers.Off(domoticz,BulbKitchenAll)
            domoticz.helpers.Off(domoticz,BulbToiletAll)
            domoticz.helpers.Off(domoticz,SwitchCooker)
            domoticz.helpers.RGB(domoticz,BulbBalcony1,25,'Blue',nil)
            os.execute('/home/pi/domoticz/scripts/Peter/Nanoleaf/nano.sh -b 30 &')
            --domoticz.log('------------------------==<[ KODI IS SERIE AAN AFSPELEN ]>==----------------', domoticz.LOG_FORCE)

-- KODI SPEELT NIKS        
        elseif (domoticz.devices(KodiStatus).state  == 'On') 
        then

            domoticz.globalData.KodiPlayVar = 0 
            domoticz.globalData.KodiStopVar = 1
            
            -- HALLOWEEN             
            if domoticz.helpers.halloween(domoticz) then
                domoticz.devices(BulbLivingroomAll).dimTo(100)
            -- X-MAS
            elseif domoticz.helpers.xmas(domoticz) 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)
            -- SENSOR DINING ROOM OFF
            elseif (not domoticz.devices(SensorDiningRoomDoor).active) then
                -- HALLOWEEN 
                if domoticz.helpers.halloween(domoticz) then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- X-MAS
                elseif domoticz.helpers.xmas(domoticz) then
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                -- BDAY    
                elseif domoticz.helpers.bday(domoticz) then
                    domoticz.helpers.RGB(domoticz,BulbDressoir1,nil,'Red',nil)
                    domoticz.helpers.KELVIN(domoticz,BulbDressoir2,nil,0,nil)
                    domoticz.helpers.RGB(domoticz,BulbDressoir3,nil,'Blue',nil)
                -- NORMAL
                else
                    domoticz.devices(BulbDressoirAll).dimTo(100)
                end
            end   
            domoticz.helpers.Off(domoticz,BulbKitchenSinkAll)
            domoticz.helpers.Off(domoticz,BulbKitchenAll)
            domoticz.helpers.Off(domoticz,BulbToiletAll)
            domoticz.helpers.Off(domoticz,SwitchCooker)
            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
}

Hello,

I reply a bit late so I hope you’ve found a solution in beween, but just in case, the easiest way I found to migrate my dzVent scripts to HA is to use AppDaemon which enables you to write python scripts for HA. Then you just have to adapt your lua scripts to python. It takes a bit of time for the first one to get used to the different ways to call things, but after that it’s pretty straight forward.

Good luck.

thanks for the reply. In meanwhile I have migrate all my 38 dzvent scripts into HA. It took some days, because its totally different… in some way harder to understand. I miss the:

If LALALA then
action
if LALALA then
action
end
end

Maybe will understand in future how it will work with HA to have more IF statements inside them.
:smiley: