diff --git a/.travis.yml b/.travis.yml index 00f2664..17254aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/README.md b/README.md index c41c12d..f680cc5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -kodi2mqtt -========= +MQTT addon for Kodi +=================== Written and (C) 2015 Oliver Wagner @@ -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. @@ -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/". diff --git a/service.mqtt/LICENSE.txt b/service.mqtt/LICENSE.txt index 6576b8d..ea8e946 100644 --- a/service.mqtt/LICENSE.txt +++ b/service.mqtt/LICENSE.txt @@ -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 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/service.mqtt/addon.xml b/service.mqtt/addon.xml index 6526d4f..b17a6d6 100644 --- a/service.mqtt/addon.xml +++ b/service.mqtt/addon.xml @@ -1,5 +1,5 @@ - + @@ -15,4 +15,4 @@ https://github.com/owagner/kodi2mqtt - \ No newline at end of file + diff --git a/service.mqtt/changelog.txt b/service.mqtt/changelog.txt index ace3705..b4b4310 100644 --- a/service.mqtt/changelog.txt +++ b/service.mqtt/changelog.txt @@ -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 diff --git a/service.mqtt/service.py b/service.mqtt/service.py index 105e004..95e280e 100644 --- a/service.mqtt/service.py +++ b/service.mqtt/service.py @@ -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})) @@ -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() # @@ -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): @@ -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() # @@ -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) \ No newline at end of file