Plugin - Kodi remote Topic is solved

Python and python framework
Post Reply
Neutrino
Posts: 34
Joined: Sunday 08 May 2016 19:00
Target OS: Raspberry Pi
Domoticz version: beta
Location: France
Contact:

Plugin - Kodi remote

Post by Neutrino » Sunday 13 August 2017 23:33

Hi all !
I want to display the kodi remote in order to use it with lirc and control my old Samsung TV.
I'm able to have the good switch, but when i click on the remote, nothing happens... :oops:

I don't know what's wrong with my code... :(

Code: Select all


"""
<plugin key="lirc" name="pilotage via lirc" author="neutrino" version="1.0.0" wikilink="http://www.domoticz.com/wiki/plugins/plugin.html" externallink="https://www.google.com/">
	<params>
	</params>
</plugin>
"""
import Domoticz
import os
import sys
import json

class BasePlugin:
	enabled = True
	def __init__(self):
		#self.var = 123
		return

	def onStart(self):
		Domoticz.Log("onStart called")
		if (len(Devices) == 0):
			Domoticz.Log("creation")
			Domoticz.Device(Name="TVlirc",  Unit=1, Type=17,Image=2, Switchtype=17,Used=1).Create()			

	def onStop(self):
		Domoticz.Log("onStop called")

	def onConnect(self, Connection, Status, Description):
		Domoticz.Log("onConnect called")

	def onMessage(self, Connection, Data):
		Domoticz.Log("onMessage called")

	def onCommand(self, Unit, Command, Level, Hue):
		Domoticz.Log("onCommand called for Unit " + str(Unit) + ": Parameter '" + str(Command) + "', Level: " + str(Level))
		Command = Command.strip()
		action, sep, params = Command.partition(' ')
		action = action.capitalize()
		params = params.capitalize()
		if Unit == 1:	 # TV power switch
			if action == "Off":
				Devices[1].Update(0, "Off")
			elif action == "On":
				Devices[1].Update(1, "On")
			
			# Remote buttons (action is capitalized so chosen for Command)
			elif Command == "ChannelUp": Domoticz.Log("ChannelUp")	   # ChannelUp
			elif Command == "ChannelDown": Domoticz.Log("ChannelDown")	 # ChannelDown
			elif Command == "Channels": Domoticz.Log("Channels")		# Display, shows information on what is playing
			elif Command == "VolumeUp": Domoticz.Log("VolumeUp")		# VolumeUp
			elif Command == "VolumeDown": Domoticz.Log("VolumeDown")	  # VolumeDown
			elif Command == "Mute": Domoticz.Log("Mute")			# Mute
			elif Command == "Select": Domoticz.Log("Select")		  # Confirm
			elif Command == "Up": Domoticz.Log("Up")			  # Up
			elif Command == "Down": Domoticz.Log("Down")			# Down
			elif Command == "Left": Domoticz.Log("Left")			# Left
			elif Command == "Right": Domoticz.Log("Right")		   # Right
			elif Command == "Home": Domoticz.Log("Home")			# Home
			elif Command == "Info": Domoticz.Log("Info")			# EPG
			elif Command == "Back": Domoticz.Log("Back")			# Return
			elif Command == "ContextMenu": Domoticz.Log("ContextMenu")	 # Options
			elif Command == "FullScreen": Domoticz.Log("FullScreen")	  # Exit
			elif Command == "ShowSubtitles": Domoticz.Log("ShowSubtitles")   # Input
			elif Command == "Stop": Domoticz.Log("Stop")			# Stop
			elif Command == "BigStepBack": Domoticz.Log("BigStepBack")	 # Pause
			elif Command == "Rewind": Domoticz.Log("Rewind")		  # Rewind
			elif Command == "PlayPause": Domoticz.Log("PlayPause")	   # TV pause
			elif Command == "FastForward": Domoticz.Log("FastForward")	 # Forward
			elif Command == "BigStepForward": Domoticz.Log("BigStepForward")  # Play
		

	def onNotification(self, Name, Subject, Text, Status, Priority, Sound, ImageFile):
		Domoticz.Log("Notification: " + Name + "," + Subject + "," + Text + "," + Status + "," + str(Priority) + "," + Sound + "," + ImageFile)

	def onDisconnect(self, Connection):
		Domoticz.Log("onDisconnect called")

	def onHeartbeat(self):
		Domoticz.Log("onHeartbeat called")

global _plugin
_plugin = BasePlugin()

def onStart():
	global _plugin
	_plugin.onStart()

def onStop():
	global _plugin
	_plugin.onStop()

def onConnect(Connection, Status, Description):
	global _plugin
	_plugin.onConnect(Connection, Status, Description)

def onMessage(Connection, Data):
	global _plugin
	_plugin.onMessage(Connection, Data)

def onCommand(Unit, Command, Level, Hue):
	global _plugin
	_plugin.onCommand(Unit, Command, Level, Hue)

def onNotification(Name, Subject, Text, Status, Priority, Sound, ImageFile):
	global _plugin
	_plugin.onNotification(Name, Subject, Text, Status, Priority, Sound, ImageFile)

def onDisconnect(Connection):
	global _plugin
	_plugin.onDisconnect(Connection)

def onHeartbeat():
	global _plugin
	_plugin.onHeartbeat()

	# Generic helper functions
def DumpConfigToLog():
	for x in Parameters:
		if Parameters[x] != "":
			Domoticz.Debug( "'" + x + "':'" + str(Parameters[x]) + "'")
	Domoticz.Debug("Device count: " + str(len(Devices)))
	for x in Devices:
		Domoticz.Debug("Device:		   " + str(x) + " - " + str(Devices[x]))
		Domoticz.Debug("Device ID:	   '" + str(Devices[x].ID) + "'")
		Domoticz.Debug("Device Name:	 '" + Devices[x].Name + "'")
		Domoticz.Debug("Device nValue:	" + str(Devices[x].nValue))
		Domoticz.Debug("Device sValue:   '" + Devices[x].sValue + "'")
		Domoticz.Debug("Device LastLevel: " + str(Devices[x].LastLevel))
	return
Thanks for your help :)

zak45
Posts: 272
Joined: Sunday 22 January 2017 12:37
Target OS: Windows
Domoticz version: V3.8153
Contact:

Re: Plugin - Kodi remote

Post by zak45 » Wednesday 23 August 2017 12:39

Hi,
to have it running, you name to put the "keyword" Kodi , somewhere in the name of your plugin : e.g. name="pilotage via lirc and kodi remote"

Neutrino
Posts: 34
Joined: Sunday 08 May 2016 19:00
Target OS: Raspberry Pi
Domoticz version: beta
Location: France
Contact:

Re: Plugin - Kodi remote

Post by Neutrino » Wednesday 23 August 2017 19:50

Yes ! It works with "Kodi" in the name.
Thank you very much :)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest