2021 Jul 21, 05:48 PM
Hi All,
I have two SIP controllers and I am trying to set one up as a master controller and the other as its slave. I cannot get the slave controller to run in slave mode.
Question: Besides correctly setting the parameters in the relevant plugins pages, do I need to modify any python scripts in order to let the master control the slave? If no script needs to be modified, could someone please point out the errors in my parameters setup or in the assumptions I make below?
My setup:
Two Raspberry Pi Zero WH’s, one for the master, controlling 16 channels, and the other for the slave also controlling 16 channels. Both rPi’s run on "Raspbian GNU/Linux 10 (buster)"
SIP software version: 4.1.20
I use 32 LED’s to represent the 32 valves to facilitate troubleshooting.
I use four shift registers, each controlling 8 channels by following the wiring instructions here:
https://github.com/Dan-in-CA/sip/wiki/Relay-interface
Here is a picture showing the master on the right controlling blue LED’s; the slave on the left controls green LED’s. The two controllers are assembled on the same breadboard but there is no electrical connection between the two controller circuits.
--Fig A: two controllers with labels
I verify the hardware works as expected by setting up identical programs on the two controllers and run both first in auto mode to verify. Both sets of LED’s switch on and off according to a simple program schedule described further down.
Fig B: Blue LED turns on indicating master circuit works properly in auto mode
Fig C: Green LED turns on indicating slave circuit works properly in auto mode
The program schedule runs in sequential mode, turning on each LED for 2 seconds, lasting 16*2 = 32 seconds. Then repeat every minute from the first minute of day to the last minute of day.
--Figure D: Both controllers run the same program schedule
To set up the master-slave communication, I follow the instructions in the MQTT slave docs, found here:
http://192.168.0.114/static/docs/plugins/slave-docs.html,
where 192.168.0.114 is my slave ip address.
(This link is accessible by pressing the HELP button under the page MQTT Slave Plugin.)
The two figures below show parameters of the Base MQTT plugins
--Figure E:
Top: base mqtt of the master
Bottom: base mqtt of the slave
The broker mqtt runs on the master (localhost in Figure E; and 192.168.0.135 in Figure F). In other words, the broker runs at 192.168.0.135, which is the master’s ip address.
In addition to the above base_mqtt, an mqtt_zone plugin is also installed at the master:
--Figure G: mqtt_zone plugin at the master controller
Likewise, in addition to its base_mqtt, the slave controller has a slave_mqtt plugin. I understand these two additional plugins are complementary, allowing the master to publish, and the slave to subscribe, to the same “Zone topic” -- “sip/zones” in my case.
--Figure H: mqtt_slave plugin at the slave controller
The master and the slave each control 16 channels. I suppose the function of the parameter “First station number” is to map Channel 17 on the master’s program schedule to Channel 1 on the slave’s schedule.
So when Channel 17 on the master is activated on the web UI display, the green LED should light up at Channel 1 on the slave controller. But I am not observing this mapping, leading me to take my own hypothesis with a palm of salt.
The total number of channels on the master’s schedule is 32.
The total number of channels on the slave is 16.
--Figure I:
Left: Master controls 16 channels, but its program schedule contains 32 channels, with the latter 16 (channels 17-32) acting as placeholders, to be mapped to the slave’s 16 channels. Each channel turns on for 2 seconds. In this figure, channel 12 is just about to expire.
Right: the slave controller is set to manual mode, a necessary setting for the slave controller
To verify I have properly installed the paho-mqtt package, I run the following script in the ssh terminal of the master ip address. This script is derived from post #10 in this forum thread (https://nosack.com/sipforum/showthread.php?tid=174). It turns on channels 3 and 5 for 2 and 3 seconds respectively. I observed the green LED turn on correctly so paho-mqtt must have been properly installed.
#########
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import paho.mqtt.publish as publish
def pub():
"""
Send an MQTT message to SIP.
"""
host='192.168.0.135' # URL of system running mosquitto
topic = 'slave01/schedule'
payload = '{"S01":2, "S05":3}' # 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()
########
Of course, the mqtt_schedule plugin must be installed beforehand on the slave controller in order for this paho-mqtt verification to work. Since I run the script from the master’s ssh terminal, and the LED correspondingly lights up in the slave unit, I know the paho-mqtt must have been properly installed in both controllers.
--Figure J: mqtt_schedule parameters at the slave controller with Scheduling topic matching the publication topic in the script above.
We finally reached the bottom of the “slave-docs.html”:
Test your setup:
“With your master and at least one slave set up and running, You can switch the master to manual and you can test individual stations.”
So:
I switched the master to manual.
I leave the slave in the manual mode. -- Shouldn’t I?
I turn on Channel 1 on the master schedule for two seconds. The green LED lights up at Channel 1 of the master, as to be expected.
I turn on Channel 17 on the master schedule for two seconds. No blue LED lights up at any channels of the slave. I would expect Channel 1 of the slave to light up.
--Figure K:
Top: the master log showed two channels turned on manually
Bottom: the slave log did not register any channel activity
If you reach here, thanks for your patience.
Any insight is greatly appreciated.
I have two SIP controllers and I am trying to set one up as a master controller and the other as its slave. I cannot get the slave controller to run in slave mode.
Question: Besides correctly setting the parameters in the relevant plugins pages, do I need to modify any python scripts in order to let the master control the slave? If no script needs to be modified, could someone please point out the errors in my parameters setup or in the assumptions I make below?
My setup:
Two Raspberry Pi Zero WH’s, one for the master, controlling 16 channels, and the other for the slave also controlling 16 channels. Both rPi’s run on "Raspbian GNU/Linux 10 (buster)"
SIP software version: 4.1.20
I use 32 LED’s to represent the 32 valves to facilitate troubleshooting.
I use four shift registers, each controlling 8 channels by following the wiring instructions here:
https://github.com/Dan-in-CA/sip/wiki/Relay-interface
Here is a picture showing the master on the right controlling blue LED’s; the slave on the left controls green LED’s. The two controllers are assembled on the same breadboard but there is no electrical connection between the two controller circuits.
--Fig A: two controllers with labels
I verify the hardware works as expected by setting up identical programs on the two controllers and run both first in auto mode to verify. Both sets of LED’s switch on and off according to a simple program schedule described further down.
Fig B: Blue LED turns on indicating master circuit works properly in auto mode
Fig C: Green LED turns on indicating slave circuit works properly in auto mode
The program schedule runs in sequential mode, turning on each LED for 2 seconds, lasting 16*2 = 32 seconds. Then repeat every minute from the first minute of day to the last minute of day.
--Figure D: Both controllers run the same program schedule
To set up the master-slave communication, I follow the instructions in the MQTT slave docs, found here:
http://192.168.0.114/static/docs/plugins/slave-docs.html,
where 192.168.0.114 is my slave ip address.
(This link is accessible by pressing the HELP button under the page MQTT Slave Plugin.)
The two figures below show parameters of the Base MQTT plugins
--Figure E:
Top: base mqtt of the master
Bottom: base mqtt of the slave
The broker mqtt runs on the master (localhost in Figure E; and 192.168.0.135 in Figure F). In other words, the broker runs at 192.168.0.135, which is the master’s ip address.
In addition to the above base_mqtt, an mqtt_zone plugin is also installed at the master:
--Figure G: mqtt_zone plugin at the master controller
Likewise, in addition to its base_mqtt, the slave controller has a slave_mqtt plugin. I understand these two additional plugins are complementary, allowing the master to publish, and the slave to subscribe, to the same “Zone topic” -- “sip/zones” in my case.
--Figure H: mqtt_slave plugin at the slave controller
The master and the slave each control 16 channels. I suppose the function of the parameter “First station number” is to map Channel 17 on the master’s program schedule to Channel 1 on the slave’s schedule.
So when Channel 17 on the master is activated on the web UI display, the green LED should light up at Channel 1 on the slave controller. But I am not observing this mapping, leading me to take my own hypothesis with a palm of salt.
The total number of channels on the master’s schedule is 32.
The total number of channels on the slave is 16.
--Figure I:
Left: Master controls 16 channels, but its program schedule contains 32 channels, with the latter 16 (channels 17-32) acting as placeholders, to be mapped to the slave’s 16 channels. Each channel turns on for 2 seconds. In this figure, channel 12 is just about to expire.
Right: the slave controller is set to manual mode, a necessary setting for the slave controller
To verify I have properly installed the paho-mqtt package, I run the following script in the ssh terminal of the master ip address. This script is derived from post #10 in this forum thread (https://nosack.com/sipforum/showthread.php?tid=174). It turns on channels 3 and 5 for 2 and 3 seconds respectively. I observed the green LED turn on correctly so paho-mqtt must have been properly installed.
#########
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import paho.mqtt.publish as publish
def pub():
"""
Send an MQTT message to SIP.
"""
host='192.168.0.135' # URL of system running mosquitto
topic = 'slave01/schedule'
payload = '{"S01":2, "S05":3}' # 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()
########
Of course, the mqtt_schedule plugin must be installed beforehand on the slave controller in order for this paho-mqtt verification to work. Since I run the script from the master’s ssh terminal, and the LED correspondingly lights up in the slave unit, I know the paho-mqtt must have been properly installed in both controllers.
--Figure J: mqtt_schedule parameters at the slave controller with Scheduling topic matching the publication topic in the script above.
We finally reached the bottom of the “slave-docs.html”:
Test your setup:
“With your master and at least one slave set up and running, You can switch the master to manual and you can test individual stations.”
So:
I switched the master to manual.
I leave the slave in the manual mode. -- Shouldn’t I?
I turn on Channel 1 on the master schedule for two seconds. The green LED lights up at Channel 1 of the master, as to be expected.
I turn on Channel 17 on the master schedule for two seconds. No blue LED lights up at any channels of the slave. I would expect Channel 1 of the slave to light up.
--Figure K:
Top: the master log showed two channels turned on manually
Bottom: the slave log did not register any channel activity
If you reach here, thanks for your patience.
Any insight is greatly appreciated.