Page 2 of 2

Re: Lua and Kodi

Posted: Thursday 09 June 2016 22:55
by rickwilleme
Just did. Hope they're able to find the root cause of this issue :)
https://github.com/domoticz/domoticz/issues/693

Re: Lua and Kodi

Posted: Sunday 12 June 2016 10:20
by Dnpwwo
I don't believe this is a problem with the Kodi plugin but more a feature of the way events are handled within Domoticz itself :o

From memory, when a new event is submitted for a device it overrides events already in the queue under most circumstances. I believe this is prevent unexpected results if multiple events were sent to a device in rapid succession. At the end of the day, Domoticz is designed to handle simple devices like switches so sending streams of commands does not make sense.

That said, there are work arounds as shown here:

Code: Select all

commandArray = {}

-- loop through all the changed devices
for deviceName,deviceValue in pairs(devicechanged) do
    print ("Device based event fired on '"..deviceName.."', value '"..tostring(deviceValue).."'");
    if (deviceName=='Test Trigger') then
        commandArray[1] = { ['Lounge Kodi'] = 'Pause' }
        commandArray[2] = { ['Lounge Kodi'] = 'Set Volume 50 AFTER 3' }
    end
end

return commandArray
By specifically delaying the second command both are executed as the log shows:

Code: Select all

2016-06-12 18:05:23.419 Kodi: (Lounge Kodi) Sent command: 'Input.ExecuteAction pause'.
2016-06-12 18:05:23.903 LUA: Device based event fired on 'Lounge Kodi', value 'Unknown'
2016-06-12 18:05:23.419 (Kodi Servers) Lighting 2 (Lounge Kodi)
2016-06-12 18:05:26.913 Kodi: (Lounge Kodi) Sent command: 'Set Volume'.
2016-06-12 18:05:26.915 Kodi: (Lounge Kodi) Volume changed to 50.00000, Muted: false.
2016-06-12 18:05:26.973 Kodi: (Lounge Kodi) Volume set to 50.
2016-06-12 18:05:27.137 LUA: Device based event fired on 'Lounge Kodi', value 'Unknown'
2016-06-12 18:05:26.913 (Kodi Servers) Lighting 2 (Lounge Kodi)
Have a play with it but it seemed to me that delays of less than 3 seconds were ignored so maybe you can activate the plugin then schedule the pause.

Good luck :)

Re: Lua and Kodi

Posted: Monday 13 June 2016 8:13
by dannybloe
I agree that for commands that change the actual state of the device this is the best way to go. However, this fails with the 'execute script' command. That is a different beast and you should be able to just send a dozen of those and all of them should be executed. It's like the openURL command or sendNotification (with whatever syntax that is). They have to be queued and executed one by one. So yeah, for pause and play it doesn't make sense to have them execute all, just the last one.

Re: Lua and Kodi

Posted: Saturday 01 April 2017 17:18
by Plaagje
Hi all,

I tried to play around with kodi and lua scripts and would like to pause my Kodi only when kodi is playing video's.
But i can only get to print the On and Off statuses and not Video Audio Photo or Paused...

I have 2 Kodi's (Kodi Livingroom, Kodi Bedroom)

This is my script:

Code: Select all

commandArray = {}

-- loop through all the devices and find the Kodi Mediaplayers
for deviceName in pairs(otherdevices) do
	Name = tostring(deviceName)
	name = deviceName:sub(1,4)
    if (name=='Kodi') then
		print (deviceName..":"..otherdevices[deviceName]);
		if (devicechanged['Doorbell_Switch'] == 'On' and otherdevices[deviceName] == 'Video') then
			commandArray[deviceName] = 'Pause'
		end
    end
end
return commandArray
The only status i see is:

Code: Select all

2017-04-01 17:15:03.275 LUA: Kodi Livingroom:On
2017-04-01 17:15:03.275 LUA: Kodi Bedroom:On
I can see the status on the dummy switch changing to Video

Image


--EDIT--

when the status changes this show up in the log:

Image

Anyone an idea or workaround?