22.11.2019, 08:01
(22.11.2019, 00:06)Erwin van der Zwart Wrote: Hi,Hello @Erwin van der Zwart
Try this:
BR,Code:require('socket.http')
socket.http.TIMEOUT = 5
data = socket.http.request('http://192.168.1.238/en/phase1.html')
-- Check if response value is received
if data then
-- Fetch values from HTTP response
p_activa = data:match([[<td id="p_activa">(.-)</td>]])
-- Remove units and trims leading and trailing spaces and decode to numberic
p_activa = tonumber(string.trim(string.gsub(p_activa, "W", "", 1)))
-- Write to KMX
grp.write('1/1/1', p_activa)
end
Erwin
Thanks for the script!!
I change the script in order to put the user and password and to change the output object (virtual byte floating point) see it:
Code:
require('socket.http')
socket.http.TIMEOUT = 5
data = socket.http.request('http://user:user@192.168.1.238/en/phase1.html')
log(data)
-- Check if response value is received
if data then
-- Fetch values from HTTP response
p_activa = data:match([[<td id="p_activa">(.-)</td>]])
log(p_activa)
-- Remove units and trims leading and trailing spaces and decode to numberic
p_activa = tonumber(string.trim(string.gsub(p_activa, "W", "", 1)))
log(p_activa)
-- Write to KMX
grp.write('32/3/1', p_activa)
end
But this doesn't work, looking to the log this is the output:
And this is the searched data read from the wibeee webpage, storeged on "data"
Code:
<tr>
<td>Active Power</td>
<td id="p_activa"></td>
</tr>
Any idea?
Thanks again.