Author Topic: Plugin: Solar Meter, universal Solar Production meter  (Read 4321 times)

Offline RHCPNG

  • Full Member
  • ***
  • Posts: 161
  • Karma: +5/-0
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #15 on: April 17, 2018, 07:01:57 am »
Hi RHCPNG,

That response looks as expected yes. In the attached version I added some more details on possible errors. Can you try that?

Cheers Rene

This is the log I get now:

Code: [Select]
2018-04-17 12:43:04.169   openLuup.server:: request completed (16671 bytes, 2 chunks, 10084 ms) tcp{client}: 0x30a6ec8
2018-04-17 12:43:04.170   openLuup.server:: socket closed: closed tcp{client}: 0x30a6ec8
2018-04-17 12:43:04.291   openLuup.server:: new client connection from 192.168.1.100: tcp{client}: 0x2c82798
2018-04-17 12:43:04.291   openLuup.server:: GET /data_request?id=lu_status2&output_format=json&DataVersion=961772878&Timeout=60&MinimumDelay=1500&_=1523961750538 HTTP/1.1 tcp{client}: 0x2c82798
2018-04-17 12:43:10.345   luup.variable_set:: 47.urn:rboer-com:serviceId:SolarMeter1.AppMemoryUsed was: 18379 now: 22648 #hooks:0
2018-04-17 12:43:10.345   luup_log:47: Solar Meter_debug: Is Day use Day delay Interval SolarMeter_Retrieve --> 30
2018-04-17 12:43:10.345   luup_log:47: Solar Meter_debug: PV Output URL https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=<id>
2018-04-17 12:43:10.632   openLuup.server:: WGET status: closed, request: https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=<id>
2018-04-17 12:43:10.633   luup_log:47: Solar Meter: Refresh failed HTTP Get to https://pvoutput.org/service/r2/getstatus.jsp?key=lkj
2018-04-17 12:43:10.633   luup.variable_set:: 47.urn:rboer-com:serviceId:SolarMeter1.HttpCode was: EMPTY now: closed #hooks:0
2018-04-17 12:43:10.633   luup_log:47: Solar Meter_debug: HTTP Get to https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=<id> failed.
2018-04-17 12:43:11.138   openLuup.server:: request completed (8468 bytes, 1 chunks, 6846 ms) tcp{client}: 0x2c82798
2018-04-17 12:43:11.139   openLuup.server:: socket closed: closed tcp{client}: 0x2c82798
2018-04-17 12:43:11.173   openLuup.server:: new client connection from 192.168.1.100: tcp{client}: 0x34e1c48
2018-04-17 12:43:11.174   openLuup.server:: GET /data_request?id=user_data&output_format=json&DataVersion=961763991&_=1523961750539 HTTP/1.1 tcp{client}: 0x34e1c48
2018-04-17 12:43:11.300   openLuup.server:: request completed (962218 bytes, 61 chunks, 126 ms) tcp{client}: 0x34e1c48
2018-04-17 12:43:11.302   openLuup.server:: socket closed: closed tcp{client}: 0x34e1c48
2018-04-17 12:43:13.376   openLuup.server:: new client connection from 192.168.1.100: tcp{client}: 0x3675358

There is nothing in it that's useful, I think.

What I noticed is that the data fields that are retrieved from the api, do not correspond to the values visible in AlTUI.

So for example, there is no field in the getstatus operation for the "This week kwh" field in the GUI. If you know what I mean. But maybe this is as expected.

Offline givapva

  • Newbie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #16 on: April 17, 2018, 11:36:33 am »
how can I create a new device and add the other inverter values?
Creating a new device with the total values

Offline RHCPNG

  • Full Member
  • ***
  • Posts: 161
  • Karma: +5/-0
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #17 on: April 18, 2018, 03:22:36 am »
how can I create a new device and add the other inverter values?
Creating a new device with the total values

I don't use the plugin in the Vera UI, but can't you create a new device at Apps > My Apps > Details of Solar plugin?

Offline RHCPNG

  • Full Member
  • ***
  • Posts: 161
  • Karma: +5/-0
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #18 on: April 18, 2018, 03:24:36 am »
Hi Rene,

The value in the variable retCode and HttpCode are incorrect. The value is "Closed" and that is not what to expect. I'm not to good with lua so my debugging stops here.

And like I said, the values retrieved by the api do not correspond to the values in the gui.

Fields webservice:
Date   
Time
Energy Generation
Power Generation
Energy Consumption
Power Consumption
Normalised Output
Temperature
Voltage

Fields GUI:
Power
Today
This Week
This Month
This Year
Lifetime Energy
Last Update
« Last Edit: April 18, 2018, 03:32:24 am by RHCPNG »

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1325
  • Karma: +73/-30
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #19 on: April 18, 2018, 05:30:31 am »
Hi Rene,

The value in the variable retCode and HttpCode are incorrect. The value is "Closed" and that is not what to expect. I'm not to good with lua so my debugging stops here.

And like I said, the values retrieved by the api do not correspond to the values in the gui.
Can you post a snippet of the log file again with the 1.4 version as you did before. It may give the reason why the http get command returns Closed. Typically that comes with an incorrect query or authentication problem.

The values are indeed different. The plugin is indented to be a generic one to get the current wattage and Daily KWh value as that gets reported by all system I have seen so far. The Weekly, Monthly, Yearly and Total KWh values are used when available. Other values are not as they vary from system to system.

Cheers Rene
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1325
  • Karma: +73/-30
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #20 on: April 18, 2018, 05:32:03 am »
how can I create a new device and add the other inverter values?
Creating a new device with the total values
Hi,

What values are you looking for? When not directly reported by the system you can better use DataMine2 to log what gets returned and make stats using that.

Cheers Rene
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline RHCPNG

  • Full Member
  • ***
  • Posts: 161
  • Karma: +5/-0
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #21 on: April 18, 2018, 06:28:26 am »
Hi Rene,

The value in the variable retCode and HttpCode are incorrect. The value is "Closed" and that is not what to expect. I'm not to good with lua so my debugging stops here.

And like I said, the values retrieved by the api do not correspond to the values in the gui.
Can you post a snippet of the log file again with the 1.4 version as you did before. It may give the reason why the http get command returns Closed. Typically that comes with an incorrect query or authentication problem.

The values are indeed different. The plugin is indented to be a generic one to get the current wattage and Daily KWh value as that gets reported by all system I have seen so far. The Weekly, Monthly, Yearly and Total KWh values are used when available. Other values are not as they vary from system to system.

Cheers Rene

Ok, these values are fine for me. So that also works as expected.

There is no additional information in v1.4. I have added the two variables in the debug code.

Code: [Select]
2018-04-18 12:23:25.190   luup.variable_set:: 47.urn:rboer-com:serviceId:SolarMeter1.AppMemoryUsed was: 13317 now: 9440 #hooks:0
2018-04-18 12:23:25.191   luup_log:47: Solar Meter_debug: Is Day use Day delay Interval SolarMeter_Retrieve --> 30
2018-04-18 12:23:25.191   luup_log:47: Solar Meter_debug: PV Output URL https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416
2018-04-18 12:23:25.466   openLuup.server:: WGET status: closed, request: https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416
2018-04-18 12:23:25.466   luup_log:47: Solar Meter_debug: retCode is closed
2018-04-18 12:23:25.466   luup_log:47: Solar Meter_debug: Http Code is closed
2018-04-18 12:23:25.466   luup_log:47: Solar Meter: Refresh failed HTTP Get to https://pvoutput.org/service/r2/getstatus.jsp?key=lkj
2018-04-18 12:23:25.466   luup_log:47: Solar Meter_debug: HTTP Get to https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416 failed.
2018-04-18 12:23:25.972   openLuup.server:: request completed (8535 bytes, 1 chunks, 6327 ms) tcp{client}: 0x20ff388
2018-04-18 12:23:25.973   openLuup.server:: socket closed: closed tcp{client}: 0x20ff388
2018-04-18 12:23:26.117   openLuup.server:: new client connection from 192.168.1.100: tcp{client}: 0x2c35628
2018-04-18 12:23:26.117   openLuup.server:: GET /data_request?id=lu_status2&output_format=json&DataVersion=35538553&Timeout=60&MinimumDelay=1500&_=1524046988513 HTTP/1.1 tcp{client}: 0x2c35628
2018-04-18 12:23:28.532   openLuup.server:: new client connection from 192.168.1.100: tcp{client}: 0x2c376d8
2018-04-18 12:23:28.533   openLuup.server:: GET /data_request?id=lr_ALTUI_Handler&command=oscommand&oscommand=tail%20-n%20500%20%2Fhome%2Ftest%2Fvera%2Fcmh-ludl%2Flogs%2FLuaUPnP.log&_=1524046988514 HTTP/1.1 tcp{client}: 0x2c376d8
2018-04-18 12:23:28.533   luup_log:3: ALTUI: debug: myALTUI_Handler: request is: ALTUI_Handler


Offline reneboer

  • Hero Member
  • *****
  • Posts: 1325
  • Karma: +73/-30
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #22 on: April 19, 2018, 08:24:16 am »
Hi RHCPNG,

I truly do not understand why it returns closed. Maybe it is a timeout issue? In the ATLUI Lua test window can you try:
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416"))

and
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416"),20)

to see if there is a difference?

Cheers Rene
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline RHCPNG

  • Full Member
  • ***
  • Posts: 161
  • Karma: +5/-0
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #23 on: April 20, 2018, 04:57:35 am »
Hi RHCPNG,

I truly do not understand why it returns closed. Maybe it is a timeout issue? In the ATLUI Lua test window can you try:
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416"))

and
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416"),20)

to see if there is a difference?

Cheers Rene

The first URL gives me:
Return result: Nil
Console output: Closed     Closed

The second URL:
Return result: Nil
Console output: Closed     20

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1325
  • Karma: +73/-30
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #24 on: April 23, 2018, 07:10:07 am »
Hi RHCPNG,

I truly do not understand why it returns closed. Maybe it is a timeout issue? In the ATLUI Lua test window can you try:
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416"))

and
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416"),20)

to see if there is a difference?

Cheers Rene

The first URL gives me:
Return result: Nil
Console output: Closed     Closed

The second URL:
Return result: Nil
Console output: Closed     20

I am truly at a loss here. What system do you use for openLuup? I have a PI running the latest Jessy and I must say I have LUA Sec version 0.7 for some other application. Standard Pi has LUA Sec 0.4 or 0.5 I think.

Maybe you can try to use http instead of https?

Cheers Rene
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline jswim788

  • Hero Member
  • *****
  • Posts: 751
  • Karma: +49/-2
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #25 on: April 23, 2018, 02:39:13 pm »
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416"),20)
Is that comma where you want it to test for the timeout?  Don't you want to test this?
Code: [Select]
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416",20))

Offline RHCPNG

  • Full Member
  • ***
  • Posts: 161
  • Karma: +5/-0
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #26 on: April 24, 2018, 06:18:42 am »
Hi RHCPNG,

I truly do not understand why it returns closed. Maybe it is a timeout issue? In the ATLUI Lua test window can you try:
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416"))

and
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416"),20)

to see if there is a difference?

Cheers Rene

The first URL gives me:
Return result: Nil
Console output: Closed     Closed

The second URL:
Return result: Nil
Console output: Closed     20

I am truly at a loss here. What system do you use for openLuup? I have a PI running the latest Jessy and I must say I have LUA Sec version 0.7 for some other application. Standard Pi has LUA Sec 0.4 or 0.5 I think.

Maybe you can try to use http instead of https?

Cheers Rene

I don't run it on Pi, but have the Vbox VM running.

I've run the HTTP URL instead of HTTPS and then the result looks promising:

Return result: Nil
Console output: 0    20180424,12:10,3100,1073,NaN,NaN,0.289,40.2,397.1    200

Is this what you expect? Any idea why the HTTPS wouldn't work? I haven't got a clue.

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1325
  • Karma: +73/-30
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #27 on: April 24, 2018, 06:19:28 am »
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416"),20)
Is that comma where you want it to test for the timeout?  Don't you want to test this?
Code: [Select]
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416",20))
Oops, you are completely right.  :-[
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline RHCPNG

  • Full Member
  • ***
  • Posts: 161
  • Karma: +5/-0
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #28 on: April 24, 2018, 06:25:11 am »
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416"),20)
Is that comma where you want it to test for the timeout?  Don't you want to test this?
Code: [Select]
print(luup.inet.wget("https://pvoutput.org/service/r2/getstatus.jsp?key=<key>&sid=58416",20))
Oops, you are completely right.  :-[

This doesn't make difference, the HTTP in stead of HTTPS does!

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1325
  • Karma: +73/-30
Re: Plugin: Solar Meter, universal Solar Production meter
« Reply #29 on: April 25, 2018, 06:37:54 am »
Hi RHCPNG,

No idea why your LUA implementation does not support https. Are you running any other plugins using https?

I made a patch to the version below that uses http for PV out by default. That should then work in your case.

Cheers Rene
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.