Dzvents get KODI state

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
TheCondor
Posts: 78
Joined: Thursday 18 June 2015 10:32
Target OS: Linux
Domoticz version:
Contact:

Dzvents get KODI state

Post by TheCondor »

Hi, it's possible ti retrive the current state from a kodi device? Such 'Video' , 'Audio'... I need to diff from when it's Just ON but nothing playing from when it's ON but playing something. Thanks in advance and merry Christmas!
poudenes
Posts: 667
Joined: Wednesday 08 March 2017 9:42
Target OS: Linux
Domoticz version: 3.8993
Location: Amsterdam
Contact:

Re: Dzvents get KODI state

Post by poudenes »

Here my dzVent script with using status Kodi Server

Code: Select all

local Version               = '17.12.15'
local FullManualModus   	= 69
local CookerSwitch	    	= 93
local SwitchMovie	    	= 62
local KodiServer	    	= 104
local WallRight		    	= 2
local WallLeft		    	= 3
local WindowsLeft	    	= 4
local WindowRight 	    	= 5
local WCSwitch		    	= 99
local KitchenSinkSwitch	    = 92
local KodiPlay		    	= 10    -- Kodi is Playing prevent loop on KODI PLAY STATUS
local KodiStop			    = 9     -- Kodi Stop Playing prevent loop on KODI ON STATUS

return {
    active = true,
    on = {
        timer = {'at nighttime'},
        devices = {KodiServer},
    },
    logging = {marker = 'KODI CONTROL ' ..Version..'...........'},
    execute = function(domoticz, device)
        
-- ALWAYS NIGHTTIME ONLY --
-- KODI ON PAUSE LIGHTS ON	
    if
    domoticz.time.isNightTime and
    domoticz.devices(FullManualModus).state == 'Off' and
    domoticz.devices(CookerSwitch).state == 'Off' and
    domoticz.devices(SwitchMovie).state == 'On' and
    domoticz.devices(KodiServer).state == 'Paused'
    then
        domoticz.variables(KodiStop).set(0)
        domoticz.variables(KodiPlay).set(0)
        domoticz.devices(CookerSwitch).switchOn()
        domoticz.devices(WallLeft).dimTo(100)
        domoticz.devices(WallRight).dimTo(100)
        domoticz.devices(WindowsLeft).dimTo(100).afterSec(1)
        domoticz.devices(WindowRight).dimTo(100).afterSec(1)
        domoticz.devices(WCSwitch).switchOn()
        domoticz.log('---------------------------------------------------------------', domoticz.LOG_FORCE)
        domoticz.log('--------------------==<[ KODI OP PAUZE ]>==--------------------', domoticz.LOG_FORCE)
        domoticz.log('---------------------------------------------------------------', domoticz.LOG_FORCE)

-- ALWAYS NIGHTTIME ONLY --
-- KODI ON PLAY LIGHTS OFF	
    elseif
    domoticz.time.isNightTime and
    domoticz.devices(FullManualModus).state == 'Off' and
    domoticz.devices(SwitchMovie).state == 'On' and
    domoticz.variables(KodiPlay).value == 0 and
    domoticz.devices(KodiServer).state == 'Video'
    then
        domoticz.variables(KodiStop).set(0)
        domoticz.variables(KodiPlay).set(1)
        domoticz.devices(CookerSwitch).switchOff()
        domoticz.devices(WallLeft).dimTo(70)
        domoticz.devices(WallRight).dimTo(70)
        domoticz.devices(WindowsLeft).dimTo(10).afterSec(1)
        domoticz.devices(WindowRight).dimTo(10).afterSec(1)
        domoticz.devices(WCSwitch).switchOff()
        domoticz.devices(KitchenSinkSwitch).switchOff()
        domoticz.log('----------------------------------------------------------------', domoticz.LOG_FORCE)
        domoticz.log('--------------------==<[ KODI SPEELT AF ]>==--------------------', domoticz.LOG_FORCE)
        domoticz.log('----------------------------------------------------------------', domoticz.LOG_FORCE)
        
-- ALWAYS NIGHTTIME ONLY --
-- KODI ON STOP PLAY LIGHTS ON	
    elseif
    domoticz.time.isNightTime and
    domoticz.devices(FullManualModus).state == 'Off' and
    domoticz.devices(SwitchMovie).state == 'On' and
    domoticz.variables(KodiStop).value == 0 and
    domoticz.devices(KodiServer).state == 'On'
    then
        domoticz.variables(KodiStop).set(1)
        domoticz.variables(KodiPlay).set(0)
        domoticz.devices(WallLeft).dimTo(100)
        domoticz.devices(WallRight).dimTo(100)
        domoticz.devices(WindowsLeft).dimTo(100).afterSec(1)
        domoticz.devices(WindowRight).dimTo(100).afterSec(1)
        domoticz.devices(CookerSwitch).switchOff()
        domoticz.devices(KitchenSinkSwitch).switchOff()
        domoticz.devices(WCSwitch).switchOff()
        domoticz.log('---------------------------------------------------------------------------', domoticz.LOG_FORCE)
        domoticz.log('--------------------==<[ KODI GESTOPT MET AFSPELEN ]>==--------------------', domoticz.LOG_FORCE)
        domoticz.log('---------------------------------------------------------------------------', domoticz.LOG_FORCE)
        end
    end
}
Maybe you can use it for your script
RPi3 B+, Debain Stretch, Domoticz, Homebridge, Dashticz, RFLink, Milight, Z-Wave, Fibaro, Nanoleaf, Nest, Harmony Hub, Now try to understand pass2php
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest