Release MQTT Adapter - Now forked (2022)
#1
As per October 2022, a forked version is available.

Go to the update post here: https://forum.kodi.tv/showthread.php?tid...pid3114761

*added by moderator*
----------------------------------------------------------------------------------------------------------------------------------

Overview
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.

It's intended as a building block in heterogenous smart home environments where an MQTT message broker is used as the centralized message bus. See https://github.com/mqtt-smarthome for a rationale and architectural overview.


Download
Source is available on GitHub at https://github.com/owagner/kodi2mqtt
Installable packages are available on the GitHub release page https://github.com/owagner/kodi2mqtt/releases/


Settings
The addon has three settings:

* the MQTT broker's IP address or host name (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/".


Topics
The addon publishes on the following topics (prefixed with the configured topic prefix):
  • connected: 2 if the addon is currently connected to the broker, 0 otherwise. This topic is set to 0 with a MQTT will.
  • status/playbackstate: a JSON-encoded object with the fields
    - "val" for the current playback state with 0=stopped, 1=playing, 2=paused
    - "kodi_playbackdetails": an object with further details about the playback state. This is effectivly the result
    of the JSON-RPC call Player.GetItem with the properties "speed", "currentsubtitle", "currentaudiostream", "repeat"
    and "subtitleenabled"
  • status/progress: a JSON-encoded object with the fields
    - "val" is the percentage of progress in playing back the current item
    - "kodi_time": the playback position in the current item
    - "kodi_totaltime": the total length of the current item
  • status/title: a JSON-encoded object with the fields
    - "val": the title of the current playback item
    - "kodi_details": an object with further details about the current playback items. This is effectivly the result
    of a JSON-RPC call Player.GetItem with the properties "title", "streamdetails" and "file"

The addon listens to the following topics (prefixed with the configured topic prefix):
  • command/notify: Either a simple string, or a JSON encoded object with the fields "message" and "title". Shows
    a popup notification in Kodi
  • command/play: Either a simple string which is a filename or URL, or a JSON encoded object which correspondents
    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)
    - "2" or "pause" to stop playback (when playing)
    - "next" to play the next track
    - "previous" to play the previous track

Feedback welcome!

Best Regards,
Olli
Reply
#2
Great add-on, thanks! One suggestion: Could you allow hostname as input for the server instead of only IP address?
Reply
#3
I just started playing around with MQTT & Kodi and I think this can really be the start of something amazing. With this plugin installed on multiple Kodi instances and all of them sharing the same storage & database (the typical MySQL config), it would be possible for them to either periodically broadcast their activity or respond to requests to publish their activity on-demand (by any other instance). I'm thinking Kodi instance name (Living room, bedroom, etc), the currently playing file, and the position of the transport. It would be possible for another client to get approximately synchronized to the same position in the same file. It would also give users the ability to pause in one room and resume in any other. Standard MQTT keep-alives and last-will-and-testament concepts would allow any client to know which other instances on the network were active (not just runnning). Even the remote apps would be able to cause > 1 instance to do the same thing at the same time. For instance, imagine clicking the Share icon on your mobile device and sharing to an app that publishes a request onto MQTT asking any/every client to start playing the same YouTube clip at the same time.

I don't have any Python experience, but I am a developer and with a lot of message queue experience. I'm happy to help out with the protocol/messaging design... I'm tempted to start teaching myself Python for this.

Any chance you can get TLS working?
Reply
#4
Not sure if this is still being developed but if it is then this project should probably be renamed to meet the official trademark policy?

http://kodi.wiki/view/Official:Trademark_Policy

You should not use "Kodi" or "XBMC" in the name of unoffical products, see this section:

http://kodi.wiki/view/Official:Trademark...d_Software

Related Software

XBMC Foundation products are designed to be extended, and we recognize that community members writing add-ons and supplemental software need some way to identify the XBMC Foundation product to which their add-on/software pertain. Our main concern about add-ons and related software is that consumers not be confused as to whether they are official (meaning approved by XBMC Foundation) or not. To address that concern, we request that add-ons and supplemental software names not include, in whole or in part, the words "XBMC Foundation" or "Kodi" in a way that suggests a connection between XBMC Foundation and the add-on or software (e.g., "Frobnicator for Kodi," would be acceptable, but "Kodi Frobnicator" would not).
Reply
#5
Information 
I've just released v0.4:

Code:
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"

@jvandenbroek: done

@RockerC: thanks for pointing this out, I've amended the documentation and addon zip name accordingly; at the UI level, it was already just called "MQTT Adapter" throughout.

