Here is some Python code that works with the MQTT_schedule plugin:
You will need to have the python Paho module installed in order for it to work and be sure to change the host to the URL of the Pi you are running mosqitto on.
The payload examples should give you something to work with.
Code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import paho.mqtt.publish as publish
def pub():
"""
Send an MQTT mesage to SIP.
"""
host='192.168.1.XXX' # URL of system runing mosquitto
topic = 'SIP/schedule'
# payload = '[0, 5, 0, 5, 0, 0, 0, 0]' # payload as list (array)
# payload = '{"S01":0, "S02":5, "S03":0, "S04":5, "S05":0, "S06":0, "S07":0, "So8":0}' # payload as Python dictionary (JavaScript object)
payload = '{"S08":5}' # payload as Python dictionary (JavaScript object)
try:
publish.single(topic, payload, hostname=host) # , port=1883, retain=False, qos=0)
except Exception as err:
print("Couldn't publish: ", err)
pub()
You will need to have the python Paho module installed in order for it to work and be sure to change the host to the URL of the Pi you are running mosqitto on.
The payload examples should give you something to work with.
<p><br></p>