Page 1 of 1

change status device

Posted: Wednesday 16 August 2017 15:57
by krissam44
Hello,

May be my question is stupid but I don't find the solution.
How to make the same thing in dzVents than in LUA :

Code: Select all

local capteurGlobal = 'Consommation Electrique'
commandArray = {} 

if (devicechanged[capteurGlobal]) then
   -- Do something
end   

return commandArray 
capteurGlobal is a OWL CM180+ which sends information around every minutes.

I try this, without any result :

Code: Select all

return {
    active = true,
    on = {
       devices = { 
           'Compteur Electrique'
       }
    },

    execute = function(domoticz, compteur)

        if (compteur.changed) then
            domoticz.log('------------------ script newtest -------------------------------------') 
            domoticz.log('Reception données OWL')
            domoticz.log('------------------ script newtest -------------------------------------')             
        end
        
    end
}
What am I doing wrong ?

Re: change status device

Posted: Wednesday 16 August 2017 16:17
by mivo
Hi,

you need not to check if device changed if (compteur.changed)..., because dzVents checks this for you based on trigger on = { devices = ....
Your script is started only when this device changes.

Re: change status device

Posted: Wednesday 16 August 2017 17:12
by randytsuch
Also, fyi to use a device in dzvents, you should use in this format

domoticz.devices('Compteur Electrique')


If you search for "The domoticz object" in the dzvents wiki page, it will help show you how to use devices.

Re: change status device

Posted: Thursday 17 August 2017 11:43
by krissam44
Thank you for your help.
The script is functionning, I've just some problems with communication beetween OWL CM180+ and RFXCom.
In normal situation, the CM180 sends information every minute, but sometimes, there is nothing during 20 minutes.
I notice, this situation appears since last beta upgrade of domoticz.

Regards.