I have one semi working if you want to give it a try:
import paho.mqtt.client as mqtt
import time
import sys
MQTTpayload = 0
mqttc = mqtt.Client(client_id="")
mqttc.username_pw_set("username", password="")
mqttc.connect("mqtt.mydevices.com", port=1883, keepalive=60)
mqttc.loop_start()
topic = "v1/username/things/clientid/digital/22"
while True:
try:
MQTTpayload = MQTTpayload + 1
print(MQTTpayload)
mqttc.loop()
mqttc.publish(topic, payload=MQTTpayload, retain=True)
time.sleep(5)
except KeyboardInterrupt:
mqttc.loop_stop()
mqttc.disconnect()
sys.exit()
For me it works for about 15 seconds and then starts sending a 1 on channel 1. I tested with a local MQTT server and it appears to be working there so I’m not sure if it’s a Cayenne issue or something with the code?