LUA script does fetch value but does not update device Topic is solved

Moderator: leecollings

Post Reply
Ingmar
Posts: 51
Joined: Sunday 04 May 2014 1:34
Target OS: NAS (Synology & others)
Domoticz version:
Location: The Netherlands
Contact:

LUA script does fetch value but does not update device

Post by Ingmar »

Hi guys,

The dummy Weather Underground device shows the outside temperature and the outside feels like temperature (chill) together in one device. For my dashboard I want to have these values separate so I made a LUA script to fetch the values individually. I fetch the values individually and update two designated dummy devices (one for temp and one for chill). However, the temp is never updated on the dummy device, while the chill value is updated without a problem. If i look at the log i can see that both values are fetched correctly so I do not understand why it doesn't work... :roll:

I tried removing the dummy device, adding a new dummy device, swapped the device for temp and chill, but nothing seems to make a difference. For some reason it seems like the chill value can be updated without any issues, but the temp value just doesn't get put through to a dummy device.

Who has any clues? See below a part of my script and the screenshot from the log in which you can see that both values are actually fetched:

Code: Select all

commandArray['UpdateDevice']='187|0|' .. getTempa
commandArray['UpdateDevice']='188|0|' .. getChill
print("Updated outside temp (" .. getTempa .. " degrees) and feels like temp (" .. getChill .. " degrees.)")
Capture.PNG
Capture.PNG (19.18 KiB) Viewed 1641 times

Any suggestion is greatly appreciated!
Synology NAS with stable release, AEON Z-wave, RFXCOM, Toon, Echo Dot, HAbridge, HarmonyHUB, Dashticz.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: LUA script does fetch value but does not update device

Post by waaren »

Ingmar wrote: Monday 07 January 2019 22:39

Code: Select all

commandArray['UpdateDevice']='187|0|' .. getTempa
commandArray['UpdateDevice']='188|0|' .. getChill
print("Updated outside temp (" .. getTempa .. " degrees) and feels like temp (" .. getChill .. " degrees.)")
Any suggestion is greatly appreciated!
Your 2nd commandArray overwrites the first one. They both point to the same key in the commandArray table.
have a look here
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Ingmar
Posts: 51
Joined: Sunday 04 May 2014 1:34
Target OS: NAS (Synology & others)
Domoticz version:
Location: The Netherlands
Contact:

Re: LUA script does fetch value but does not update device

Post by Ingmar »

waaren wrote: Monday 07 January 2019 22:50 Your 2nd commandArray overwrites the first one. They both point to the same key in the commandArray table.
have a look here
Excellent, problem solved. Thank you very much for the quick reply!


For future reference, I've updated the script to below:

Code: Select all

commandArray[#commandArray+1] = {['UpdateDevice']='187|0|' .. getTempa }
commandArray[#commandArray+1] = {['UpdateDevice']='188|0|' .. getChill }
Synology NAS with stable release, AEON Z-wave, RFXCOM, Toon, Echo Dot, HAbridge, HarmonyHUB, Dashticz.
BBI_home
Posts: 25
Joined: Monday 08 December 2014 13:53
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: LUA script does fetch value but does not update device

Post by BBI_home »

Try something like:

--Extract Wind Gust speed from SValue Wind
local wind = otherdevices_svalues['Wind_Zeeland']
print("Metingen Zeeland: "..wind)

local windgust = string.sub(f,1,string.find(f,';',1,true)-1)
-- print("Windgust Zeeland: "..windgust)

g = string.sub(f,string.find(f,';',1,true)+1)
--print("g: "..g)
commandArray[#commandArray+1] = {['UpdateDevice'] = '507|0|' ..windgust}


ps, when you're interested I have a complete working code available.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest