dzVents 2.4.6. script not working anymore  [Solved]

Easy to use, 100% Lua-based event scripting framework.
Post Reply
Gravityz
Posts: 273
Joined: Wednesday 16 December 2015 20:13
Target OS: NAS (Synology & others)
Domoticz version: V3.8637
Location: Netherlands
Contact:

dzVents 2.4.6. script not working anymore  [Solved]

Post by Gravityz » Monday 25 June 2018 20:03

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
}

rrozema
Posts: 124
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi
Domoticz version: beta
Location: Delft
Contact:

Re: dzVents 2.4.6. script not working anymore

Post by rrozema » Monday 25 June 2018 20:22

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

rrozema
Posts: 124
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi
Domoticz version: beta
Location: Delft
Contact:

Re: dzVents 2.4.6. script not working anymore

Post by rrozema » Monday 25 June 2018 20:38

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...

Gravityz
Posts: 273
Joined: Wednesday 16 December 2015 20:13
Target OS: NAS (Synology & others)
Domoticz version: V3.8637
Location: Netherlands
Contact:

Re: dzVents 2.4.6. script not working anymore

Post by Gravityz » Monday 25 June 2018 20:45

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)

dannybloe
Posts: 1480
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 2.4.6. script not working anymore

Post by dannybloe » Monday 25 June 2018 21:06

You can dump all attributes of the device in the log: device.dump(). Perhaps then you can see what’s wrong.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.

rrozema
Posts: 124
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi
Domoticz version: beta
Location: Delft
Contact:

Re: dzVents 2.4.6. script not working anymore

Post by rrozema » Monday 25 June 2018 21:14

Then try replacing

Code: Select all

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

Code: Select all

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

dannybloe
Posts: 1480
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: dzVents 2.4.6. script not working anymore

Post by dannybloe » Monday 25 June 2018 21:45

Check the dump and inspect the value for the state.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.

Gravityz
Posts: 273
Joined: Wednesday 16 December 2015 20:13
Target OS: NAS (Synology & others)
Domoticz version: V3.8637
Location: Netherlands
Contact:

Re: dzVents 2.4.6. script not working anymore

Post by Gravityz » Monday 25 June 2018 22:35

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

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests