update battery level on dummy switch

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
devros
Posts: 183
Joined: Saturday 29 October 2016 20:55
Target OS: -
Domoticz version:
Contact:

update battery level on dummy switch

Post by devros »

hello, 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
}
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: update battery level on dummy switch

Post by dannybloe »

You cannot set the battery level from code. It is a read-only value from dzVents' side.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
devros
Posts: 183
Joined: Saturday 29 October 2016 20:55
Target OS: -
Domoticz version:
Contact:

Re: update battery level on dummy switch

Post by devros »

ok thanks for info
found json command to change this value (&rssi=10&battery=89)
https://www.domoticz.com/wiki/Domoticz_ ... y_level.29
co i can post manual json adress with battery level then

would be great to have it supported in dzvents anyway :)
thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest