This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Help to read html code
#1
Hello friends.
I try several times to read active power from my wibeee power meter trough the web page.
I use the example on https://forum.logicmachine.net/showthread.php?tid=712 
and on https://openrb.com/read-plugwise-smile-p...-requests/

But I can not do it, I do not have any ressult.

This is the url I use: http://192.168.1.238/en/phase1.html
And this is a screen capture how html is:
[Image: wibee.png]

Can someone help with the script?
Thanks and greetings.

PD: Sorry about my english  Confused
Reply
#2
Hi,

Try this:
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
BR,

Erwin
Reply
#3
(22.11.2019, 00:06)Erwin van der Zwart Wrote: Hi,

Try this:
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
BR,

Erwin
Hello @Erwin van der Zwart
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:

[Image: log.png]

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.
Reply
#4
Data is probably loaded via JavaScript so initial HTML fields are empty. Check network tab in browser. You might get a URL for JSON data which will make parsing easier.
Reply
#5
(22.11.2019, 08:04)admin Wrote: Data is probably loaded via JavaScript so initial HTML fields are empty. Check network tab in browser. You might get a URL for JSON data which will make parsing easier.

Hello, I completely a noob with html and java.
How can I do it?
Reply
#6
Open dev tools (F12) switch to Network tab and reload the page. Post a screenshot of what requests you get there.
Reply
#7
Hi,

What model do you use? When looking at the internet data i see it supports XML and modbus TCP, so integration by parsing XML or communicate over modbus should be easy and there is no need to fetch the data from the HTML (this is the last option i would use). I would go for Modbus TCP when available.

BR,

Erwin
Reply
#8
(22.11.2019, 09:20)Erwin van der Zwart Wrote: Hi,

What model do you use? When looking at the internet data i see it supports XML and modbus TCP, so integration by parsing XML or communicate over modbus should be easy and there is no need to fetch the data from the HTML (this is the last option i would use). I would go for Modbus TCP when available.

BR,

Erwin

I use this one:

https://wibeee.com/producto/wibeee-box-m...nformation

EDIT
Well, It seems that it does have modbus TCP communication:
[Image: wibeee.jpg]

Any info how catch this data?
Reply
#9
Read manuals or contact support. You need to setup modbus, probably just enable and get the registry info.
------------------------------
Ctrl+F5
Reply
#10
(22.11.2019, 09:57)Daniel. Wrote: Read manuals or contact support.  You need to setup modbus, probably just enable and get the registry info.
 
I'm on it
Reply
#11
I already have the information from support, how to put it in modbus TCP mode and address table:

See:
[Image: modbus.jpg]

The direction I would like to read is 0x000D "Total Active Power"
Now I need how to extract this info.

Can someone help me with that?

And once again, thanks
Reply
#12
Go to modbus tab, add attached profile and then add modbus IP device.  Map object and you are done.
Profile may need adjustment.

Attached Files
.json   Wibee box.json (Size: 220 bytes / Downloads: 9)
------------------------------
Ctrl+F5
Reply
#13
(22.11.2019, 15:15)Daniel. Wrote: Go to modbus tab, add attached profile and then add modbus IP device.  Map object and you are done.
Profile may need adjustment.

Wow, that was fast.
Thanks a lot, later at home I try it.
Reply
#14
Finally I can do it, but not trough modbus, because when I inserted new modbus device, the software ask for the IP and one port. I don't had idea what port wibeee uses for this task.
So, searching info on the manual I founded that wibeee can answer to html request for one item.
With this info, I have used the scrip from @Erwin van der Zwart and modify to request only for the items I wanted.
This is the final script:
Code:
require('socket.http')
socket.http.TIMEOUT = 5
pact = socket.http.request('http://192.168.1.238/services/user/values.xml?var=WIBEEE.pact')
i1 = socket.http.request('http://192.168.1.238/services/user/values.xml?var=WIBEEE.irms1')
en = socket.http.request('http://192.168.1.238/services/user/values.xml?var=WIBEEE.eac1')

-- Check if response value is received
if pact then
      p_activa = pact:match([[<value>(.-)</value>]])
      p_activa = tonumber(string.trim(string.gsub(p_activa, "W", "", 1)))
      grp.write('32/3/1', p_activa)
end
 
if i1 then
    int_f1 = i1:match([[<value>(.-)</value>]])
      int_f1 = tonumber(string.trim(string.gsub(int_f1, "W", "", 1)))
    grp.write('32/3/2', int_f1)
end

if en then
  energia = en:match([[<value>(.-)</value>]])
  energia = tonumber(string.trim(string.gsub(energia, "W", "", 1)))
  grp.write('32/3/3', energia)
end

I launch it every 5 minutes, and works pretty well  Rolleyes

Thanks to all, for the help.
Reply
#15
(25.11.2019, 12:30)peyoe Wrote: Finally I can do it, but not trough modbus, because when I inserted new modbus device, the software ask for the IP and one port. I don't had idea what port wibeee uses for this task...

Modbus over TCP is most likely port 502.
Reply


Forum Jump: