diff --git a/.idea/misc.xml b/.idea/misc.xml
index 7d004e3..8c91e35 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -3,7 +3,7 @@
-
+
diff --git a/.idea/revpipyload.iml b/.idea/revpipyload.iml
index 148e432..0dc1149 100644
--- a/.idea/revpipyload.iml
+++ b/.idea/revpipyload.iml
@@ -4,8 +4,9 @@
+
-
+
\ No newline at end of file
diff --git a/revpipyload/mqttserver.py b/revpipyload/mqttserver.py
index 69c1777..3a97480 100644
--- a/revpipyload/mqttserver.py
+++ b/revpipyload/mqttserver.py
@@ -76,7 +76,8 @@ class MqttServer(Thread):
self._loadrevpimodio()
# Topics konfigurieren
- self._basetopic = basetopic
+ self._basetopic = basetopic.strip("/")
+ self._basetopic_len = len(self._basetopic.split("/"))
self._mqtt_evt_io = join(basetopic, "event/{0}")
self._mqtt_got_io = join(basetopic, "got/{0}")
self._mqtt_io = join(basetopic, "io/{0}")
@@ -214,6 +215,8 @@ class MqttServer(Thread):
def _on_message(self, client, userdata, msg):
"""Sendet piCtory Konfiguration."""
+ proginit.logger.debug("Received topic: {0}".format(msg.topic))
+
if msg.topic == self._mqtt_pictory:
# piCtory Konfiguration senden
self._send_pictory_conf()
@@ -226,27 +229,23 @@ class MqttServer(Thread):
# The I/O name may contain forward slashes. Those look nice on the
# MQTT bus, but make parsing the topic for actions a bit harder since
# we cannot simply split the topic and know at what index to find the
- # action. To find the action we first remove the base topic (keeping
- # in mind that it may or may not have a trailing / in the
- # configuration file), determine the I/O action and finally reassemble
- # the I/O name with slashes.
-
- lst_topic = msg.topic[len(self._basetopic):]
- if lst_topic[0] == '/':
- lst_topic = lst_topic[1:]
- lst_topic = lst_topic.split("/")
- proginit.logger.error("lst_topic {0}".format(lst_topic))
-
- if len(lst_topic) < 2:
- proginit.logger.error("wrong format for topic '{0}', expected '{1}/(get/set/reset)/'".format(msg.topic, self._basetopic))
+ # action. To find the action we remove base topic parts to get the
+ # action and finally reassemble the I/O name with slashes.
+ lst_topic = msg.topic.split("/")[self._basetopic_len:]
+ if len(lst_topic) < 2 or lst_topic[0].lower() not in ("get", "set", "reset"):
+ proginit.logger.error(
+ "wrong format for topic '{0}', expected '{1}/[get|set|reset]/'"
+ "".format(msg.topic, self._basetopic)
+ )
return
# Aktion und IO auswerten
- ioget = lst_topic[0].lower() == "get"
- ioset = lst_topic[0].lower() == "set"
- ioreset = lst_topic[0].lower() == "reset"
+ io_action = lst_topic[0].lower()
+ ioget = io_action == "get"
+ ioset = io_action == "set"
+ ioreset = io_action == "reset"
ioname = '/'.join(lst_topic[1:])
- coreio = ioname.find(".") != -1
+ coreio = ioname.find("core.") == 0
try:
# IO holen
diff --git a/setup.py b/setup.py
index 09abb53..26b1931 100644
--- a/setup.py
+++ b/setup.py
@@ -27,12 +27,13 @@ setup(
license="LGPLv3",
name="revpipyload",
- version="0.9.8",
+ version="0.9.8a1",
scripts=[
"data/revpipyload",
"data/revpipyload_secure_installation",
],
+ packages=[],
install_requires=["revpimodio2 >= 2.5.0"],
python_requires=">=3.2",