No fix found yet for the error in version 3.
Because older
version 2b is OK for my application with the STECA-read-out, not further investigated.
But version 2b relies on manual counting of positions in the XML-file:

not nice & easy
Obviously quite frustrating that the same script flawlessly operates for XML-files coming from other FP4All-loggers:
must be something very subtle, like a hidden character sneaked in somewhere while copying & adapting.
Have retyped the 'offending' scriptline and the related ones preceeding it, but no progress ....
The script below is operational to get the information from a BMP180 which is part from a remote Raspberry-setup, from which is the below screenshot from the page with current states.

- screenshot_currentstate_bmp180
- screenshot-192.168.1.5 8080-2017-10-25-21-45-53.png (2.71 KiB) Viewed 10512 times
That remote Raspberry uploads the BMP180-information to my website as an XML-file.
This script on another Raspberry then reads that XML-file and provides the 'local' Domoticz with info like from a BMP180-sensor.
The printcommand at line 48 in the log shows what rubbish is coming in.
In this script between lines 55 and 69 you see how to find the start and stop positions for extraction of values from the substrings.
Unfortunately the headers of substrings are sometimes rather long.
Instead of fully automatic or 100% manual, this script is semi-automatic: it's search finds the start of the 'header' and the start of the 'tail' of the substring, and then you have to count the numbers of characters till (and including) the end of the 'header'.
As indicated, the command at line 81 results in a device-content as for a BMP180-sensor, but not complete:
the 4th value from the screenshot is missing.
Can somebody explain that value?
Code: Select all
------------------------------------------------------------------------------------------
-- Version 00 20171025
--
-- Domoticz lua script to convert XML output for BMP180-sensor as uploaded to remote website
-- Reads the status based on the unique web-address and passes values
-- to virtual sensor(s) in Domoticz
-- Complete for Pressure & Temperature
--------------------------------------------------------------------------------------------------
-- Original script by RATA1 at Domoticz-forum, adapted by Toulon7559 (c)2016
--------------------------------------------------------------------------------------------------
-- Line 11: Start of script
commandArray = {}
function XML_Capture(cmd,flatten)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if flatten then
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
end
return s
end
-- Line 26: Set debug to true to print to log file.
debug = true
-- Line 29: Define the idx of your virtual sensor(s) - i.e. what you have called your sensor(s) and the related IDX number(s)
PT_BMP180 = 1138 -- Virtual device for temp + baro
-- Line 33: Define your device IP-address
Device_IP = "vannwnhzn.nl"
-- Device_IP = "192.168.1.x/home/pi" -- for local readout
if debug == true then
print("Reading values from: 'http://"..Device_IP.."/xml130_upload.xml'")
end
-- Line 41: Read the XML data from the device
XML_string=XML_Capture("curl -s 'http://"..Device_IP.."/xml130_upload.xml'",1)
valid = string.find(XML_string, "<root>") -- check we are looking in the right place
if debug == true then
print("XML130-string = "..XML_string)
end
if valid == nil then
print ("Bad XML status read - info NOT updated")
else
-- Line 55: Find in the XML_string the info-fields based on their labels
-- Line 56: read position of pressure string
p0 = string.find(XML_string,"<Barometer ") -- start of 'header'
print(p0)
p2 = string.find(XML_string,"</Barometer>") -- start of 'tail'
print(p2)
-- Line 59: read position of temperature string
t0 = string.find(XML_string,"<Temp ") -- start of 'header'
print(t0)
t2 = string.find(XML_string,"</Temp>") -- start of 'tail'
print(t2)
-- Line 65: Manually determine/set start/stop-positions of the values within the substrings
p1 = p0+24 -- number = characters of header-string <Barometer ... >
print(p1)
t1 = t0+19 -- number = characters of header-string <Temp ... >
print(t1)
-- Line 69: Extract the values and process for upload to Domoticz
-- Line 70: read pressure string
pressure = string.sub(XML_string,p1,p2-1)
pressure1 = tonumber(pressure)
print(pressure1)
-- Line 74: read temperature string
temp = string.sub(XML_string,t1,t2-1)
temp1 = tonumber(temp)
print(temp1)
-- Line 79: Upload to Domoticz
commandArray[1] = {['UpdateDevice'] = PT_BMP180.."|0|"..temp1..";"..pressure1..";1"} -- send updated values to Domoticz
-- for the virtual device set in line 31 the above { layout } as result mimicks a BMP180, except for the 4th value
if debug == true then
print("pressure/temperature = ".."'"..pressure1.."/"..temp1.."'")
end
end
return commandArray

Because this script makes a call to a public website, probably a testrun with the unchanged script will have no errors till line 80:
certainly line 81 will cry for help, because your virtual device will have another IDX than listed in line 31.