im using dzvents to control soma shades (already works quite well), but i want to add code to read battery level and update on domoticz side (will be triggered and update value every time when i open shades), question is how to update battery level value ? (tried .batteryLevel(20)) but thats not working

next problem would be to parse python script value, but that shouldnt be hard

Code: Select all
return {
on = {
devices = {576}
},
execute = function(domoticz, switch)
local roleta = domoticz.devices(576)
local mac_a = 'D6:84:F4:AD:F7:3A'
local val_shades_on = '0'
local val_shades_off = '100'
local on_command = "python /home/pi/python/SOMA/control.py -t " ..mac_a.. " -c move_target -a " ..val_shades_on
local off_command = "python /home/pi/python/SOMA/control.py -t " ..mac_a.. " -c move_target -a " ..val_shades_off
domoticz.log('TEST', domoticz.LOG_FORCE)
if (switch.state == 'Open') then
domoticz.log('Opening....', domoticz.LOG_FORCE)
domoticz.log(on_command, domoticz.LOG_FORCE)
os.execute(on_command)
-- roleta.batteryLevel(20)
elseif (switch.state == 'Closed') then
domoticz.log('closing....', domoticz.LOG_FORCE)
domoticz.log(off_command, domoticz.LOG_FORCE)
os.execute(off_command)
end
end
}