Kodi Light in room
#1
Hi all,

I would like to control a output gpio just to turn off the light in my room when I hit on play and turn on when I hit stop or pause.
This gpio turn on a relay or a triac system.
This should be simple, no X10 system, ambilight etc ...
The script could be written in Python, this is the simplest
I can't find this informations, somebody have idea for extract the play command in Kodi ?

Best regards
Reply
#2
Have fun Wink

addon.xml
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.test"
       name="test"
       version="0.0.0"
       provider-name="test">

    <extension point="xbmc.service" library="service.py" start="login" />

    <extension point="xbmc.addon.metadata">
        <platform>all</platform>
        <license></license>
        <website></website>
        <source></source>
        <email></email>
        <summary lang="en"></summary>
        <description lang="en"></description>
    </extension>
</addon>

service.py
Code:
import xbmc

class Player(xbmc.Player):

    def onPlayBackStarted(self):
        # Will be called when playback starts
        #
        # Use:
        #  - self.isPlayingVideo()
        #  - self.isPlayingAudio()
        # to determine what's playing
        pass

    def onPlayBackPaused(self):
        # Will be called when playback gets paused
        pass

    # There are a few more things you can do.
    # have a look at:
    # http://romanvm.github.io/Kodistubs/_autosummary/xbmc.html#xbmc.Player

if __name__ == '__main__':
    # Initialize our Player class
    player = Player()

    # We need to keep our service script active meaning we have to create a main-loop.
    # That's how it's done properly
    monitor = xbmc.Monitor()
    while not monitor.abortRequested():
        if monitor.waitForAbort(1):
            # Abort was requested while waiting. We should exit
            break
Reply
#3
Thumbs Up 
Nod Nod Nod

Fun guaranteed
Great thank,
Reply

Logout Mark Read Team Forum Stats Members Help
Kodi Light in room1