Page 1 of 1

device scripts for PCA9685 dimmers

Posted: Tuesday 15 December 2020 12:00
by pascalspits
Hi,

First of all, let me say that I'm a noob at scripting, but eager to learn !

I want to use Raspi with PCA9685 on I2C bus for creating dimmer channels for LED PWM dimming.
I have succeeded in loading the Adafruit library and the test-script for PCA9685 is working.

Code: Select all

#!/usr/bin/python3

# This simple test outputs a 50% duty cycle PWM single on the 0th channel. Connect an LED and
# resistor in series to the pin to visualize duty cycle changes and its impact on brightness.

from board import SCL, SDA
import busio
 
# Import the PCA9685 module.
from adafruit_pca9685 import PCA9685
 
# Create the I2C bus interface.
i2c_bus = busio.I2C(SCL, SDA)
 
# Create a simple PCA9685 class instance.
pca = PCA9685(i2c_bus)
 
# Set the PWM frequency to 60hz.
pca.frequency = 2000
 
# Set the PWM duty cycle for channel zero to 50%. duty_cycle is 16 bits to match other PWM objects
# but the PCA9685 will only actually give 12 bits of resolution.
pca.channels[15].duty_cycle = 0xFFFF
Now (in my testing environment) I call this script by calling it from "On Action" and "Off Action" in devices, but this is very rudimentary, as it only sets fixed levels (not actually dimming) and also it appears to initialize the I2C bus each time, creating a "dropout" in the PWM causing the lights to flicker each time a script runs ...

So I wonder how to create DEVICE scripts (in Python, because the PCA9685 library is Python) for using these PWM channels as individual dimmer devices ?

I have device (LUA-)scripts for doing this exact thing with ESP-Easy on ESP8266 ...

Code: Select all

commandArray = {}

DomDevice = 'Badkamer-tv'

IP = '192.168.20.10'

 if devicechanged[DomDevice] then
   if(devicechanged[DomDevice]=='Off') then DomValue = 0;
   print ("Turning off " .. DomDevice);
   runcommand = "curl 'http://" .. IP .. "/led/0/" .. DomValue .. "'";
   print (runcommand);
   os.execute(runcommand);
 return commandArray
   else
    DomValue = (otherdevices_svalues[DomDevice]);
    CalcValue = DomValue * 3.3;
   end
   print ("Value received from Domoticz was " .. (DomValue) .." ");
   print ("Dimming "  .. (DomDevice) .. " to " .. (DomValue) .. " ");
   runcommand =  " curl 'http://" .. IP .. "/led/0/" .. CalcValue .. "'";
   print (runcommand);
   os.execute(runcommand);
 end
return commandArray
These scripts read the dimmer levels of the Domoticz devices each time it gets changed and transmit the values to the devices to dim them accordingly ...

Is there a way to "convert" these scripts into Python and tailor them towards the PCA9685 channels ?
(Then I could finally replace my Wifi-dimmers (not really stable) with wired dimmers ... after many years of frustration !)

Can some of you scripting geniusses help a beginning noob with this ?

Forever gratefull,
Pascal
Belgium

Re: device scripts for PCA9685 dimmers

Posted: Friday 15 January 2021 15:06
by SHARK
Hi,

I managed to achieve dimming powerleds lamp using domoticz + python + pca9685 (PWM dimming) with "dummy virtual switch" (name = Blue).
Screenshot 2021-01-15 at 14.55.54.png
Screenshot 2021-01-15 at 14.55.54.png (24.43 KiB) Viewed 317 times
Screenshot 2021-01-15 at 14.56.13.png
Screenshot 2021-01-15 at 14.56.13.png (50.31 KiB) Viewed 317 times
Python script (/home/domoticz/akwarium/led-dimming.py ):

Code: Select all

# Necessary drivers loading 
from pca9685_driver import Device
import sys

# PCA9685 Initialization 
dev = Device(0x40)
dev.set_pwm_frequency(100)

# Power array
led_power = [0, 1, 4, 7, 12, 19, 26, 34, 43, 54, 65, 77, 90, 104, 119, 135, 151, 169, 187, 206, 226, 247, 268, 291, 314, 338, 362, 388, 414, 441, 469, 497, 527, 557, 587, 619, 651, 684, 718, 752, 787, 823, 859, 896, 934, 973, 1012, 1052, 1093, 1134, 1176, 1219, 1262, 1306, 1351, 1396, 1442, 1489, 1536, 1584, 1633, 1682, 1732, 1783, 1834, 1886, 1938, 1992, 2045, 2100, 2155, 2211, 2267, 2324, 2382, 2440, 2499, 2558, 2618, 2679, 2740, 2802, 2865, 2928, 2992, 3056, 3121, 3187, 3253, 3320, 3388, 3456, 3524, 3594, 3663, 3734, 3805, 3877, 3949, 4022, 4095]

# Numer of item from the array above
x = int(sys.argv[2])

# PWM channel number on PCA9685
y = int(sys.argv[1])

led_level = led_power[x]

dev.set_pwm(y, led_level)
LUA Event Script:

Code: Select all

commandArray = {}

for deviceName,deviceValue in pairs(devicechanged) do
    if (deviceName=='Blue') then
        if deviceValue == "Set Level: 1 %" then
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 1")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 1")
        elseif deviceValue == "Set Level: 2 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 2")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 2")
        elseif deviceValue == "Set Level: 3 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 3")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 3")
        elseif deviceValue == "Set Level: 4 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 4")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 4")
        elseif deviceValue == "Set Level: 5 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 5")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 5")
        elseif deviceValue == "Set Level: 6 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 6")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 6")
        elseif deviceValue == "Set Level: 7 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 7")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 7")
        elseif deviceValue == "Set Level: 8 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 8")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 8")
        elseif deviceValue == "Set Level: 9 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 9")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 9")
        elseif deviceValue == "Set Level: 10 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 10")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 10")
        elseif deviceValue == "Set Level: 11 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 11")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 11")
        elseif deviceValue == "Set Level: 12 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 12")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 12")
        elseif deviceValue == "Set Level: 13 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 13")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 13")
        elseif deviceValue == "Set Level: 14 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 14")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 14")
        elseif deviceValue == "Set Level: 15 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 15")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 15")
        elseif deviceValue == "Set Level: 16 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 16")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 16")
        elseif deviceValue == "Set Level: 17 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 17")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 17")
        elseif deviceValue == "Set Level: 18 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 18")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 18")
        elseif deviceValue == "Set Level: 19 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 19")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 19")
        elseif deviceValue == "Set Level: 20 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 20")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 20")
        elseif deviceValue == "Set Level: 21 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 21")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 21")
        elseif deviceValue == "Set Level: 22 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 22")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 22")
        elseif deviceValue == "Set Level: 23 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 23")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 23")
        elseif deviceValue == "Set Level: 24 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 24")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 24")
        elseif deviceValue == "Set Level: 25 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 25")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 25")
        elseif deviceValue == "Set Level: 26 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 26")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 26")
        elseif deviceValue == "Set Level: 27 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 27")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 27")
        elseif deviceValue == "Set Level: 28 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 28")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 28")
        elseif deviceValue == "Set Level: 29 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 29")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 29")
        elseif deviceValue == "Set Level: 30 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 30")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 30")
        elseif deviceValue == "Set Level: 31 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 31")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 31")
        elseif deviceValue == "Set Level: 32 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 32")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 32")
        elseif deviceValue == "Set Level: 33 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 33")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 33")
        elseif deviceValue == "Set Level: 34 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 34")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 34")
        elseif deviceValue == "Set Level: 35 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 35")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 35")
        elseif deviceValue == "Set Level: 36 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 36")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 36")
        elseif deviceValue == "Set Level: 37 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 37")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 37")
        elseif deviceValue == "Set Level: 38 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 38")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 38")
        elseif deviceValue == "Set Level: 39 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 39")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 39")
        elseif deviceValue == "Set Level: 40 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 40")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 40")
        elseif deviceValue == "Set Level: 41 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 41")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 41")
        elseif deviceValue == "Set Level: 42 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 42")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 42")
        elseif deviceValue == "Set Level: 43 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 43")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 43")
        elseif deviceValue == "Set Level: 44 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 44")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 44")
        elseif deviceValue == "Set Level: 45 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 45")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 45")
        elseif deviceValue == "Set Level: 46 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 46")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 46")
        elseif deviceValue == "Set Level: 47 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 47")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 47")
        elseif deviceValue == "Set Level: 48 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 48")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 48")
        elseif deviceValue == "Set Level: 49 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 49")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 49")
        elseif deviceValue == "Set Level: 50 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 50")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 50")
        elseif deviceValue == "Set Level: 51 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 51")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 51")
        elseif deviceValue == "Set Level: 52 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 52")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 52")
        elseif deviceValue == "Set Level: 53 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 53")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 53")
        elseif deviceValue == "Set Level: 54 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 54")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 54")
        elseif deviceValue == "Set Level: 55 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 55")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 55")
        elseif deviceValue == "Set Level: 56 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 56")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 56")
        elseif deviceValue == "Set Level: 57 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 57")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 57")
        elseif deviceValue == "Set Level: 58 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 58")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 58")
        elseif deviceValue == "Set Level: 59 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 59")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 59")
        elseif deviceValue == "Set Level: 60 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 60")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 60")
        elseif deviceValue == "Set Level: 61 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 61")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 61")
        elseif deviceValue == "Set Level: 62 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 62")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 62")
        elseif deviceValue == "Set Level: 63 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 63")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 63")
        elseif deviceValue == "Set Level: 64 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 64")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 64")
        elseif deviceValue == "Set Level: 65 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 65")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 65")
        elseif deviceValue == "Set Level: 66 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 66")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 66")
        elseif deviceValue == "Set Level: 67 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 67")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 67")
        elseif deviceValue == "Set Level: 68 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 68")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 68")
        elseif deviceValue == "Set Level: 69 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 69")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 69")
        elseif deviceValue == "Set Level: 70 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 70")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 70")
        elseif deviceValue == "Set Level: 71 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 71")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 71")
        elseif deviceValue == "Set Level: 72 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 72")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 72")
        elseif deviceValue == "Set Level: 73 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 73")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 73")
        elseif deviceValue == "Set Level: 74 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 74")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 74")
        elseif deviceValue == "Set Level: 75 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 75")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 75")
        elseif deviceValue == "Set Level: 76 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 76")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 76")
        elseif deviceValue == "Set Level: 77 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 77")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 77")
        elseif deviceValue == "Set Level: 78 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 78")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 78")
        elseif deviceValue == "Set Level: 79 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 79")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 79")
        elseif deviceValue == "Set Level: 80 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 80")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 80")
        elseif deviceValue == "Set Level: 81 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 81")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 81")
        elseif deviceValue == "Set Level: 82 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 82")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 82")
        elseif deviceValue == "Set Level: 83 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 83")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 83")
        elseif deviceValue == "Set Level: 84 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 84")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 84")
        elseif deviceValue == "Set Level: 85 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 85")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 85")
        elseif deviceValue == "Set Level: 86 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 86")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 86")
        elseif deviceValue == "Set Level: 87 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 87")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 87")
        elseif deviceValue == "Set Level: 88 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 88")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 88")
        elseif deviceValue == "Set Level: 89 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 89")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 89")
        elseif deviceValue == "Set Level: 90 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 90")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 90")
        elseif deviceValue == "Set Level: 91 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 91")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 91")
        elseif deviceValue == "Set Level: 92 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 92")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 92")
        elseif deviceValue == "Set Level: 93 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 93")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 93")
        elseif deviceValue == "Set Level: 94 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 94")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 94")
        elseif deviceValue == "Set Level: 95 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 95")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 95")
        elseif deviceValue == "Set Level: 96 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 96")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 96")
        elseif deviceValue == "Set Level: 97 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 97")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 97")
        elseif deviceValue == "Set Level: 98 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 98")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 98")
        elseif deviceValue == "Set Level: 99 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 99")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 99")
        elseif deviceValue == "Set Level: 100 %" then    	
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 100")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 100")            
        elseif deviceValue == "Off" then
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 8 0")
                os.execute ("/usr/bin/python3.5 /home/domoticz/akwarium/led-dimming.py 9 0")   
        end
    end
end

return commandArray

I realize this is not a perfect solution (my scripting skills are worse than weak), but it works. I hope it will help you somehow.