mirror of
https://github.com/naruxde/revpipyload.git
synced 2025-11-08 15:13:52 +01:00
Some additional MQTT updates
This commit is contained in:
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -3,7 +3,7 @@
|
|||||||
<component name="JavaScriptSettings">
|
<component name="JavaScriptSettings">
|
||||||
<option name="languageLevel" value="ES6" />
|
<option name="languageLevel" value="ES6" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (revpi)" project-jdk-type="Python SDK" />
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.8 (revpipyload)" project-jdk-type="Python SDK" />
|
||||||
<component name="PythonCompatibilityInspectionAdvertiser">
|
<component name="PythonCompatibilityInspectionAdvertiser">
|
||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
3
.idea/revpipyload.iml
generated
3
.idea/revpipyload.iml
generated
@@ -4,8 +4,9 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/revpipyload" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/revpipyload" isTestSource="false" />
|
||||||
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/lib" isTestSource="false" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/venv" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.8 (revpi)" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3.8 (revpipyload)" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
@@ -76,7 +76,8 @@ class MqttServer(Thread):
|
|||||||
self._loadrevpimodio()
|
self._loadrevpimodio()
|
||||||
|
|
||||||
# Topics konfigurieren
|
# 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_evt_io = join(basetopic, "event/{0}")
|
||||||
self._mqtt_got_io = join(basetopic, "got/{0}")
|
self._mqtt_got_io = join(basetopic, "got/{0}")
|
||||||
self._mqtt_io = join(basetopic, "io/{0}")
|
self._mqtt_io = join(basetopic, "io/{0}")
|
||||||
@@ -214,6 +215,8 @@ class MqttServer(Thread):
|
|||||||
|
|
||||||
def _on_message(self, client, userdata, msg):
|
def _on_message(self, client, userdata, msg):
|
||||||
"""Sendet piCtory Konfiguration."""
|
"""Sendet piCtory Konfiguration."""
|
||||||
|
proginit.logger.debug("Received topic: {0}".format(msg.topic))
|
||||||
|
|
||||||
if msg.topic == self._mqtt_pictory:
|
if msg.topic == self._mqtt_pictory:
|
||||||
# piCtory Konfiguration senden
|
# piCtory Konfiguration senden
|
||||||
self._send_pictory_conf()
|
self._send_pictory_conf()
|
||||||
@@ -226,27 +229,23 @@ class MqttServer(Thread):
|
|||||||
# The I/O name may contain forward slashes. Those look nice on the
|
# 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
|
# 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
|
# 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
|
# action. To find the action we remove base topic parts to get the
|
||||||
# in mind that it may or may not have a trailing / in the
|
# action and finally reassemble the I/O name with slashes.
|
||||||
# configuration file), determine the I/O action and finally reassemble
|
lst_topic = msg.topic.split("/")[self._basetopic_len:]
|
||||||
# the I/O name with slashes.
|
if len(lst_topic) < 2 or lst_topic[0].lower() not in ("get", "set", "reset"):
|
||||||
|
proginit.logger.error(
|
||||||
lst_topic = msg.topic[len(self._basetopic):]
|
"wrong format for topic '{0}', expected '{1}/[get|set|reset]/<ioname>'"
|
||||||
if lst_topic[0] == '/':
|
"".format(msg.topic, self._basetopic)
|
||||||
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)/<ioname>'".format(msg.topic, self._basetopic))
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Aktion und IO auswerten
|
# Aktion und IO auswerten
|
||||||
ioget = lst_topic[0].lower() == "get"
|
io_action = lst_topic[0].lower()
|
||||||
ioset = lst_topic[0].lower() == "set"
|
ioget = io_action == "get"
|
||||||
ioreset = lst_topic[0].lower() == "reset"
|
ioset = io_action == "set"
|
||||||
|
ioreset = io_action == "reset"
|
||||||
ioname = '/'.join(lst_topic[1:])
|
ioname = '/'.join(lst_topic[1:])
|
||||||
coreio = ioname.find(".") != -1
|
coreio = ioname.find("core.") == 0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# IO holen
|
# IO holen
|
||||||
|
|||||||
3
setup.py
3
setup.py
@@ -27,12 +27,13 @@ setup(
|
|||||||
|
|
||||||
license="LGPLv3",
|
license="LGPLv3",
|
||||||
name="revpipyload",
|
name="revpipyload",
|
||||||
version="0.9.8",
|
version="0.9.8a1",
|
||||||
|
|
||||||
scripts=[
|
scripts=[
|
||||||
"data/revpipyload",
|
"data/revpipyload",
|
||||||
"data/revpipyload_secure_installation",
|
"data/revpipyload_secure_installation",
|
||||||
],
|
],
|
||||||
|
packages=[],
|
||||||
|
|
||||||
install_requires=["revpimodio2 >= 2.5.0"],
|
install_requires=["revpimodio2 >= 2.5.0"],
|
||||||
python_requires=">=3.2",
|
python_requires=">=3.2",
|
||||||
|
|||||||
Reference in New Issue
Block a user