WIP Samsung EX-Link Control Addon
#1
UPDATE: https://github.com/jknight2014/Samsung-E...ree/master this is my initial version. If I have done things right it will toggle the tv when called directly. You can call it with a "mode" argument for dedicated on and off commands: plugin://plugin.script.samsung.control/?mode=on. I have not tested yet.

I am taking a crack at writing my own Kodi addon. I am starting this thread as I work for my impending questions. I have had a few simple python scripts that turn my samsung tv on and off. Switching to OpenElec has forced me to find a new method. OpenElec does not come compiled with the pyserial module. I have found a pyserial addon. But I can not import it directly from anywhere. So I would like to package it as an addon. So my few starter questions,

Is this best done as a script addon? Can one addon have multiple accessable scripts? I have several scripts, tvon, tvoff, and tvtoggle are the ones I want to include now. The only difference being the hex code sent to the tv.

This is my current script:

Code:
import time, serial
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=9600, timeout=1)
resp=""
loop="true"
string="030cf100"
count=0
while loop:
        if count == 10:
                break
        if string in resp:
                print "found it"
                break
                ser.close()
        else:
                ser.write("\x08\x22\x00\x00\x00\x00\xd6")
                data = ser.read(24)
                resp=data.encode('hex')
                print resp
                count = count +1
                time.sleep(1)
print "finished"

I am reading some howtos and I think just packaging it as a script. I use the XBMC Callbacks Plugin by pulli to turn the tv on and off automatically. So I just need to be able to run the script from there.

Suggestions and help apperiated! Once I start the base code I will upload to github and update this post.
Check out all my How-To's at http://KnightCinema.com
Maine, USA.
Using XBMC since Dharma 2010
Reply
#2
Currently modified to simplify the addon. This is my first one and it does work. I mapped a key to script.samsung.control and the tv toggles properly. So my next step is to add the ability to call different commands. What would be the simplest way to acomplish this. I was trying to just do arguments in python but I am a bit confused as to how I add the arguments. Is it possible to register several addon names? Like script.samsung.control.OFF script.samsung.control.ON script.samsung.control.TOGGLE. And have each run a different .py file?
Check out all my How-To's at http://KnightCinema.com
Maine, USA.
Using XBMC since Dharma 2010
Reply

Logout Mark Read Team Forum Stats Members Help
Samsung EX-Link Control Addon0