Skip to content

Commit

Permalink
v0.13 - 2016-05-01 - owagner
Browse files Browse the repository at this point in the history
  - change logic for command/playbackstate:
     - resume/play/1 will now properly resume when pausing, and attempt to
       start play when playback has endeded. Fixes #17
     - pause/2 will now only pause if the player is actually playing.
       It can no longer be used to toggle pause mode.
     - toggle (new) will now toggle pause mode, similarily to how "pause"
       did before

Also updated README.md, which was lagging behind describing new settings
  • Loading branch information
owagner committed May 1, 2016
1 parent 230671e commit c963718
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ See https://github.com/mqtt-smarthome for a rationale and architectural overview

Dependencies
------------
* Kodi 14 Helix (or newer)
* Kodi 14 Helix (or newer). Tested with 16.1.
* Eclipse Paho for Python - http://www.eclipse.org/paho/clients/python/
(used for MQTT communication)

Expand All @@ -27,11 +27,14 @@ Dependencies

Settings
--------
The addon has three settings:
The addon has multiple settings:

* 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/".
* MQTT authentication and TLS settings
* update frequency intervals
* keyword filtering on content details, to prevent certain kind of content to be e.g. displayed in a SmartHome visualization


Topics
Expand Down Expand Up @@ -64,8 +67,9 @@ The addon listens to the following topics (prefixed with the configured topic pr
to the Player.Open() JSON_RPC call
* command/playbackstate: A simple string or numeric with the values:
- "0" or "stop" to stop playback
- "1" or "resume" to resume playback (when paused)
- "1" or "resume" or "play" to resume playback (when paused or stopped)
- "2" or "pause" to stop playback (when playing)
- "toggle" to toggle between play and pause
- "next" to play the next track
- "previous" to play the previous track

Expand Down
4 changes: 2 additions & 2 deletions service.mqtt/addon.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.mqtt" name="MQTT Adapter" version="0.12" provider-name="owagner">
<addon id="service.mqtt" name="MQTT Adapter" version="0.13" provider-name="owagner">
<requires>
<import addon="xbmc.python" version="2.19.0"/>
</requires>
<extension point="xbmc.service" library="service.py" start="login" />
<extension point="xbmc.addon.metadata">
<summary lang="en">MQTT Adapter, adhering to mqtt-smarthome specification</summary>
<description lang="en">The addon is an adapter to a MQTT broker. It will publish information about what is playing, and provides remote control capability. It adheres to the mqtt-smarthome specification. </description>
<description lang="en">The addon is an adapter to an MQTT broker. It will publish information about what is playing, and provides remote control capability. It adheres to the mqtt-smarthome specification. </description>
<disclaimer lang="en"></disclaimer>
<platform>all</platform>
<license>MIT</license>
Expand Down
9 changes: 9 additions & 0 deletions service.mqtt/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
v0.13 - 2016-05-01 - owagner
- change logic for command/playbackstate:
- resume/play/1 will now properly resume when pausing, and attempt to
start play when playback has endeded. Fixes #17
- pause/2 will now only pause if the player is actually playing.
It can no longer be used to toggle pause mode.
- toggle (new) will now toggle pause mode, similarily to how "pause"
did before

v0.12 - 2016-02-022 - markferry
- fix non-JSON case for handling command/notify

Expand Down
16 changes: 12 additions & 4 deletions service.mqtt/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def load_settings():

activeplayerid=-1
activeplayertype=""
playbackstate=0
lasttitle=""
lastdetail={}

Expand Down Expand Up @@ -66,7 +67,8 @@ def publish(suffix,val,more):
# the state is "playing"
#
def setplaystate(state,detail):
global activeplayerid,activeplayertype
global activeplayerid,activeplayertype,playbackstate
playbackstate=state
if state==1:
res=sendrpc("Player.GetActivePlayers",{})
activeplayerid=res["result"][0]["playerid"]
Expand Down Expand Up @@ -185,13 +187,19 @@ def processplay(data):
player.play(data)

def processplaybackstate(data):
global playbackstate
if data=="0" or data=="stop":
player.stop()
elif data=="1" or data=="resume":
if not player.isPlaying():
elif data=="1" or data=="resume" or data=="play":
if playbackstate==2:
player.pause()
elif playbackstate!=1:
player.play()
elif data=="2" or data=="pause":
if player.isPlaying():
if playbackstate==1:
player.pause()
elif data=="toggle":
if playbackstate==1 or playbackstate==2:
player.pause()
elif data=="next":
player.playnext()
Expand Down

0 comments on commit c963718

Please # to comment.