SOLVED: Entity unavailable with DMSR smart meter

On my Synology I start home assistant as a docker with docker compose:

    homeassistant:
        image: homeassistant/home-assistant:latest
        container_name: home-assistant
        volumes:
          - /volume1/docker/homeassistant/config:/config
          - /etc/localtime:/etc/localtime:ro
        devices:
          - /dev/ttyACM0:/dev/ttyACM0
          - /dev/ttyUSB0:/dev/ttyUSB0
        restart: always
        network_mode: host

I checked with ‘dmesg | grep tty’ that the serial usb cable has port /dev/ttyUSB0 after installing a package for serial drivers on my synology. Also, I put the usb cable in my laptop and with a serial monitor I got the output as expected.

My configuration looks like this:

sensor:
  # P1 smart meter
  - platform: dsmr
    port: /dev/ttyUSB0
    dsmr_version: 5

With groups.yaml like this:

  meter_readings:
    name: Meter readings
    entities:
      - sensor.power_consumption 
      - sensor.power_consumption_low 
      - sensor.power_consumption_normal 
      - sensor.power_consumption_phase_l1 
      - sensor.power_consumption_phase_l2 
      - sensor.power_consumption_phase_l3 
      - sensor.power_production 
      - sensor.power_production_low 
      - sensor.power_production_normal 
      - sensor.power_production_phase_l1 
      - sensor.power_production_phase_l2 
      - sensor.power_production_phase_l3 
      - sensor.power_tariff 
      - sensor.voltage_sags_phase_l1 
      - sensor.voltage_sags_phase_l2 
      - sensor.voltage_sags_phase_l3 
      - sensor.voltage_swells_phase_l1 
      - sensor.voltage_swells_phase_l2 
      - sensor.voltage_swells_phase_l3 
      - sensor.long_power_failure_count 
      - sensor.gas_consumption 
      - sensor.hourly_gas_consumption

I tried different entities from some examples I found online, nothing works. In Home Assistant I get ‘Entiteit niet beschikbaar …’ (entity unavailable) for all these items I add in the group.

My meter was installed today and it is a v5 meter, it is able to measure consumption on the different phases.

Anybody got an idea on what is going wrong here?

edit: looks like a problem connecting to the usb device:

Error connecting to DSMR
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/serial/serialposix.py", line 265, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: '/dev/ttyUSB0'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/dsmr/config_flow.py", line 74, in validate_connect
    transport, protocol = await asyncio.create_task(reader_factory())
  File "/usr/local/lib/python3.8/asyncio/coroutines.py", line 124, in coro
    res = func(*args, **kw)
  File "/usr/local/lib/python3.8/site-packages/serial_asyncio/__init__.py", line 410, in create_serial_connection
    ser = serial.serial_for_url(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/serial/__init__.py", line 88, in serial_for_url
    instance.open()
  File "/usr/local/lib/python3.8/site-packages/serial/serialposix.py", line 268, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))
serial.serialutil.SerialException: [Errno 2] could not open port /dev/ttyUSB0: [Errno 2] No such file or directory: '/dev/ttyUSB0'

edit2: Probably solved, I forgot to reload docker compose file after changing it to include the usb device. I figured a reboot of the nas should start the docker with the changes but ofcourse thats not the case.