britkat1980 / giv_tcp

TCP connection (from inverter) and MQTT implementation
71 stars 32 forks source link

MQTT issue with 2.4.1 #134

Open PianSom opened 8 months ago

PianSom commented 8 months ago

I run GivTCP in its own Docker container, rather than as a HA Add-on. I am trying to upgrade from 2.2.4 (which works) to 2.4.1

I get a fail, with the following error:

06/11/2023
11:48:53
 INFO  Accepting connections at http://localhost:3000
06/11/2023
11:50:33
2023-11-06 11:50:33,291 - Inv1 - mqtt_client -  [ERROR   ] - No serial_number found in MQTT queue. MQTT Control not available.
06/11/2023
11:50:33
Traceback (most recent call last):
06/11/2023
11:50:33
  File "/app/GivTCP_1/mqtt_client.py", line 402, in <module>
06/11/2023
11:50:33
    client.loop_forever()
06/11/2023
11:50:33
  File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 1756, in loop_forever
06/11/2023
11:50:33
    rc = self._loop(timeout)
06/11/2023
11:50:33
  File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 1164, in _loop
06/11/2023
11:50:33
    rc = self.loop_read()
06/11/2023
11:50:33
  File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 1556, in loop_read
06/11/2023
11:50:33
    rc = self._packet_read()
06/11/2023
11:50:33
  File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 2439, in _packet_read
06/11/2023
11:50:33
    rc = self._packet_handle()
06/11/2023
11:50:33
  File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 3039, in _packet_handle
06/11/2023
11:50:33
    return self._handle_connack()
06/11/2023
11:50:33
  File "/usr/local/lib/python3.10/site-packages/paho/mqtt/client.py", line 3138, in _handle_connack
06/11/2023
11:50:33
    on_connect(
06/11/2023
11:50:33
  File "/app/GivTCP_1/mqtt_client.py", line 386, in on_connect
06/11/2023
11:50:33
    client.subscribe(MQTT_Topic+"/control/"+GiV_Settings.serial_number+"/#")
06/11/2023
11:50:33
AttributeError: type object 'GiV_Settings' has no attribute 'serial_number'
PianSom commented 8 months ago

FWIW my suspicion is that GivTCP is not finding my (AIO) inverter, even though the IP is specified as an ENV. I never got the 2.3 branch to work for this reason

PianSom commented 8 months ago

docker-compose.yaml:

  GivTCP:
    container_name: givtcp
    image: britkat/giv_tcp-ma:2.4.1
#    user: 1000:1000  
    ports:
#     - "1883:1883"                  # MQTT
      - "6345:6345"                   # REST (add increments for each inverter)
      - "8040:3000"                   # This should match the WEB_DASH_PORT ENV below
      - "6379:6379"                   # Redis port for job queueing
      - "9181:9181"                   # RQ Dashboard to view job scheduling
    environment:
## Critical to update
      - NUMINVERTORS=1                # Set this to the number of Inverters in your setup, then replicate the next two lines for each inverter (changing the last number of the ENV)
      - INVERTOR_IP_1=192.168.99.211                # Set this to the IP address of your Inverter on your local network
      - INVERTOR_AIO_1=True           
      - NUMBATTERIES_1=0              # Number of battery modules installed and connected to the above inverter
      - MQTT_OUTPUT=True              # "True" if you want to publish your data to MQTT, "False" otherwise
      - MQTT_ADDRESS=192.168.99.200                 # IP address of an existing MQTT broker, or leave as "127.0.0.1" to use the internal broker
      - MQTT_USERNAME=REDACTED                # Username of your existing broker, if needed. Not required for internal broker
      - MQTT_PASSWORD=REDACTED                # Password of your existing broker, if needed. Not required for internal broker
      - HOSTIP=192.168.99.200                       # External IP address of the docker host (needed for web dashboard)
      - CACHELOCATION=/config/GivTCP  # Location of cache data, this folder can be mapped to a persistence storage outside the container
      - TZ=Europe/London              # Set to your Timezone

<the rest as per default> 
PianSom commented 7 months ago

Looking at Debug logs, it appears that I was wrong - it does appear to be connecting to the AIO inverter. But is failing to retrieve the serial number for some reason.

PianSom commented 7 months ago

Issue solved, by including the env variable -

- INVERTOR_AC_1=False