in addition, a script is running that the selector must convert.
this seems to happen, the selector changes visually, but the http action is not executed.
if I press the selector switch with the mouse, the action will be executed. does anyone have an idea how this is possible?
- Spoiler: show
- -- Title: script_device_kodi
-- Date: 09-01-2017
-- Start, Pause and Stop media playing on Kodi driven media center
-- Define local variables to match (virtual) hardware in Domoticz
-- Make sure capital letters are matching ('Kodi Media Center' is something different than 'kodi media center'), so everything is case sensitive
local kodidevice = 'mediaplayer' -- The name of the Kodi Hardware as it can be found in the 'switches' page
local kodi_multiswitch = 'kodiswitchupdate' -- the name of the self made virtual multi-selector as it can be found in the 'switches' page
local kodi_multiswitch_idx = 96 -- The idx of the self made virtual multi-selector as it can be found in the 'Devices' under 'setup'
-- The following lines are to define the different levels of the selector switch
local kodiplay = "Play" -- by using a variable the possibility is to use a local language on the dashboard (level name)
local kodiplay_level = "10" -- level value of the 'Play' level name
local kodipause = "Pause" -- by using a variable the possibility is to use a local language on the dashboard (level name)
local kodipause_level = "20" -- level value of the 'Pause' level name
local kodistop = "Stop" -- by using a variable the possibility is to use a local language on the dashboard (level name)
local kodistop_level = "0" -- level value of the 'Stop' level name
commandArray = {}
-- Set Kodi to react to input of selector switch in Domoticz
if (devicechanged[kodi_multiswitch] == kodiplay and (otherdevices [kodidevice] ~= "Audio" and otherdevices [kodidevice] ~= "Video")) then
commandArray [kodidevice] = "Play"
elseif (devicechanged[kodi_multiswitch] == kodipause and otherdevices [kodidevice] ~= "Paused") then
commandArray [kodidevice] = "Pause"
elseif (devicechanged[kodi_multiswitch] == kodistop and otherdevices [kodidevice] ~= "On") then
commandArray [kodidevice] = "Stop"
end
-- Update selector switch in Domoticz to react to status change of Kodi, but don't fire the above code (update device only, instead of creating a 'devicechanged' event)
if ((devicechanged[kodidevice] == "Audio" or devicechanged[kodidevice] == "Video") and otherdevices [kodi_multiswitch] ~= kodiplay) then
commandArray ['UpdateDevice'] = kodi_multiswitch_idx .. '|0|' .. kodiplay_level
elseif (devicechanged[kodidevice] == "Paused" and otherdevices [kodi_multiswitch] ~= kodipause) then
commandArray ['UpdateDevice'] = kodi_multiswitch_idx .. '|0|' .. kodipause_level
elseif (devicechanged[kodidevice] == "On" and otherdevices [kodi_multiswitch] ~= kodistop) then
commandArray ['UpdateDevice'] = kodi_multiswitch_idx .. '|0|' .. kodistop_level
end
return commandArray