Help wanted updatedevice Yocto-Thermocouple!!

Moderator: leecollings

Post Reply
nikels
Posts: 10
Joined: Wednesday 01 July 2015 23:46
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

 Help wanted updatedevice Yocto-Thermocouple!!

Post by nikels »

Hello i am struggling with Lua and updating devices. I both a Thermocouple from yoctopuce I am using this solution of updating devices.

I use the same settings as described in the explanation of Domoticz.
Image



The information the device (Thermocouple) is sending is this.

Code: Select all

Request URI: /json.htm?type=command&param=udevices&script=yoctopuce.lua&timestamp=1450868355&network=virtualwindows&THRMCPL1%2d57DD1%23dataLogger=OFF&THRMCPL1%2d57DD1%23temperature2=13%2e46&THRMCPL1%2d57DD1%23temperature1=15%2e03
The Lua sript i am using is this.

Code: Select all

local temperature = uri['meteo#temperature1'];
local humidity = uri['meteo#temperature2'];

domoticz_updateDevice(150,151,temperature1 .. ";" .. temperature2 .. ";" .. "0" .. ";" .. pressure .. ";" .. "0");
I am using this script from the manual. The devices IDX is 150 and 151the devices are named temerature1 and temperature2. What am I doing wrong or how do I get this working..some help please.
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re:  Help wanted updatedevice Yocto-Thermocouple!!

Post by jvdz »

I have not seen a JSON line like that before, are you sure that should be working and starting the LUA script?
The LUA script shown uses some functions which are not in there or are you only showing a part of the script?
Which manual are you referring to that has this example?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
nikels
Posts: 10
Joined: Wednesday 01 July 2015 23:46
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re:  Help wanted updatedevice Yocto-Thermocouple!!

Post by nikels »

The manual i am using is this: https://www.domoticz.com/wiki/Inserting ... ua_parsers

This manual is for the Temperature device am just copied it! Its my first steps in Domoticz
I followed al the steps: Callback : http://<domoticz ip>:<domoticz port>/json.htm?type=command&param=udevices&script=yoctopuce.lua&

'''yoctopuce.lua''' the name of my script.

I have made two virtual devices Idx 150 temperature1 and two Idx 151 temperature2

I used the ''WWW-Form-UrlEncoded'' setting as descripted in the manual. Together with the script this should also work for the Thermo-couple device that's why i didn't change anything from the settings. Changing it to JSON does not work also.. i think the Lua script only works for the ''WWW-Form'' setting

The meteo-themparate device both have the same software ''VirtualHub'' that creates the ''Outgoing callbacks''
I would like to try the JSON settings but i dont know how to make the Lua script or other script to translate the outgoing callbacks.

I will post the JSON Outgoing callbacks from the ''Virtualhub'' settings.
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re:  Help wanted updatedevice Yocto-Thermocouple!!

Post by jvdz »

Learned something today as I hadn't encountered this option yet before. :)
Do you have the domoticz logging enabled and is anything showing up in the log that indicates an error or that the script is ran?

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re:  Help wanted updatedevice Yocto-Thermocouple!!

Post by jvdz »

I did a quick test using you total url and created a lua script in lua_parsers,
The Webpage returns a JSON: OK, but the domoticz log shows:

Code: Select all

Error: WebServer: /home/pi/domoticz/scripts/lua_parsers/test.lua:1: attempt to index global 'uri' (a nil value)
This would indicate that the uri array is not build at all by domoticz and have no idea why that is.
Same happens when I use the url in the example in the WiKi.

ps:I am using the latest production version.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
nikels
Posts: 10
Joined: Wednesday 01 July 2015 23:46
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re:  Help wanted updatedevice Yocto-Thermocouple!!

Post by nikels »

Hello i am getting this as a result! Both my virtual devices nothing shows. the log! tells me the same as your result. Jvdz

Code: Select all

Error: WebServer: /usr/local/domoticz/var/scripts/lua_parsers/yoctapuce.la:4: attempt to concatenate global 'pressure' (a nil value)
When i push the ''test'' button i get this result.

Code: Select all

