tiagocoutinho / modbus-proxy

Connect multiple clients to modbus devices
Other
71 stars 13 forks source link

Connection from HA not possible & no log output on docker console #33

Closed CoolID2 closed 7 months ago

CoolID2 commented 8 months ago

Description

I have a Solaredge inverter, Homeassistant and will soon be getting a wallbox. Since only one device can access the inverter via Modbus and this works successfully with Homeassistant, I wanted to connect a Modbus proxy in between in preparation for my wallbox. In HA I have changed the port to 5020. With a port scan, I can also see that port 5020 is accessible on my Docker host system. But the integration does not work with the modbus proxy. In addition, neither info nor debug information is displayed on the console of the container. I can't even see whether the connection is working.

What I Did

Here is my

docker-compose.yml

version: "3.9"
services:

  modbus-proxy:
    container_name: modbus-proxy
    image: tiagocoutinho/modbus-proxy:latest
    restart: unless-stopped
    ports:
      - 5020:502
    environment:
      TZ: ${TZ}
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ${DATA}/modbus_proxy/config/modbus-proxy.yml:/etc/modbus-proxy.yml:ro

modbus-proxy.yml


devices:
- modbus:
    url: solaredge.iot:1502     # device url (mandatory)
    timeout: 10                 # communication timeout (s) (optional, default: 10)
    connection_time: 0.1        # delay after connection (s) (optional, default: 0)
  listen:
    bind: 0:502                 # listening address (mandatory)4
logging:
  version: 1
  formatters:
    standard:
      format: "%(asctime)s %(levelname)8s %(name)s: %(message)s"
  handlers:
    console:
      class: logging.StreamHandler
      formatter: standard
  root:
    handlers: ['console']
    level: DEBUG

What am I doing wrong???

magpern commented 7 months ago

Is it working at all for you? You have a config file, but I don't see you tell modbus-proxy to pick it up, in your docker compose file. I also have a config file, my docker compose looks like this image

The command is what I am thinking of

CoolID2 commented 7 months ago

Hello,

I found out how to switch on the logging correctly via this page. https://hub.docker.com/r/tiagocoutinho/modbus-proxy

-e RUST_LOG=debug

This was the decisive hint. My modbus-proxy.yml now also looks a bit different.

devices:
- modbus:
    url: 192.168.1.10:1502      # device url (mandatory)
    timeout: 10                 # communication timeout (s) (optional, default: 10)
    connection_time: 0.1        # delay after connection (s) (optional, default: 0)
  listen:
    bind: 0:502                 # listening address (mandatory)4