Switch on after dimTo issue

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

Moderator: leecollings

Post Reply
hestia
Posts: 361
Joined: Monday 25 December 2017 23:06
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: Paris
Contact:

Switch on after dimTo issue

Post by hestia »

Hi,
I have a dimmer (Qubino DIN Dimmer) and I'd like to restart it from 0 (or 1) when I switched it on after an off.
For instance 0 -> 5% -> 0 -> 55% -> 0 -> 100%
Without anything when I switch it on it restarts from the last on level !
I've tried those settings on the device:
67. Ignore start level: ignore start level
68. Dimming duration: Ignore start level
w/o success :-(

So I wrote this script

Code: Select all

local LED_SWITCH = 1023   -- dimmer switch

return {
     logging =   {   level   =   
                    --domoticz.LOG_ERROR,
                    domoticz.LOG_DEBUG,
                    --domoticz.LOG_INFO,
                    --domoticz.LOG_FORCE
    },
    on = {
    	devices = {LED_SWITCH},
    },

    execute = function(dz, device)
    _G.logMarker =  dz.moduleLabel -- set logmarker to scriptname  
    local LOG_LEVEL = dz.LOG_DEBUG 

    dz.log(device.name .. " " .. device.state .. " " .. tostring(device.level) .. " nValue: " .. device.nValue, LOG_LEVEL)

    local function logWrite(str,level)
        if level == nil then
            level = LOG_LEVEL
        end
        dz.log(tostring(str),level)
    end
 
    local toDo
        if device.active then
            dz.log(device.name .. " level: "  .. device.level, LOG_LEVEL)
            toDo = device.level
            logWrite('toDo: ' .. toDo)
            --device.dimTo(0).silent()
        else
            toDo = 0
            --device.switchOn().silent()
            device.dimTo(1).silent()
            --device.setLevel(1).silent()
            device.switchOff().silent().afterSec(1)
            logWrite('TO OFF')
        end

  end
}
to put the device to level 1 when it is switched off (I tried several combinations of the commented lines)
So the device it set to level on 1 when off.
But when I switched it on again it restarts from the previous level :-(
I've tried to change these settings
67. Ignore start level: ignore start level
68. Dimming duration: Ignore start level
w/o success :-(

Version: 2020.2 (build 12269)
Build Hash: 81b1d645b-modified
Compile Date: 2020-08-23 17:33:23
dzVents Version: 3.0.11

It seemed to have worked yesterday with a previous version, but I didn't managed to make it works again
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest