Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Format of MQTT Schedule plugin commands?
#10
Here is some Python code that works with the MQTT_schedule plugin:
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>
Reply


Messages In This Thread
Format of MQTT Schedule plugin commands? - by Ryan - 2019 Aug 10, 01:20 PM
RE: Format of MQTT Schedule plugin commands? - by dan - 2019 Aug 12, 09:18 PM

Forum Jump:


Users browsing this thread: 5 Guest(s)