Custom Widgets

Do you have a sensor not supported by the application? Create your custom widget! Write your script on the Raspberry Pi and read the results from the RaspController app.

Create your own custom script on the Raspberry Pi. The script must end with the printing of at least one result, this result will be captured by RaspController and displayed.

 

The result must be printed in the format <result1>x</result1>.

Up to 9 results can be printed (<result9>x</result9>).

 

If something is printed from the script without the <result> tags, the application will show a dialog with the text; useful for reporting errors:

print("This is my error text")

#!/usr/bin/python

import random

#Generating a string that contains a random number
value1 = str(random.randint(0, 100))
value2 = str(random.randint(0, 100))
value3 = str(random.randint(0, 100))

#Preparation of the result
result1 = "<result1>{}</result1>".format(value1)
result2 = "<result2>{}</result2>".format(value2)
result3 = "<result3>{}</result3>".format(value3)

#Print the result that will be read by the application
print(result1)
print(result2)
print(result3)

Python example script

App Configuration

Create a new “User Widget” by entering the name and command to run yout script.

When using the Widget, the script will be executed and at the end the result will be shown in the application.

In this step it is possible to assign a label to be associated with each result.

Recursion

Important: Do not use infinite loops in your scripts to show updated results. Instead, use the appropriate “Recursive” function of the app.

The app will execute the script, when it receives a result it will display this. In “recursive” mode, after viewing the data the script will be run again. If the script fails or a dialog is shown, the recursion stops and the script must be restarted manually.

If the “Recursive” mode is active, it is possible to set a delay value between one reading and another (at least 1 second is recommended).

Results

The results obtained by the script will be displayed in the application together with the labels assigned during configuration.

It is possible to show the results as plain text or as a gauge.

Use Gauge


Instead of plain text, you can show the results with a gauge.

In the configuration phase, select “Use gauge” and also set the minimum value, the maximum value, the unit of measurement and the number of decimal places.

 

IMPORTANT: to use the gauge, your script must return only a numeric value (without a unit of measurement): <result1>27.2</result1>

If you return a value that also contains a string (eg <result1>Temp = 27.2°C</result1>), the gauge cannot be used and the result will be displayed as plain text.