Page 1 of 1

Re: Problem set activity time.  [Solved]

Posted: Friday 09 August 2019 21:38
by waaren
Mayki wrote: Friday 09 August 2019 20:37 EDIT: So it's not right, the script runs every minute. Or is it normal behavior?..
Is there any other way?
Yes is normal behavior but I don't think you need to check every minute between 19:45 - 23:59. If you check once at 19:45 triggered by a timer and after that only check based on the device change you will have the best of both worlds :)

By combining the logic of the scripts you will get this:

Code: Select all

return
{
    on = 
    { 
        devices =  {['Samsung TV - Status'] = {'between 19:45 and 23:59'}},   -- <<< --- trigger on device change within time window
        timer =  {'at 19:45'},  -- <<< --- trigger at specific time 
    },

    logging = 
    {   
        level =  domoticz.LOG_DEBUG,
        marker = "Samsung TV Hyperion Wall" 
    },

    execute = function(dz )
        local tv = dz.devices('Samsung TV - Status')
        local light = dz.devices('Hyperion Wall - RGB Light')

        if tv.active then
            light.setColor(0, 0, 255, 20, 0, 0, 4, 255)
        else
            light.dimTo(0)
        end
    end
}