Open DogParty opened 3 years ago
Hey @DogParty, that's a new one, haven't seen that error before while building this. Just to confirm, I assume you're installing the add-on in via the addon store under the supervisor tab? What is the base OS that you have running on the Intel NUC?
Damn, that's a fast response. Yup, I'm installing through Supervisor and the base OS is the x86-64 Home Assistant OS. Here's a screenshot of the System tab:
Hmm, I'm really not sure what the issue might be... I suspect it might have something to do with the base OS I'm using (debian 64 bit on raspi) versus yours, but it's hard to debug from here without a NUC device to try stuff on.
Can you help me by trying something? You can download this repo and copy the "coned" folder into your "addons" folder on your home assistant server. Edit the Dockerfile in the coned folder to contain the below and then go into your addon store and hit "reload" and you should see the local version pop up. Try installing this and see if it fixes the issue. If so can try and make some changes to the repo to fix it.
FROM node:12-buster
#RUN apt-get update && apt-get install -y chromium jq
RUN apt-get update && apt-get install -y jq
#RUN ln -s /usr/bin/chromium /usr/bin/chromium-browser
RUN mkdir /usr/app
WORKDIR /usr/app
COPY package*.json ./
#ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
RUN npm install
COPY . .
RUN chmod a+x run.sh
CMD ./run.sh
I've removed the lines which have the Dockerfile install a different version of chromium from the debian repos rather than the official version which comes packaged with pupeteer. I had originally switched versions because the official version cannot be built on the arm64 architecture of my raspi, but would probably work on your Intel NUC. Let me know how it goes!
Alright, so after updating the Dockerfile, I ran into this error:
Starting server!
> coned-fetch@1.0.0 start /usr/app
> ts-node src/index.ts
Fetching data from API...
Attempt #1 - Failed to fetch data from API: Error: Failed to launch the browser process!
/usr/app/node_modules/puppeteer/.local-chromium/linux-818858/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
After some digging and adding some dependencies, I was able to get it to run using this dockerfile:
FROM node:12-buster
RUN apt-get update && apt-get install -y jq
RUN apt-get update && \
apt-get install -yq --no-install-recommends \
libx11-6 libx11-xcb1 libxcb1 libatk-bridge2.0-0 libcups2 libasound2 libnss3 libdrm-dev libxkbcommon-x11-0 libgbm-dev libgtk-3-0
#RUN ln -s /usr/bin/chromium /usr/bin/chromium-browser
RUN mkdir /usr/app
WORKDIR /usr/app
COPY package*.json ./
# ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1
RUN npm install
COPY . .
RUN chmod a+x run.sh
CMD ./run.sh
The add-on now runs but I now have the following error:
Starting server!
> coned-fetch@1.0.0 start /usr/app
> ts-node src/index.ts
Fetching data from API...
Attempt #1 - Failed to fetch data from API: Error: Node is either not visible or not an HTMLElement
Any ideas? Sorry, I'm new to Puppeteer
EDIT: After letting the add-on run for a little, I saw this in the logs 😅:
Attempt #1 - Failed to fetch data from API: Error: Node is either not visible or not an HTMLElement
Fetching data from API...
(node:34) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process]. Use emitter.setMaxListeners() to increase limit
Attempt #2 - Failed to fetch data from API: Error: Node is either not visible or not an HTMLElement
Fetching data from API...
(node:34) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(node:34) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. Use emitter.setMaxListeners() to increase limit
(node:34) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGHUP listeners added to [process]. Use emitter.setMaxListeners() to increase limit
Attempt #3 - Failed to fetch data from API: Error: Node is either not visible or not an HTMLElement
Fetching data from API...
Attempt #4 - Failed to fetch data from API: Error: Node is either not visible or not an HTMLElement
Failed to retrieve API data after 5 attempts...
I'm really not sure what's goin on there, you're running into all manner of new problems I've never seen before haha. How about this, have you tried using the addon by bvlaicu: https://github.com/bvlaicu/home-assistant-addons/tree/master/oru
It's very similar (although it does not yet integrate with the new energy tracker from what I am aware), we've been working on similar codebases based on one another's ideas (his is written in python, mine in Node.js). If his works for u, I can maybe use it to understand what's going wrong here.
Heya, sorry, I was away for the last few days. It turns out that ConEd actually reset my password so I reran your add-on and this is what happens:
Starting server!
> coned-fetch@1.0.0 start /usr/app
> ts-node src/index.ts
Fetching data from API...
Attempt #1 - Failed to fetch data from API: TimeoutError: Navigation timeout of 30000 ms exceeded
Fetching data from API...
Attempt #2 - Failed to fetch data from API: TimeoutError: Navigation timeout of 30000 ms exceeded
Fetching data from API...
Attempt #3 - Failed to fetch data from API: TimeoutError: Navigation timeout of 30000 ms exceeded
Fetching data from API...
Attempt #4 - Failed to fetch data from API: TimeoutError: Navigation timeout of 30000 ms exceeded
Failed to retrieve API data after 5 attempts...
Unfortunately, it's not very descriptive. I tried the other add on and it works, though I'm not sure how reliable it is. It seems like it will pull down the data once and then won't pull it again for another 6 hours (if at all). Either way, that seems out of the scope of your project.
Ok, that's promising, now we're up and running with pupeteer at least! I suspect this may have something to do with more login problems, though I cannot be sure. Might be worth rechecking your login?
I've just pushed an updated version of the code which should hopefully give more descriptive errors. Let me know what you get?
I just checked the repo and it looks like your commit hasn't been pushed yet. Ready to check whenever it's available! :)
Oops, fixed @DogParty
This isn't going to work if I'm running the Home Assistant OS directly on a Rpi is it? As opposed to a container. Hmmm... I wonder if I should switch over to running on a container.
I don't use the HASS OS personally, but from what I understand it is running on docker (has supervisor) and can run this add-on (in theory). What we;re trying to figure out is whether the issue is with running the addon on HASS OS host vs running it on Raspi vs Intel NUC. If you can try and install the add-on and let us know how it goes, that'd be very helpful!
Ok cool. Installed it on HassOS on rip4. Not sure how helpful I can be. I'm a noob. Excellent at following directions though.
Starting server!
coned-fetch@1.0.0 start /usr/app ts-node src/index.ts Fetching data from API...
Not sure if it gets any further. The log has remained the same all night. I don't know where to find the output.
Heya, I found your project by desperately searching "coned home-assistnat" so thank you for building it! I tried to run the add-on on my Intel NUC and it fails with the following logs:
Any idea how I could get this to work? I'm assuming it's a dependency issue due to the error logs.
Thank you again!