{

      ''status'' : ''OK'',
      ''title'' : ''Update Device''
}
     [Connection closed]
Changing the ''Virtualhub '' to JSON i get the same results when i press the ''test'' button. ''OK!!'' But also this results in the same error code in Domoticz log!

Code: Select all

Error: WebServer: /usr/local/domoticz/var/scripts/lua_parsers/yoctapuce.la:4: attempt to concatenate global 'pressure' (a nil value)
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re:  Help wanted updatedevice Yocto-Thermocouple!!

Post by jvdz »

Looks like you have a different error. I do believe that you have the wrong fieldnames in there.
Your URL contains 2 temperatures with a field name of HRMCPL1-57DD1#temperature1 and HRMCPL1-57DD1#temperature2 so guess it should look something like the below script.

Code: Select all

print(#uri)
local temperature1 = uri['THRMCPL1-57DD1#temperature1'];
local temperature2 = uri['THRMCPL1-57DD1#temperature2'];
print(temperature1)
print(temperature2)
print(temperature,humidity)
domoticz_updateDevice(150,0,temperature1 .. ";" .. temperature1);
I also added print(#uri) at he top to check how many entries the array contains for debugging.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
nikels
Posts: 10
Joined: Wednesday 01 July 2015 23:46
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re:  Help wanted updatedevice Yocto-Thermocouple!!

Post by nikels »

Hello after a quick test got one reading showing other is also reading but not showing.

Code: Select all

2015-12-24 16:45:39.615 WebServer: udevices: 0
2015-12-24 16:45:39.615 WebServer: udevices: 13.02
2015-12-24 16:45:39.616 WebServer: udevices: 11.18
2015-12-24 16:45:39.616 WebServer (updateDevice from LUA) : idx=150 nvalue=151 svalue=11.18;13.02 invalue=151 signallevel=12 batterylevel=255
I used the code provided by jvdz

Code: Select all

print(#uri)
local temperature1 = uri['THRMCPL1-57DD1#temperature1'];
local temperature2 = uri['THRMCPL1-57DD1#temperature2'];
print(temperature1)
print(temperature2)
print(temperature,humidity)
domoticz_updateDevice(150,151,temperature1 .. ";" .. temperature2);]

Temperature 1 = 150
temperature 2 = 151

Its working but just one of the two readings. Temperature 1 is working i am doing something wrong.
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re:  Help wanted updatedevice Yocto-Thermocouple!!

Post by jvdz »

It makes sense that only one device updates as I think you need to do this for 2 devices when I understand it corectly:

Code: Select all

domoticz_updateDevice(150,0,temperature1]
domoticz_updateDevice(151,0,temperature2]
I had put in the extra print() statements to see how many entries you have in the array and the content of the 2 variables. They should show in your logfile and mught want to take them out when it is working.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
nikels
Posts: 10
Joined: Wednesday 01 July 2015 23:46
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re:  Help wanted updatedevice Yocto-Thermocouple!!

Post by nikels »

Code: Select all

2015-12-24 17:43:54.409 WebServer: udevices: 0
2015-12-24 17:43:54.409 WebServer: udevices: 13.63
2015-12-24 17:43:54.409 WebServer: udevices: 11.38
2015-12-24 17:43:54.409 WebServer (updateDevice from LUA) : idx=150 nvalue=0 svalue=13.63;13.63 invalue=0 signallevel=12 batterylevel=255
2015-12-24 17:43:54.424 WebServer (updateDevice from LUA) : idx=151 nvalue=0 svalue=11.38;13.63 invalue=0 signallevel=12 batterylevel=255
I got this result first result was a error after adjusting your script Jvdz.
I got it working showing above results thanks a lot for the help!

Code: Select all

print(#uri)
local temperature1 = uri['THRMCPL1-57DD1#temperature1'];
local temperature2 = uri['THRMCPL1-57DD1#temperature2'];
print(temperature1)
print(temperature2)
print(temperature,humidity)
domoticz_updateDevice(150,0,temperature1 .. ";" .. temperature1);
domoticz_updateDevice(151,0,temperature2 .. ";" .. temperature2)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest