krbaker / hass-sunpower

Home Assistant SunPower Integration using the local installer ethernet interface.
Apache License 2.0
49 stars 22 forks source link

Unable to integrate PV Supervisor version 2.2.2, Build 234 #31

Open meanhacker opened 2 years ago

meanhacker commented 2 years ago

Hello, I followed the guide to setup a Raspberry Pi inside of the comm cabinet, however it appears that the PV Supervisor is not compatible with the integration. Below is the setup:

I am able to access the PV Supervisor Management Console, below is a screenshot:

SunPower Console

When I enter http://sunpowerpi/cgi-bin/dl_cgi?Command=DeviceList into the browser, I'm presented with an HTML response:

SunPower Response

=========EDIT=========

I recently came across a command that pulls all the information given a serial number of the device, however the response is still in an HTML format:

http://sunpowerpi/cgi-bin/dl_cgi?Command=DeviceDetails&SerialNumber=146xxx

image

When I inspect the page and indent the response for readability, this is what I see:

<div class='accordionItem'>
<h2 id='146xxx' type='WATTNODE'><img/>
    <span class='working'>Power Meter 146xxx</span><img/>
    <span class='working'>Working</span>
    <span class='info'>P0:Modbus Slave ID: 11</span>
    <span class='link'></span>
</h2>
<div>
<table>
    <tr><td class='working'><b>Last&nbsp;Data:</b>&nbsp;
        <span class='DateClass'>2022,07,20,17,27,24</span></td>
    <td class='info'><b>CT&nbsp;Scale&nbsp;Factor:</b>&nbsp;
        100&nbsp;&nbsp;</td></tr>
    <tr><td class='info'><b>Last&nbsp;Refresh:</b>&nbsp;
        <span class='DateClass'>2022,07,20,17,27,38</span></td>
    <td class='info'><b>Total&nbsp;Lifetime&nbsp;Energy:</b>&nbsp;
        69006.2343&nbsp;&nbsp;kWh</td></tr>
    <tr><td class='info'><b>Model:</b>&nbsp;
        WNC-3Y-208-MB</td>
    <td class='info'><b>Avg&nbsp;Real&nbsp;Power:</b>&nbsp;
        -0.4899&nbsp;&nbsp;kW</td></tr>
    <tr><td class='info'><b>Serial&nbsp;Number:</b>&nbsp;
        146xxx</td>
    <td class='info'><b>Avg&nbsp;Reactive&nbsp;Power:</b>&nbsp;
        -0.2289&nbsp;&nbsp;kVAR</td></tr>
    <tr><td class='info'><b>Software&nbsp;Version:</b>&nbsp;
        19</td>
    <td class='info'><b>Avg&nbsp;Apparent&nbsp;Power:</b>&nbsp;
        0.5408&nbsp;&nbsp;kVA</td></tr>
    <tr><td/>
    <td class='info'><b>Avg&nbsp;Power&nbsp;Factor:</b>&nbsp;
        -0.9059&nbsp;&nbsp;</td></tr>
    <tr><td/>
    <td class='info'><b>Avg&nbsp;AC&nbsp;Frequency:</b>&nbsp;
        60.0627&nbsp;&nbsp;Hz</td></tr>
    <tr><td class='MadCow' a='100' b='3'        ></td></tr>
</table>
</div></div>

In HomeAssistant, when try to initialize the integration, it doesn't work. I tried providing the hostname and IP address:

HomeAssistant Cannot Connect

  1. Would it be possible to update the plugin to support this type of response from SunPower Supervisor?
  2. Has anyone else come across this version of SunPower Supervisor? It appears it was installed all the way back in 2014.
  3. While browsing the Documentation files, I came across a lot of interesting and potentially useful reference documents:

SunPower Documentation

Here is an example of what the setup looks like on my end, except I don't have the Ethernet adapters: https://us.sunpower.com/how-troubleshoot-icd-sunpower-monitoring-system-sms-2x-pv-supervisor

jcronq commented 1 year ago

I've been poking around the same version of the pv supervisor. Just appears to be this older version of the cgi_bin script is returning the data pre-embedded in http. I think all the data is there to be able to integrate with this component.

Will take a shot at it and report back, or create a PR.

jcronq commented 1 year ago

@meanhacker I think I've got this working. I am running tests for a few days to see how it behaves before raising a PR.

I see you have a Power Meter, which I don't have. It would be helpful if you could test the beta-feature (support for v2.2.2/3) as well. It's available at this fork: https://github.com/jcronq/hass-sunpower.

meanhacker commented 1 year ago

Hello, I tried setting up the integration. After typing in the IP address, the initialization would never complete. After a long time, I would see the integration in my devices, but no sensors... In the logs, this is what I see:

2022-09-18 09:49:41.779 ERROR (MainThread) [custom_components.sunpower] Failed to update data 2022-09-18 09:49:41.826 ERROR (MainThread) [custom_components.sunpower.sensor] Cannot find PVS Entry 2022-09-18 09:49:41.830 ERROR (MainThread) [custom_components.sunpower.binary_sensor] Cannot find PVS Entry 2022-09-18 09:49:41.835 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up sunpower platform for binary_sensor

On Sat, Sep 17, 2022 at 6:58 PM Vitaliy Daniliuk @.***> wrote:

Hi Jason, thank you for looking at my issue report! I will try to do some testing with that fork and report my findings. Thanks!

On Sat, Sep 17, 2022, 5:30 PM Jason Cronquist @.***> wrote:

@meanhacker https://github.com/meanhacker I think I've got this working. I am running tests for a few days to see how it behaves before raising a PR.

I see you have a Power Meter, which I don't have. It would be helpful if you could test the beta-feature (support for v2.2.2/3) as well. It's available at this fork: https://github.com/jcronq/hass-sunpower.

— Reply to this email directly, view it on GitHub https://github.com/krbaker/hass-sunpower/issues/31#issuecomment-1250162653, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOETEJAEUFHPABSXQHXFHA3V6ZPDBANCNFSM5SM5TSUQ . You are receiving this because you were mentioned.Message ID: @.***>

meanhacker commented 1 year ago

I believe I left out some logs. Here is a better capture:

2022-09-18 12:08:40.372 ERROR (MainThread) [custom_components.sunpower] Failed to update data 2022-09-18 12:08:40.387 ERROR (MainThread) [custom_components.sunpower.sensor] Cannot find PVS Entry 2022-09-18 12:08:40.391 ERROR (MainThread) [custom_components.sunpower.binary_sensor] Cannot find PVS Entry 2022-09-18 12:08:40.396 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up sunpower platform for binary_sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/sunpower/binary_sensor.py", line 55, in async_setup_entry async_add_entities(entities, True) UnboundLocalError: local variable 'entities' referenced before assignment

On Sun, Sep 18, 2022 at 11:10 AM Vitaliy Daniliuk @.***> wrote:

Hello, I tried setting up the integration. After typing in the IP address, the initialization would never complete. After a long time, I would see the integration in my devices, but no sensors... In the logs, this is what I see:

2022-09-18 09:49:41.779 ERROR (MainThread) [custom_components.sunpower] Failed to update data 2022-09-18 09:49:41.826 ERROR (MainThread) [custom_components.sunpower.sensor] Cannot find PVS Entry 2022-09-18 09:49:41.830 ERROR (MainThread) [custom_components.sunpower.binary_sensor] Cannot find PVS Entry 2022-09-18 09:49:41.835 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up sunpower platform for binary_sensor

On Sat, Sep 17, 2022 at 6:58 PM Vitaliy Daniliuk @.***> wrote:

Hi Jason, thank you for looking at my issue report! I will try to do some testing with that fork and report my findings. Thanks!

On Sat, Sep 17, 2022, 5:30 PM Jason Cronquist @.***> wrote:

@meanhacker https://github.com/meanhacker I think I've got this working. I am running tests for a few days to see how it behaves before raising a PR.

I see you have a Power Meter, which I don't have. It would be helpful if you could test the beta-feature (support for v2.2.2/3) as well. It's available at this fork: https://github.com/jcronq/hass-sunpower.

— Reply to this email directly, view it on GitHub https://github.com/krbaker/hass-sunpower/issues/31#issuecomment-1250162653, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOETEJAEUFHPABSXQHXFHA3V6ZPDBANCNFSM5SM5TSUQ . You are receiving this because you were mentioned.Message ID: @.***>

jcronq commented 1 year ago

Can you inspect & attach the raw http that's returned for DeviceList command?

http://sunpowerpi/cgi-bin/dl_cgi?Command=DeviceList

meanhacker commented 1 year ago

Here is the requested HTML file. I only redacted the serial numbers because it's the internet :) http __sunpowerpi_cgi-bin_dl_cgi Command=DeviceList.txt

jcronq commented 1 year ago

I've pushed an update to the same fork that should handle your device list (there was a &nbsp; tag in your PVS device name that I didn't have).

If this doesn't work. Please send along the error message from the logs along with the raw http result from calling DeviceDetails on each of your devices.

meanhacker commented 1 year ago

Hello Jason, after I updated the integration, home assistant would not let me delete and re-add the integration. I had to disable it first, delete the folder in custom_components, restart home assistant, and re-download it. After that, it is still no longer prompting for the IP address. Below are the HTML responses for each device:

PV Supervisor.txt Power Meter.txt Inverter.txt

"This integration does not support configuration via the UI. If you followed this link from the Home Assistant website, make sure you run the latest version of Home Assistant."

2022-09-19 08:22:16.778 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration sunpower: No module named 'custom_components.sunpower.const_noha' 2022-09-19 09:16:49.296 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration sunpower: No module named 'custom_components.sunpower.const_noha'

On Mon, Sep 19, 2022, 5:40 AM Jason Cronquist @.***> wrote:

I've pushed an update to the same fork that should handle your device list (there was a line break in your PVS device name that I didn't have).

If this doesn't work. Please send along the error message from the logs along with the raw http result from calling DeviceDetails on each of your devices.

— Reply to this email directly, view it on GitHub https://github.com/krbaker/hass-sunpower/issues/31#issuecomment-1250967109, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOETEJABEYNOU63T53BJ243V7BNMNANCNFSM5SM5TSUQ . You are receiving this because you were mentioned.Message ID: @.***>

jcronq commented 1 year ago

That's my bad. Accidentally committed code I was using for testing the data you sent me. Ok to try again now.

meanhacker commented 1 year ago

Ok, I think we are getting a bit closer now, but I'm still not seeing the sensors. Attached latest logs: sunpower-logs.txt

jcronq commented 1 year ago

Ready for another test.

meanhacker commented 1 year ago

Hello, currently the sun is down is and the inverter is offline (showing an Error status), so I'm not sure if that's contributing to the errors: sunpower-logs.txt

Here is what the response looks like with the inverter being offline: device-list.txt inverter.txt

jcronq commented 1 year ago

Ready for another test. Wasn't related to inverter being offline, I missed a point in the parsing where I was handling &nbsp; tags incorrectly, which caused the argument-name conversion (to the v5/6 naming convention) to fail.

I ran the data you sent through it. It should work now... Famous last words.

meanhacker commented 1 year ago

I'm finally seeing the sensors! However some things are missing like Inverter Avg AC Power/Voltage/Current, Avg DC Current. sunpower-logs.txt

jcronq commented 1 year ago

This is expected behavior. Only values that are used in the hass-sunpower component are being mapped. Additional values that appear in version 2.x.x but not used in the component are not mapped. Primarily, I don't know what the key-name would be in version 5/6.x.x, as I am on version 2.2.3 myself.

Only concern I have with your logs is that your Inverter isn't publishing Avg DC Power (maps to p_3phsum_kw). I don't think this will impact you negatively though. The Power dashboard in Home Assistant wants Total Lifetime Energy (maps to ltea_3phsum_kwh) which you do have.

Your Power Meter does seem to be publishing an Avg DC Power which can be used in place of the inverter's missing value if you ever desire it.

