gustonator / goodwe-prometheus-exporter

Exporter for prometheus to export metrics from GoodWe Inverters
2 stars 2 forks source link

how to access the container image? #5

Open imp1sh opened 1 month ago

imp1sh commented 1 month ago

Hi,

do you offer a ready to use container image? What is the url to pull it?

Thanks

imp1sh commented 1 month ago

Well I've wasted quite some time now to get this running. I've build the image myself and deployed it to my container host. It just won't work. Weirdly it always tries to resolve the inverter IP value, even it's an IP address already. When using a hostname it will always result in NXDOMAIN, even the record is valid. Getting a python crash in the container like this:

File "exporter.py", line 235, in main
    inverter_metrics.run_metrics_loop()
  File "exporter.py", line 158, in run_metrics_loop
    self.collector_register()
  File "exporter.py", line 154, in collector_register
    asyncio.run(create_collector_registers())
  File "/usr/local/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "exporter.py", line 138, in create_collector_registers
    inverter = await goodwe.connect(INVERTER_IP)
  File "/usr/local/lib/python3.8/site-packages/goodwe/__init__.py", line 48, in connect
    return await discover(host, port, timeout, retries)
  File "/usr/local/lib/python3.8/site-packages/goodwe/__init__.py", line 69, in discover
    response = await DISCOVERY_COMMAND.execute(UdpInverterProtocol(host, port, timeout, retries))
  File "/usr/local/lib/python3.8/site-packages/goodwe/protocol.py", line 456, in execute
    response_future = await protocol.send_request(self)
  File "/usr/local/lib/python3.8/site-packages/goodwe/protocol.py", line 182, in send_request
    await self._connect()
  File "/usr/local/lib/python3.8/site-packages/goodwe/protocol.py", line 124, in _connect
    self._transport, self.protocol = await asyncio.get_running_loop().create_datagram_endpoint(
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1265, in create_datagram_endpoint
    infos = await self._ensure_resolved(
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 1365, in _ensure_resolved
    return await loop.getaddrinfo(host, port, family=family, type=type,
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 825, in getaddrinfo
    return await self.run_in_executor(
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve
gustonator commented 1 week ago

Hi, first, sorry for the delay. I haven't seen your question.

this is probably something on your side. I don't have a ready build image, but you can easily build it yourself with: docker build -t <image name>:<version> . I've already updated the documentation with this information

about the error... you need to use the IP Address, not hostname. be also sure, that the host with docker is on the same network as the inverter. if you scrape from someone else, or via an external IP address, be sure to have opened the UDP port 8899 on your router.

you can try to debug it via your PC/laptop. Just be on the same network as inverter, install python, and run: python src/exporter.py --port 8787 --inverter 192.168.2.15 (put there your IP, port can be random)

You should see something like: GOODWE DATA EXPORTER v1.4.4

polling interval: 60s inverter scrape IP: 192.168.2.15 total PV power: 5670W spot price scrape: Enabled spot price scrape interval: 0:30:00 min exporter started on port: 8787


energy price(spot): 0.0 eur/KW last spot price scrape: 2024-07-24 06:56:04.551613 number of metrics: 135 last scrape: 24.07.2024 06:56:09