geustace / home-assistant-enasolar

Custom Integration to support EnaSolar Inverters
GNU General Public License v3.0
5 stars 1 forks source link

error setting up integration #5

Closed bashers222 closed 2 months ago

bashers222 commented 2 months ago

Hi, as per the first issue logged (https://github.com/geustace/home-assistant-enasolar/issues/1) , i seem to have another version that is not supported by this HACS integration and I'd love to get this integrated

I'm seeing the folloiwing in the debug logs: 2024-06-25 20:38:03.137 ERROR (MainThread) [custom_components.enasolar.config_flow] Unexpected exception Traceback (most recent call last): File "/config/custom_components/enasolar/config_flow.py", line 70, in _try_connect await self._enasolar.interogate_inverter(host) File "/usr/local/lib/python3.12/site-packages/pyenasolar/__init__.py", line 301, in interogate_inverter self.capability = int(cap[0])

As suggested, ive added the settings file to see if that helps enasolar.txt

geustace commented 2 months ago

I now get why web scrapping is not allowed in the core integrations. Unfortunately there is no API for these inverters so there isnt an alternative. I'll have a look at this and get back to you. BTW: Thanks for including the Settings page it should help.

bashers222 commented 2 months ago

Thanks for your assistance

geustace commented 2 months ago

Can you please upload the wv.txt we page from the inverter. http://inverter/wv.txt, actually just confirm that is it 21

geustace commented 2 months ago

Digging around in the code, I need some of the text in the index.html page. Can you browse to it, show source then copy and paste just the <head>...</head> section as it has the jscript in it that I need to parse. Thanks

bashers222 commented 2 months ago

yep, its 21 enasolar-index.txt

geustace commented 2 months ago

Hmm, the code has all been html-ified and is pretty much unreadable. The line from the HEAD section I need is the line that starts with var tiv= I just browse to the page then Right click and show source. I am using Firefox but other browsers ought to do the same. image Can you try to get all of this line for me. If it doesnt exist my plan B is to just not error out and let you override the values I cant extract.

bashers222 commented 2 months ago

Try this:

var tiv="Enasolar-Garden";if(tiv!=""){document.title=tiv}; var globalWdtI;var gMt;function iready(){var a="3";var c="

";c+="";c+="";c+="";c+="";if(has2mpp(a)){c+="";c+="";c+="";c+=""}else{c+="";c+=""}c+="";c+="";c+="
Utilisation:
Output Power:
Input Voltage 1:
Input Voltage 2:
Input Voltage:
Output Voltage:
";$("#pgauge_yield").html(c);function b(){function d(f){UpdateMeters(f,a);if(gMt!=null){clearTimeout(gMt)}gMt=setTimeout(b,10000);if(globalWdtI!=null){clearTimeout(globalWdtI)}}function e(){UpdateMeters(false,a);if(gMt!=null){clearTimeout(gMt)}gMt=setTimeout(b,10000);if(globalWdtI!=null){clearTimeout(globalWdtI)}}globalWdtI=setTimeout(e,60000);$.ajaxQueue({url:"meters.xml",method:"GET",dataType:"xml",success:d,error:e,timeout:30000})}b();hready();banner_draw()}var iloadstate=0;var jsloadtimer=0;function iload(){var a;try{if(!iloadstate){a=$}else{a=has2mpp}}catch(c){}if(a!=undefined){iloadstate++;jsloadtimer=0;if(iloadstate>1){iready();return}}if(jsloadtimer==0){jsloadtimer=201;var b=document.createElement("script");b.type="text/javascript";if(!iloadstate){b.src="jquery.min.js"}else{b.src="js.js"}document.getElementById("head").appendChild(b)}jsloadtimer--;setTimeout(iload,100)}var globalWdtH;var gDt;function hready(){function a(){function c(d){UpdateEnergyProduction(d);if(gDt!=null){clearTimeout(gDt)}gDt=setTimeout(a,30000);if(globalWdtH!=null){clearTimeout(globalWdtH)}}function b(){if(gDt!=null){clearTimeout(gDt)}gDt=setTimeout(a,30000);if(globalWdtH!=null){clearTimeout(globalWdtH)}}globalWdtH=setTimeout(b,60000);$.ajaxQueue({url:"data.xml",method:"GET",dataType:"xml",success:c,error:b,timeout:30000})}a();fplot("#D","D",0);fplot("#W","W",1)};

geustace commented 2 months ago

The needed data would appear not to be available in version 21, so I have assigned some defaults which you can override. I have uploaded a new version of pyenasolar and the enasolar intergration. HACS should show that it can be updated.