This Python script allows you to monitor the recording status of vMix, a live production and streaming software, and send MQTT messages based on its recording state. You can customize the MQTT messages and topics to integrate vMix with your home automation or other applications.
Before using this script, make sure you have the following prerequisites:
-
Python: You need to have Python installed on your system. You can download it from Python's official website.
-
Required Python Libraries: This script uses the following Python libraries, which can be installed using pip:
xml.etree.ElementTree
requests
paho.mqtt.client
schedule
You can install these libraries using the following command:
pip install xml.etree.ElementTree requests paho-mqtt schedule
-
vMix: You need to have vMix installed and running with its API enabled on port 8088.
-
MQTT Broker: Set up an MQTT broker and have its IP address ready, as you'll need it to configure the script.
You need to customize the script with your specific configuration:
-
Replace the following variables with your own values:
vMix_ip
: Set this to your vMix server's IP address.mqtt_broker_ip
: Set this to the IP address of your MQTT broker.start_recording_topic
: Set this to the MQTT topic where you want to send the "start recording" message.stop_recording_topic
: Set this to the MQTT topic where you want to send the "stop recording" message.
-
You can also customize the MQTT message payloads by modifying the
send_mqtt_message
function, the default is to turn the device On when recording, and Off when not.
To use this script, follow these steps:
-
Clone or download this repository to your local machine.
-
Install the necessary libraries stated previously
-
Customize the script as described in the "Customization" section.
-
Open a terminal and navigate to the folder where you saved the script.
-
Run the script using the following command:
python3 main.py
The script will monitor vMix's recording status and send MQTT messages to the specified topics whenever the recording state changes.
--logs
or-l
: Enable log messages. If enabled, the script will display additional information for debugging purposes.
-
The script uses the
schedule
library to periodically check vMix's recording status. By default, it checks every 10 seconds. You can modify the schedule as needed in thecheck_recording
function. -
The script will continuously run in the terminal until you manually stop it (e.g., by pressing Ctrl+C).
-
Make sure the MQTT broker is running and accessible from the machine where you run the script.
-
This script is designed to run on a continuous basis. You can use tools like
systemd
(on Linux) orTask Scheduler
(on Windows) to ensure it runs automatically when your system starts. -
Monitor the script's console output for information about the recording status and MQTT messages.
With ❤️ from Max Broomfield