Relays are a great way to control high power devices using our raspberry pis low voltage GPIO. MudPi allows you add relays and control them by publishing events over redis to the channel the relay is listening on.
Relays can be configured for both the main MudPi controller and nodes. However it is recommended to use relays typically on a main controller for system reliability.
Below is an example of a relay configuration.
{
"relays": [
{
"name": "Relay 1",
"pin": 27,
"normally_open": true,
"group": "group1",
"topic": "garden/pi/relays/1",
"key": "relay_1"
}
}
Option | Type | Required | Description |
pin | [Integer] | Yes | GPIO pin on the raspberry pi the relay is connected to. |
key | [String] | Yes | A unique slug value that is used to identify the relay. This value with also used as they key with '_state' appended to store relay state in redis. i.e. relay_1_state |
name | [String] | No | Friendly display name of the relay. Useful for UI. |
normally_open | [Boolean] | No | Type of relay connection normally open or normally closed. Default False |
group | [String] | No | Assign relay to a group to control multiple relays at once. |
topic | [String] | No | Channel that relay will listen for command on. If relays share a channel they will both trigger when a command is sent! Default 'mudpi/relays/[relay_key]' |
restore_last_known_state | [Boolean] | No | A setting that when the system crashes, it enables relays to look for the last saved state in redis and attempt to restore it. Default False |
Learn more about relays and how to trigger them under the relay docs.