Page 1 of 1

dzVents 2.4.6. script not working anymore  [Solved]

Posted: Monday 25 June 2018 20:03
by Gravityz
this script used to work perfectly but only partially works in 2.4.6.
as far as i can tell it should work

this test does not seem to work anymore
if (device.name == 'Woonkamer schedule' and domoticz.devices('Woonkamer schedule').state == 'Off' and domoticz.devices('CheckIfHome').state == 'Off') then

this test does not work even if all the variables are true
elseif (device.name == 'Woonkamer schedule' and domoticz.devices('Woonkamer schedule').state == 'Off' and domoticz.devices('CheckIfHome').state == 'On') then

Code: Select all

return {
    active = true,
    on = {
 -- de devices die dit script triggeren 
        devices = {
            'Woonkamer schedule',
            'CheckIfHome'
            
        }
    },
    execute = function(domoticz, device, triggerInfo)
-- trigger bevat de info van het device wat de trigger veroorzaakt heeft
-- schakelt woonkamer schedule in en is er niemand thuis dan worden de lampen sfeervol aangezet. dit geldt ook als de lampen al normaal aan staan en iedereen gaat weer weg
THIS PART WORKS:LIGHTS GO ON
        if (domoticz.devices('Woonkamer schedule').state == 'On' and domoticz.devices('CheckIfHome').state == 'Off') then
            domoticz.groups('Woonkamer lampen Sfeervol').switchOn()
            domoticz.log('Woonkamer lampen Sfeervol ingeschakeld')
-- is er wel iemand thuis dan gaan de lampen normaal aan. dit geldt ook als de lampen op sfeervol staan en er komt iemand thuis
        elseif (domoticz.devices('Woonkamer schedule').state == 'On' and domoticz.devices('CheckIfHome').state == 'On') then
                domoticz.groups('Woonkamer lampen').switchOn()
                domoticz.log('Woonkamer lampen ingeschakeld')
        end
--de lampen gaan pas uit als de trigger  veroorzaakt wordt door Woonkamer schedule en iedereen weg/naar bed is. Als er nog mensen op zijn blijven de lampen branden
THIS PART DOES NOT WORK ANYMORE, LIGHTS DO NOT GO OUT
        if (device.name == 'Woonkamer schedule' and domoticz.devices('Woonkamer schedule').state == 'Off' and domoticz.devices('CheckIfHome').state == 'Off') then
-- check of de lampen aan staan voordat ze worden uitgeschakeld. de melding woonkamer lampen uitgeschakeld verschijnt alleen als de lampen van aan naar uit gaan
                if (domoticz.devices('Dressoirlamp').state == 'On') then
                domoticz.groups('Woonkamer lampen').switchOff()
                domoticz.log('Woonkamer lampen uitgeschakeld')
                end
        elseif (device.name == 'Woonkamer schedule' and domoticz.devices('Woonkamer schedule').state == 'Off' and domoticz.devices('CheckIfHome').state == 'On') then
-- check of de lampen aan staan voordat ze worden uitgeschakeld. de melding woonkamer lampen niet uitgeschakeld verschijnt alleen als de lampen aan staan
                 if (domoticz.devices('Dressoirlamp').state == 'On') then
                domoticz.log('Lampen niet uitgeschakeld, er is nog iemand aanwezig')
                end
        end
    end
}

Re: dzVents 2.4.6. script not working anymore

Posted: Monday 25 June 2018 20:22
by rrozema
You could be right that there is very subtle difference in the order that assignments take place. I haven't seen documented anywhere at what time exactly a "device" triggered script gets executed: after the device gets updated or before the device gets updated. So it could be that this has changed. What is documented is that the 2nd parameter to the execute function is the device that changed, including it's new state. So you can try this:

Code: Select all

        if (device.name == 'Woonkamer schedule' and device.state == 'Off' and domoticz.devices('CheckIfHome').state == 'Off') then

Re: dzVents 2.4.6. script not working anymore

Posted: Monday 25 June 2018 20:38
by rrozema
By the way, if that is the case, then will your 1st if not work correctly in all cases too. So please do let us know the result, as Danny may need to do a quick bugfix then...

Re: dzVents 2.4.6. script not working anymore

Posted: Monday 25 June 2018 20:45
by Gravityz
tried it but did not fix things.

i think the problem is not in the domoticz.devices part because that seems to work in the first part of the script.(the lights go on and react to other variables)

it has to be something with the device.name

i know they changed things so you can figur out if device is .isdevice .istimer etc
i however do not want to know what it is because i already know it is a device.
maybe that's what's going wrong and it does not react because we know it is a device but dzVents probably thinks it is something else.

or it is the triple and test(allready tried extra brackets without succes)

Re: dzVents 2.4.6. script not working anymore

Posted: Monday 25 June 2018 21:06
by dannybloe
You can dump all attributes of the device in the log: device.dump(). Perhaps then you can see what’s wrong.

Re: dzVents 2.4.6. script not working anymore

Posted: Monday 25 June 2018 21:14
by rrozema
Then try replacing

Code: Select all

if (domoticz.devices('Dressoirlamp').state == 'On') then
with

Code: Select all

if (domoticz.devices('Dressoirlamp').state ~= 'Off') then

Re: dzVents 2.4.6. script not working anymore

Posted: Monday 25 June 2018 21:45
by dannybloe
Check the dump and inspect the value for the state.

Re: dzVents 2.4.6. script not working anymore

Posted: Monday 25 June 2018 22:35
by Gravityz
i checked the dump and found something completely else.

i updated to V4.9700 and noticed that the hue lights do not switch status to ON when i switch them on using a script.

i test one of those hue lights(which is physical ON but shows OFF in the domoticz interface.

so sorry folks, seems like a bug but not in dzVents