Smanar / Domoticz-deCONZ

deCONZ plugin for Domoticz (Zigbee application)
GNU General Public License v3.0
36 stars 27 forks source link

Add setting for HeartBeat ? #61

Open Smanar opened 4 years ago

Smanar commented 4 years ago

Need some test to check if this feature is usefull or not

Here a script that need it

return {
    on = {
        devices = {
            'Conbee dongle - Livingroom Switch'
        }
    },
    execute = function(domoticz, device)
        local dimDevice = domoticz.devices('Bedroom Ceiling Light');
        local dimLevel = dimDevice.level;
        local delay = 0

        if device.state == "hold"  then
            repeat
                delay = delay + 0.15
                dimLevel = dimLevel - 10
                domoticz.log('Set ' .. dimDevice.name .. ' to dimLevel '.. dimLevel .. '%, after ' .. delay .. ' seconds', domoticz.LOG_INFO)
                dimDevice.dimTo(dimLevel).afterSec(delay)
            until dimLevel <= 0
        elseif device.state == "Off" then
            domoticz.log('Stop dimming of ' .. dimDevice.name, domoticz.LOG_INFO)
            dimDevice.cancelQueuedCommands()
            if dimDevice.level == 0 then
                dimDevice.switchOff()
            end
        end  
        domoticz.log('dimLevel ' .. dimLevel, domoticz.LOG_INFO)
        domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
    end

We have the problem with Aquara single Gang

@markiboy2all

This device is not made for that, just by curiosity, waht happen if you use long press during 15s ? It will reset the device ? I can't trigger the "hold"on my devices (IDK why, however I have the 2 versions), you need to press for more than 3s ? and you will have only 1 websocket return ?

Because I m trying to understand how work your script. If the heartbeat is set a 1s.

You hold the button
You have the "hold" event
1 s after the code set the device to false using heartbeat
and after ....

Deconz will not send again the "hold" event ? So the device state will be to "off" event you are keeping the pression nope ?