script not triggering...WHY????

Moderator: leecollings

Post Reply
tiga
Posts: 159
Joined: Friday 27 May 2016 20:15
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: nederland
Contact:

script not triggering...WHY????

Post 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?
User avatar
jvdz
Posts: 2441
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

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

Post 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.
tiga
Posts: 159
Joined: Friday 27 May 2016 20:15
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: nederland
Contact:

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

Post by tiga »

the strange thing is that the first script works perfect.
that is the reading i get from my energy meter.
User avatar
jvdz
Posts: 2441
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

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

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

Who is online

Users browsing this forum: No registered users and 1 guest