TLDR; Your logs look good. :)

meanhacker commented 1 year ago

Hello Jason, thank you for taking a look at the logs. The dashboard seems to be working correctly, however it took me some time to understand that everything is in kWh. I would like to monitor my solar production from home usage separately, would it be possible to create a sensor for the inverter power usage (in kW)? Ideally, it would be interesting to monitor the solar performance and home energy usage over time, but it looks like the power meter is capturing both solar and home usage which means solar would need to be subtracted from the watt meter to get a true home usage reading. Thank you so much for getting this to work, below is what my dashboard looks like! image

meanhacker commented 1 year ago

Hello Jason, thank you for taking a look at the logs. The dashboard seems to be working correctly, however it took me some time to understand that everything is in kWh. I would like to monitor my solar production from home usage separately, would it be possible to create a sensor for the inverter power usage (in kW)? Ideally, it would be interesting to monitor the solar performance and home energy usage over time, but it looks like the power meter is capturing both solar and home usage which means solar would need to be subtracted from the watt meter to get a true home usage reading. Thank you so much for getting this to work, below is what my dashboard looks like!

On Tue, Sep 20, 2022 at 9:00 AM Jason Cronquist @.***> wrote:

This is expected behavior. Only values that are used in the hass-sunpower component are being mapped. Additional values that appear in version 2.x.x but not used in the component are not mapped. Primarily, I don't know what the key-name would be in version 5/6.x.x, as I am on version 2.2.3 myself.

Only concern I have with your logs is that your Inverter isn't publishing Avg DC Power (maps to p_3phsum_kw). I don't think this will impact you negatively though. The Power dashboard in Home Assistant wants Total Lifetime Energy (maps to ltea_3phsum_kwh) which you do have.

Your Power Meter does seem to be publishing an Avg DC Power which can be used in place of the inverter's missing value if you ever desire it.

TLDR; Your logs look good. :)

— Reply to this email directly, view it on GitHub https://github.com/krbaker/hass-sunpower/issues/31#issuecomment-1252569086, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOETEJHROMK5GZUNQNLXBW3V7HNTDANCNFSM5SM5TSUQ . You are receiving this because you were mentioned.Message ID: @.***>

meanhacker commented 1 year ago

Hi Jason, thank you for looking at my issue report! I will try to do some testing with that fork and report my findings. Thanks!

On Sat, Sep 17, 2022, 5:30 PM Jason Cronquist @.***> wrote:

@meanhacker https://github.com/meanhacker I think I've got this working. I am running tests for a few days to see how it behaves before raising a PR.

I see you have a Power Meter, which I don't have. It would be helpful if you could test the beta-feature (support for v2.2.2/3) as well. It's available at this fork: https://github.com/jcronq/hass-sunpower.

— Reply to this email directly, view it on GitHub https://github.com/krbaker/hass-sunpower/issues/31#issuecomment-1250162653, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOETEJAEUFHPABSXQHXFHA3V6ZPDBANCNFSM5SM5TSUQ . You are receiving this because you were mentioned.Message ID: @.***>

krbaker commented 1 year ago

My gut feeling is this should probably be a different integration. They are both hacky in their own way (missing fields and such is enough of a problem with the pvs5/pvs6). Thoughts?

jcronq commented 1 year ago

I probably came to the same conclusion given I never raised a PR. Hacky by definition too, lol.

I also don’t have a ton of interest in testing a PR. It’s been working for me for 7 months without issue, so don’t want to rock the boat.

I’d be surprised if there’s anyone else out there with this old hardware, and a desire to connect to home assistant. So not a ton of value in investing additional effort. I personally planned on leaving this issue open indefinitely in case anyone else was desperate enough to find it.

meanhacker commented 1 year ago

I have also been satisfied with the performance of jcronq's fork and it has been working well for the past 7 months. I don't mind keeping this issue open if it helps others find this code/thread.

krbaker commented 1 month ago

Looking at the fork I think its less intrusive than I was expecting (I like the ~adapter). I'm also abstracting some of the code for ESS / PVS work so I may take another look at integrating this.