jdeath / homeassistant-addons

MIT License
63 stars 15 forks source link

Playwright integration with Changedetection.io not working #15

Open timmeh-git opened 12 months ago

timmeh-git commented 12 months ago

I'm experiencing the following error when attempting to use Playwright in Changedetection.io as described in your instructions.

WebSocket error: getaddrinfo ENOTFOUND db21ed7f-browserless-chrome =========================== logs =========================== ws://db21ed7f-browserless-chrome:3000/?stealth=1&--disable-web-security=true error getaddrinfo ENOTFOUND db21ed7f-browserless-chrome ws://db21ed7f-browserless-chrome:3000/?stealth=1&--disable-web-security=true getaddrinfo ENOTFOUND db21ed7f-browserless-chrome ws://db21ed7f-browserless-chrome:3000/?stealth=1&--disable-web-security=true code=1006 reason= ============================================================

I have verified I can access Playwright separately on port 3000 and confirmed it renders web pages as expected.

From what I can see this looks like it is being caused by an incorrect hostname. In my setup Browserless Chrome has a hostname of 2937404c-browserless-chrome. From what I can see the value db21ed7f-browserless-chrome seems to be hardcoded into the addon as I couldn't find anywhere to try changing it?

Is is possible to change the hostname value somehow or perhaps make it a variable so it can be updated as needed?

My setup: Pi4 4GB Home Assistant 2023.10.1 Supervisor 2023.10.0 Operating System 10.5 Frontend 20231005.0 - latest

navels commented 12 months ago

Oddly I just started seeing this error today and it had been working for me (I think?) for a few days before that.

jdeath commented 11 months ago

Hmm. I don't use this anymore. Alex posted a changedetection addon and his are usually much better than mine https://github.com/alexbelgium/hassio-addons

It probably is possible to make it a variable, just a pain. In the mean time, can also check out the code in this directory, put it in /addons/changedetection/ and change the hardcoded value in the config.json .

timmeh-git commented 11 months ago

Yeah I had already tried Alex's version but it doesn't seem to integrate at all with Playwright unfortunately.

I'll experiment with the config.json for now. Thanks.

navels commented 11 months ago

Yeah I had already tried Alex's version but it doesn't seem to integrate at all with Playwright unfortunately.

It does, but you have to

To use the Playwright fetcher, Changedetection.io addon needs to team up with the Browserless Chrome addon made by alexbelgium.

timmeh-git commented 11 months ago

Are you saying you have managed to get it working using Alex's version of Changedetection and Browserless Chrome?

That wording is from JDeath's page. There's no mention of it on Alex's version. All my testing has been done with his Browseless Chrome installed and if I try running Alex's version of Changedetection with Browserless Chrome installed I get this:

Content fetcher 'html_webdriver' did not respond.
Be sure that the selenium/webdriver runner is running and accessible via network from this container/host.
Did you follow the instructions in the wiki?

WebDriver Host: http://browser-chrome:4444/wd/hub
[Go here for more information](https://github.com/dgtlmoon/changedetection.io/wiki/Fetching-pages-with-WebDriver)
Content fetcher did not respond properly, unable to use it. HTTPConnectionPool(host='browser-chrome', port=4444): Max retries exceeded with url: /wd/hub/session (Caused by NewConnectionError(': Failed to establish a new connection: [Errno -5] Name has no usable address'))

It looks like his version is configured for the default webdriver version (tried changing browserless chrome port to 4444 too but made no difference).

navels commented 11 months ago

Oh dangnabit, you're right . . . sorry for adding to the confusion!

In either case, I have resorted to running changedetection in my own container so I can use a cron task to restart it periodically due to a memory leak in Playwright.

timmeh-git commented 11 months ago

Ah fair enough. Yeah I have it running in a separate docker environment myself on a NAS but it's slow. I was hoping to use the extra power available on my HA setup to improve that. Oh well, back to the drawing board for now :)

Norm2023 commented 7 months ago

Same issue here. The PLAYWRIGHT_DRIVER_URL environment variable is hardcoded in the Changedetection addon. This prevent any connection with browserless chrome addon. Apparently there is no way to change it from the addon. Have you fixed in some way?

jdeath commented 7 months ago

I have not added that capability as I am not sure if it will work (and I dont use it). If you test the capability, and it works, I can make it so the URL is passed in from the Configuration page.

To test: Download the repo code (big green button that says code). Move the entire changedetection folder into \homeassistantant\addons

edit config.json to put whatever PLAYWRIGHT_DRIVER_URL that you want.

Refresh the addonstore, Then you should see it at the top under "Local add-ons"

Install the addon and see if it works.

Norm2023 commented 7 months ago

Now it seems attaching correctly to browserless chrome (thanks for that) but getting a new error "Target page, context or browser has been closed". In Browser Steps and Visual filter selector I actually see the webpage being fetched, do you know why I am getting above error?

jdeath commented 7 months ago

I don't know. I have only used it a little and never with an external url.