Skip to content

Commit

Permalink
V0.4 - 2015-06-16 - owagner
Browse files Browse the repository at this point in the history
  - Settings: MQTT broker address is now a text field and thus allows entering of hostnames
  - will now check whether the title information changes during progress
    checking, and will republish the "title" topic if a change was detected
  - increase progress publish rate to 20s (from 30s)
  - avoid "kodi2mqtt" as a name in the documentation and addon itself, and instead stick to "MQTT Adapter"
  • Loading branch information
owagner committed Jun 16, 2015
1 parent bd6c814 commit 1550393
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ language: python

script: "echo Nothing to do"

before_deploy: "zip -r kodi2mqtt_addon.zip service.mqtt"
before_deploy: "zip -r mqtt_addon.zip service.mqtt"

deploy:
provider: releases
api_key:
secure: ngx8lgauODj+3ZHPb062piIHYfGwY3DHrbiEPMH87VYBzvUbRJo/JSVJn/JllULCGDHOXITb79D9dbLcpFW+j23abXmd86dfHeVPUFlhgH+VBXtNjmMV5jWdEDYmCIsVORf+dWq4Z5pQjX9GtCpVOUb9wfMF6mRdIgioWj0TsCM=
file: kodi2mqtt_addon.zip
file: mqtt_addon.zip
skip_cleanup: true
on:
repo: owagner/kodi2mqtt
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
kodi2mqtt
=========
MQTT addon for Kodi
===================

Written and (C) 2015 Oliver Wagner <[email protected]>

Expand All @@ -8,7 +8,7 @@ kodi2mqtt

Overview
--------
kodi2mqtt is a Kodi addon which acts as an adapter between a Kodi media center instance and MQTT.
This is a Kodi addon which acts as an adapter between a Kodi media center instance and MQTT.
It publishes Kodi's playback state on MQTT topics, and provides remote control capability also via
messages to MQTT topics.

Expand All @@ -29,7 +29,7 @@ Settings
--------
The addon has three settings:

* the MQTT broker's IP address (defaults to 127.0.0.1)
* the MQTT broker's host name or IP address (defaults to 127.0.0.1)
* the MQTT broker's port. This defaults to 1883, which is the MQTT standard port for unencrypted connections.
* the topic prefix which to use in all published and subscribed topics. Defaults to "kodi/".

Expand Down
2 changes: 1 addition & 1 deletion service.mqtt/LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ The kodi2mqtt addon is licensed under the terms of the MIT license:

The MIT License (MIT)

Copyright (c) 2015 Oliver Wagner
Copyright (c) 2015 Oliver Wagner <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions service.mqtt/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.mqtt" name="MQTT Adapter" version="0.3" provider-name="owagner">
<addon id="service.mqtt" name="MQTT Adapter" version="0.4" provider-name="owagner">
<requires>
<import addon="xbmc.python" version="2.19.0"/>
</requires>
Expand All @@ -15,4 +15,4 @@
<email></email>
<source>https://github.com/owagner/kodi2mqtt</source>
</extension>
</addon>
</addon>
7 changes: 7 additions & 0 deletions service.mqtt/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
V0.4 - 2015-06-16 - owagner
- Settings: MQTT broker address is now a text field and thus allows entering of hostnames
- will now check whether the title information changes during progress
checking, and will republish the "title" topic if a change was detected
- increase progress publish rate to 20s (from 30s)
- avoid "kodi2mqtt" as a name in the documentation and addon itself, and instead stick to "MQTT Adapter"

V0.3 - 2015-03-22 - owagner
- fixed division by zero when switching TV channels
- now supports command/notify to send notifications
Expand Down
16 changes: 12 additions & 4 deletions service.mqtt/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
__version__ = __addon__.getAddonInfo('version')

activeplayerid=-1
lasttitle=""
lastdetail={}

def sendrpc(method,params):
res=xbmc.executeJSONRPC(json.dumps({"jsonrpc":"2.0","method":method,"params":params,"id":1}))
Expand Down Expand Up @@ -74,10 +76,16 @@ def publishprogress():
#
def publishdetails():
global player,activeplayerid
global lasttitle,lastdetail
if not player.isPlaying():
return
res=sendrpc("Player.GetItem",{"playerid":activeplayerid,"properties":["title","streamdetails","file"]})
publish("title",res["result"]["item"]["title"],{"kodi_details":res["result"]["item"]})
newtitle=res["result"]["item"]["title"]
newdetail={"kodi_details":res["result"]["item"]}
if newtitle!=lasttitle or newdetail!=lastdetail:
lasttitle=newtitle
lastdetail=newdetail
publish("title",newtitle,newdetail)
publishprogress()

#
Expand Down Expand Up @@ -179,7 +187,6 @@ def msghandler(mqc,userdata,msg):

def connecthandler(mqc,userdata,rc):
xbmc.log("MQTT: Connected to MQTT broker with rc=%d" % (rc))
mqc.publish(topic+"connected",2,qos=1,retain=True)
mqc.subscribe(topic+"command/#",qos=0)

def disconnecthandler(mqc,userdata,rc):
Expand All @@ -203,6 +210,7 @@ def startmqtt():
mqc.will_set(topic+"connected",0,qos=2,retain=True)
xbmc.log("MQTT: Connecting to MQTT broker at %s:%s" % (__addon__.getSetting("mqtthost"),__addon__.getSetting("mqttport")))
mqc.connect(__addon__.getSetting("mqtthost"),__addon__.getSetting("mqttport"),60)
mqc.publish(topic+"connected",2,qos=1,retain=True)
mqc.loop_start()

#
Expand All @@ -214,7 +222,7 @@ def startmqtt():
monitor=MQTTMonitor()
player=MQTTPlayer()
startmqtt()
while not monitor.waitForAbort(30):
publishprogress()
while not monitor.waitForAbort(20):
publishdetails()
mqc.loop_stop(True)

0 comments on commit 1550393

Please sign in to comment.