Best Regards,
Olli
Reply
#6
Thanks for this great addon! I'm using it with my Openelec installation. Unfortunately sometimes I get an Addon Error and afterwards the service seems to stop until I do a restart.

Any advice on how to debug this issue?
Reply
#7
Hi,

I've now uploaded a new version which should fix the error:

https://github.com/owagner/kodi2mqtt/releases/tag/v0.5

Best Regards,
Olli
Reply
#8
I've just uploaded v0.8 at https://github.com/owagner/kodi2mqtt/releases/tag/v0.8

Code:
v0.8 - 2015-09-15 - owagner
  - updated PAHO library to v1.0.2 to fix startup issues caused by
    "localhost" not resolving, which apparently seems to happen on some
    OpenELEC installations. Fixes #6 (thanks fab33)

v0.7 - 2015-08-01 - existsec
  - include "thumbnail" and "fanart" in title message

v0.6 - 2015-07-29 - owagner
  - include "kodi_playerid" and "kodi_playertype" in playbackstate updates [#2]
Reply
#9
Smile 
Awesome addon Olli (Owagner)!

I'm using it with my Raspberry Pi Openelec installation and on three other PC's in an home.
Each install of Kodi has five user profiles and links to a central SQL database for syncing user watched lists.

I am now using your plugin to post each install's details of who is watching what, when & where to a Mosquitto MQTT broker (Also on a Raspberry Pi)
The MQTT messages are picked up by EventGhost on my central server which displays system wide status on its home screen using Rainmeter.

Your plugin has filled in a gap in my system and I appreciate your hard work.
Would love to compare notes on home automation....

Again thanks.
Reply
#10
Please delete....
Reply
#11
Really nice Cool

Any plans for inclusion in the official repo?
'Zero

-----
Kodi Krypton 17.6 | Linux | FTV w/LiveTV 'Fred edition' | Maraschino Git | Kore v 2 | Chorus2
-----
On a long enough timeline. The survival rate for everyone drops to zero.
Reply
#12
Hi Olli

I really like your addon - I think it will help get around a problem with the old xbmc binding in OpenHAB which does not seem to have been updated for some time. MQTT Adapter was simple to setup and configure and ran without issues. Do you have any future plans for it?

A couple of points :

1) When I boot my system, it can take a while before the network (and hence the MQTT broker) become available. MQTT Adapter tries to connect to the MQTT broker but when it cannot, it fails to retry. It is necessary for me to disable and then re-enable the addon in order to get it started. It would be great if MQTT Adapter could retry periodically until the connection succeeds.

2) I think it would be good if the update period of the progress sentence could be made user configurable.

Thanks again for a great addon - wish I had thought of it!
Reply
#13
(2016-02-04, 10:09)namirda Wrote: Hi Olli

I really like your addon - I think it will help get around a problem with the old xbmc binding in OpenHAB which does not seem to have been updated for some time. MQTT Adapter was simple to setup and configure and ran without issues. Do you have any future plans for it?

A couple of points :

1) When I boot my system, it can take a while before the network (and hence the MQTT broker) become available. MQTT Adapter tries to connect to the MQTT broker but when it cannot, it fails to retry. It is necessary for me to disable and then re-enable the addon in order to get it started. It would be great if MQTT Adapter could retry periodically until the connection succeeds.

2) I think it would be good if the update period of the progress sentence could be made user configurable.

Thanks again for a great addon - wish I had thought of it!
Hi namird,

I had the first issue already covered in my fork of the add-on (https://github.com/jvandenbroek/kodi2mqtt) and just added your second request. Make sure you restart Kodi after changing the progress interval, somehow it doesn't do it by itself, which I'll look into later. If all is stable I'll create a pull request for the original project.

[edit]Just created a pull request for the official fork, hopefully some of my additions can be included.[/edit]
Reply
#14
Great thank you!

I have just tried your fork and it is working well. Nice that it is possible to completely disable the progress topic if desired.
Reply
#15
I've just done a new release (V0.12) including jvandenbroek's changes and some others:

https://github.com/owagner/kodi2mqtt/releases/tag/v0.12

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

V0.11 - 2016-02-22 - jvandenbroek
  - optional ignore list to prevent certain content to be published as being
    played back by a word match on title and/or path
  - configurable push frequencies for details and progress
  - automatically retry MQTT connections up to 20 times
  - various minor fixes

v0.10 - 2016-01-30 - 2Zero
  - added TLS parameters to settings
  - noisy logging now optional via "Debug" settings switch

v0.9 - 2015-11-17 - drlobo
  - added MQTT authentication parameters to settings


Best Regards,
Olli
Reply

Logout Mark Read Team Forum Stats Members Help
MQTT Adapter - Now forked (2022)0