Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kodi2mqtt_import
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
42loop
kodi2mqtt_import
Commits
d3df56ab
Commit
d3df56ab
authored
9 years ago
by
2Zero
Browse files
Options
Downloads
Patches
Plain Diff
Add option to disable noisy local logging.
parent
b8fa6969
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
service.mqtt/resources/language/English/strings.po
+4
-0
4 additions, 0 deletions
service.mqtt/resources/language/English/strings.po
service.mqtt/resources/settings.xml
+1
-0
1 addition, 0 deletions
service.mqtt/resources/settings.xml
service.mqtt/service.py
+13
-9
13 additions, 9 deletions
service.mqtt/service.py
with
18 additions
and
9 deletions
service.mqtt/resources/language/English/strings.po
+
4
−
0
View file @
d3df56ab
...
...
@@ -32,6 +32,10 @@ msgctxt "#30013"
msgid "MQTT Topic Prefix"
msgstr ""
msgctxt "#30014"
msgid "MQTT Debug Logging"
msgstr ""
msgctxt "#30100"
msgid "Authentication"
msgstr ""
...
...
This diff is collapsed.
Click to expand it.
service.mqtt/resources/settings.xml
+
1
−
0
View file @
d3df56ab
...
...
@@ -4,6 +4,7 @@
<setting
label=
"30011"
type=
"text"
id=
"mqtthost"
default=
"127.0.0.1"
/>
<setting
label=
"30012"
type=
"number"
id=
"mqttport"
default=
"1883"
/>
<setting
label=
"30013"
type=
"text"
id=
"mqtttopic"
default=
"kodi/"
/>
<setting
label=
"30014"
type=
"bool"
id=
"mqttdebug"
default=
"false"
/>
</category>
<category
label=
"30100"
>
<setting
label=
"30101"
type=
"bool"
id=
"mqttanonymousconnection"
default=
"true"
/>
...
...
This diff is collapsed.
Click to expand it.
service.mqtt/service.py
+
13
−
9
View file @
d3df56ab
...
...
@@ -15,9 +15,13 @@ activeplayertype=""
lasttitle
=
""
lastdetail
=
{}
def
mqttlogging
(
log
):
if
__addon__
.
getSetting
(
"
mqttdebug
"
)
==
'
true
'
:
xbmc
.
log
(
log
)
def
sendrpc
(
method
,
params
):
res
=
xbmc
.
executeJSONRPC
(
json
.
dumps
({
"
jsonrpc
"
:
"
2.0
"
,
"
method
"
:
method
,
"
params
"
:
params
,
"
id
"
:
1
}))
xbmc
.
lo
g
(
"
MQTT: JSON-RPC call
"
+
method
+
"
returned
"
+
res
)
mqttloggin
g
(
"
MQTT: JSON-RPC call
"
+
method
+
"
returned
"
+
res
)
return
json
.
loads
(
res
)
#
...
...
@@ -33,7 +37,7 @@ def publish(suffix,val,more):
robj
.
update
(
more
)
jsonstr
=
json
.
dumps
(
robj
)
fulltopic
=
topic
+
"
status/
"
+
suffix
xbmc
.
lo
g
(
"
MQTT: Publishing @
"
+
fulltopic
+
"
:
"
+
jsonstr
)
mqttloggin
g
(
"
MQTT: Publishing @
"
+
fulltopic
+
"
:
"
+
jsonstr
)
mqc
.
publish
(
fulltopic
,
jsonstr
,
qos
=
0
,
retain
=
True
)
#
...
...
@@ -97,7 +101,7 @@ def publishdetails():
class
MQTTMonitor
(
xbmc
.
Monitor
):
def
onSettingsChanged
(
self
):
global
mqc
xbmc
.
lo
g
(
"
MQTT: Settings changed, reconnecting broker
"
)
mqttloggin
g
(
"
MQTT: Settings changed, reconnecting broker
"
)
mqc
.
loop_stop
(
True
)
startmqtt
()
...
...
@@ -130,7 +134,7 @@ class MQTTPlayer(xbmc.Player):
setplaystate
(
1
,
"
speed
"
)
def
onQueueNextItem
():
xbmc
.
lo
g
(
"
MQTT onqn
"
);
mqttloggin
g
(
"
MQTT onqn
"
);
#
# Handles commands
...
...
@@ -172,7 +176,7 @@ def processcommand(topic,data):
elif
topic
==
"
playbackstate
"
:
processplaybackstate
(
data
)
else
:
xbmc
.
lo
g
(
"
MQTT: Unknown command
"
+
topic
)
mqttloggin
g
(
"
MQTT: Unknown command
"
+
topic
)
#
# Handles incoming MQTT messages
...
...
@@ -186,14 +190,14 @@ def msghandler(mqc,userdata,msg):
if
mytopic
.
startswith
(
"
command/
"
):
processcommand
(
mytopic
[
8
:],
msg
.
payload
)
except
Exception
as
e
:
xbmc
.
lo
g
(
"
MQTT: Error processing message %s: %s
"
%
(
type
(
e
).
__name__
,
e
))
mqttloggin
g
(
"
MQTT: Error processing message %s: %s
"
%
(
type
(
e
).
__name__
,
e
))
def
connecthandler
(
mqc
,
userdata
,
rc
):
xbmc
.
lo
g
(
"
MQTT: Connected to MQTT broker with rc=%d
"
%
(
rc
))
mqttloggin
g
(
"
MQTT: Connected to MQTT broker with rc=%d
"
%
(
rc
))
mqc
.
subscribe
(
topic
+
"
command/#
"
,
qos
=
0
)
def
disconnecthandler
(
mqc
,
userdata
,
rc
):
xbmc
.
lo
g
(
"
MQTT: Disconnected from MQTT broker with rc=%d
"
%
(
rc
))
mqttloggin
g
(
"
MQTT: Disconnected from MQTT broker with rc=%d
"
%
(
rc
))
time
.
sleep
(
5
)
mqc
.
reconnect
()
...
...
@@ -213,7 +217,7 @@ def startmqtt():
if
not
topic
.
endswith
(
"
/
"
):
topic
+=
"
/
"
mqc
.
will_set
(
topic
+
"
connected
"
,
0
,
qos
=
2
,
retain
=
True
)
xbmc
.
lo
g
(
"
MQTT: Connecting to MQTT broker at %s:%s
"
%
(
__addon__
.
getSetting
(
"
mqtthost
"
),
__addon__
.
getSetting
(
"
mqttport
"
)))
mqttloggin
g
(
"
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
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment