Page 1 of 1

script not triggering...WHY????

Posted: Saturday 02 April 2022 15:10
by tiga
i have a script that updates a dummy electrical counter (device is called "huidig verbruik").
this script works perfect

Code: Select all

local elektriciteit = 'elektriciteit'
local idxhuidigverbruik = 7039
local blanco = 0

 
commandArray = {}
 
if devicechanged[elektriciteit] then
        sgebruik_hoog_tarief, sgebruik_laag_tarief, slevering_hoog_tarief, slevering_laag_tarief, sinkoop, slevering = otherdevices_svalues[elektriciteit]:match("([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);([^;]+)")
        sgebruik_hoog_tarief = tonumber(sgebruik_hoog_tarief)
        sgebruik_laag_tarief = tonumber(sgebruik_laag_tarief)
        slevering_hoog_tarief = tonumber(slevering_hoog_tarief)
        slevering_laag_tarief = tonumber(slevering_laag_tarief)
        sinkoop = tonumber(sinkoop)
        slevering = tonumber(-slevering)
        
        
        --print(sgebruik_hoog_tarief)
        --print(sgebruik_laag_tarief)
        --print(slevering_hoog_tarief)
        --print(slevering_laag_tarief)
        --print(sinkoop)
        --print(slevering)
        
        if sinkoop >0 then
            commandArray = {['UpdateDevice'] = idxhuidigverbruik .. '|0|' .. tostring(sinkoop) .. ';' .. tostring(blanco)}
        end
        
        if sinkoop ==0 then
            commandArray = {['UpdateDevice'] = idxhuidigverbruik .. '|0|' .. tostring(slevering) .. ';' .. tostring(blanco)}
        end        
    
end
 
return commandArray
but when i want to trigger an other lua (device based) script with the "huidig verbruik" device i can not get it to trigger.
something like this does not work:

Code: Select all

if devicechanged['huidig verbruik'] then ........
why does it not work?

Re: script not triggering...WHY????

Posted: Saturday 02 April 2022 16:09
by jvdz
Pretty sure that an updatedevice operation on sensors in LUA will not trigger the event system and don't think you can change that.
I believe dzevent does have the option to trigger the event system when updating a sensor or else you need to use the API interface with a JSON call to update.

Re: script not triggering...WHY????

Posted: Saturday 02 April 2022 16:30
by tiga
the strange thing is that the first script works perfect.
that is the reading i get from my energy meter.

Re: script not triggering...WHY????

Posted: Saturday 02 April 2022 16:47
by jvdz
Why is that strange? I assume it is a device from a regular hardware definition so one expect the eventsystem to trigger an event.