I just updated to the last version, and I was trying to create a custom On/Off, as I need to turn one light ON and another Off before taking an collor reading (for my custom Input).
So, I found it is possible to do this by creating a Python code like this:
control.output_off(POWER_STRIP_ID, output_channel=1) # Light Off
But I cannot save any code with this format, as I receive this error:
Full Python code:
1: import os
2: import sys
3: sys.path.append(os.path.abspath('/var/mycodo-root'))
4: from mycodo.mycodo_client import DaemonControl
5: control = DaemonControl()
6: output_id = '357e9057-ca68-4464-88ae-a4fdc1d3ec57'
7:
8: class OutputRun:
9: def __init__(self, logger, output_id):
10: self.logger = logger
11: self.output_id = output_id
12: self.variables = {}
13: self.running = True
14:
15: def stop_output(self):
16: self.running = False
17:
18: def output_code_run_on(self):
19: log_string = "ID: {id}: ON".format(id=output_id)
20: self.logger.info(log_string)
21: #control.output_off(4b9c9cc7-e779-4350-b800-653634518173, 0) # Light Off
22: control.output_on(0da22db6-df12-4461-9be5-62bfc8188b4e, 0) # UV Light On
23:
24: #from RPi import GPIO
25: #GPIO.output(12, 1)
26: #GPIO.output(19, 0)
27:
28: def output_code_run_off(self):
29: log_string = "ID: {id}: OFF".format(id=output_id)
30: self.logger.info(log_string)
31: #control.output_on(4b9c9cc7-e779-4350-b800-653634518173, output_channel=0) # Light On
32: #control.output_off(0da22db6-df12-4461-9be5-62bfc8188b4e, output_channel=0) # UV Light Off
33:
34: #from RPi import GPIO
35: #GPIO.output(12, 0)
36: #GPIO.output(19, 1)
Python code analysis:
************* Module mycodo.user_python_code.output_357e9057-ca68-4464-88ae-a4fdc1d3ec57
pi/Mycodo/mycodo/user_python_code/output_357e9057-ca68-4464-88ae-a4fdc1d3ec57.py:22:28: E0001: invalid syntax (, line 22) (syntax-error)
Interesting, this works:
from RPi import GPIO
GPIO.output(12, 0)