change status device

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

Moderator: leecollings

Post Reply
krissam44
Posts: 3
Joined: Wednesday 16 August 2017 15:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

change status device

Post 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 ?
mivo
Posts: 80
Joined: Friday 21 April 2017 8:58
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Czechia
Contact:

Re: change status device

Post 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.
My toys:
Raspberry Pi 3 + UPS PIco HV3.0 A Stack
Minibian (Raspbian Jessie) + Domoticz beta
RFLink 433 Gateway, 1wire DS18B20 temp sensors (GPIO)
RaZberry module + 2x Comet Z-Wave + Z-wave socket
---
Plugins: WeMo Switch, UPS PIco HV3.0A on GitHub
randytsuch
Posts: 90
Joined: Sunday 20 March 2016 18:56
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: LA, Ca USA
Contact:

Re: change status device

Post 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.
krissam44
Posts: 3
Joined: Wednesday 16 August 2017 15:33
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: change status device

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

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest