In a previous Tech Note we presented a method for executing Python code from within HomeSeer. In this Tech Note we will present another method which is simpler and provides greater flexibility.
Through the use of Node-Red, you can greatly simplify the process of executing Python code based on HomeSeer device status and event condition triggers. By utilizing Node-Red, you also decouple from HomeSeer and have greater flexibility.
To start, you will need to ensure Node-Red is install and configured to recognize your HomeSeer system. Next, install the node module node-red-contrib-pythonshell. Once installed, it will be available from the Inputs node group. You will also need to ensure that the computer running Node-Red is also capable of running Python code. Next, create a folder where your Python scripts will be located. You will reference this location when configuring your Python flow.
Once this has been done, the only thing left is to create a flow that executes your Python code.
You can use either a HomeSeer device or event to act as the trigger for your Python code. The example flow shown executes the ‘Security Lockdown’ Python code when the HomeSeer device Garage Door Tilt Sensor is a specific value. By utilizing Node-Red to execute Python code, you can use any available input device as the trigger for your code.
This was a short post due to how simple and easy it is to have a HomeSeer device or event act as a trigger to execute Python by using Node-Red. Don’t hesitate to reach out if you have any questions.