NEWS
RPI Pico W and MQTT Server question
-
Dear all,
For my pergola I designed a servo control to follow the sun and a "dimmer setting" that allows a percentage of the sun.
As I have a double pergola, I also have 2 controls.
The trigonometry calculations are done in my PLC and my 2 RPI Pico W's subscribe to each the same topic "set_angle" and publish their "status".Communication works as expected but in ioBroker objects, the 2 devices share identical topics.
The parameters and code I use in mPython are:
MQTT_BROKER = "rpi4.local" CLIENT_ID = "pergola1" SUBSCRIBE_TOPIC = b"set_angle" PUBLISH_TOPIC1 = b"status" print(f"Begin connection with MQTT Broker :: {MQTT_BROKER}") mqttClient = MQTTClient(CLIENT_ID, MQTT_BROKER, keepalive=60) mqttClient.set_callback(sub_cb) mqttClient.connect() mqttClient.publish(PUBLISH_TOPIC1, str("Homing").encode()) mqttClient.subscribe(SUBSCRIBE_TOPIC) print(f"Connected to MQTT Broker :: {MQTT_BROKER}, and waiting for callback function to be called!")
I've seen duplicate devices where each gets it's own folder with each their respective states in the ioBroker objects but no idea how to do that in this case...
Does anyone know how to get each device into their own designated folder?
Thanks in advance! -
@martiman OK, it was a case of RTFM
SUBSCRIBE_TOPIC =
b"set_angle"b"pergola1/set_angle"
PUBLISH_TOPIC1 =b"status"b"pergola1/status"Solved...