Skip to content

mqtt für openwb 2.0#1570

Merged
LKuemmel merged 3 commits intoopenWB:masterfrom
okaegi:smart201
Apr 19, 2024
Merged

mqtt für openwb 2.0#1570
LKuemmel merged 3 commits intoopenWB:masterfrom
okaegi:smart201

Conversation

@okaegi
Copy link
Copy Markdown
Contributor

@okaegi okaegi commented Apr 18, 2024

Neu können auch Temp. übergeben werden.
Brauchte noch ein Anpasung in setdata da sonst topics grad wieder gelöscht. Nur für Openwb 2.0
Gui kommt noch separat.
Siehe auch:
https://forum.openwb.de/viewtopic.php?t=8415

okaegi added 2 commits April 18, 2024 13:38
Neu können auch Temp. übergeben werden.
Brauchte noch ein Anpasung in setdata da sonst topics grad wieder gelöscht.
Nur für Openwb 2.0
Guid kommt noch separat.
Siehe auch:
https://forum.openwb.de/viewtopic.php?t=8415
Comment on lines +1109 to +1111
pub_single(msg.topic.replace('openWB/set/', 'openWB/', 1), msg.payload.decode("utf-8"),
retain=True, no_json=True, port=1886)
pub_single(msg.topic, "", no_json=True, port=1886)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub_single(msg.topic.replace('openWB/set/', 'openWB/', 1), msg.payload.decode("utf-8"),
retain=True, no_json=True, port=1886)
pub_single(msg.topic, "", no_json=True, port=1886)
self._validate_value(msg, None)

Wenn das Topic nicht validiert werden soll als Datentyp None angeben, dann wird das Topic von openWB/set/ an openWB/ gepublished und das openWB/set/-Topic gelöscht.

Copy link
Copy Markdown
Contributor Author

@okaegi okaegi Apr 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

der self._validate_value(msg, None) ersetzt leider nicht die beiden pub_single..Wenn ich diese beiden durch den self._validate_value(msg, None) ersetzte, stimmt dann der Payload nicht mehr,
update 18:18: Ich glaube das liegt daran:
self._validate_value verwendet in Zeile 151
Pub().pub(msg.topic.replace('set/', '', 1), value, retain=retain)
Pub().pub(msg.topic, "")
in pub.py
def pub(self, topic: str, payload) -> None:
try:
if payload == "":
self.client.publish(topic, payload, qos=0, retain=True)
else:
self.client.publish(topic, payload=json.dumps(payload), qos=0, retain=True)
except Exception:
log.exception("Fehler im pub-Modul")

Der payload wird mit json.dumps(payload) gepublished. Im orginal coding wird durch den no_json=True der payload ohne json. gepublished
if no_json:
publish.single(topic, payload, hostname=hostname, retain=True)

Und das beeinflusst strings Stiebelx wird zu "Stiebelx"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

Comment on lines +1127 to +1128
pass
# diese topics werden im Smarthomemodul mqtt bearbeitet
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pass
# diese topics werden im Smarthomemodul mqtt bearbeitet
self._validate_value(msg, None)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ist geändert

@okaegi okaegi requested a review from LKuemmel April 18, 2024 14:57
@LKuemmel LKuemmel merged commit 6a27548 into openWB:master Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants