I just configured dsmr, sensors are unavailable in lovelace, and there is an error in the log (see below).
HA runs in a Virtualbox VM on top of my linux laptop, HA Version | 2021.1.0
I can read the telegrams on my laptop using putty on /dev/ttyUSB0
Before activating the HA VM, I closed putty and rebooted the laptop, to make sure putty is not blocking the serial port for itself.
To give putty access to the serial port, I needed to give myself access to the uucp group
As I am the user that starts Virtualbox, I suppose that should give Virtualbox also access to the serial port.
ls -l /dev/ttyUSB*
crw-rw---- 1 root uucp 188, 0 9 jan 18:03 /dev/ttyUSB0
sudo usermod -a -G uucp marc
In Virtualbox/Settings/Serial ports, I enabled the serial port COM1, put it in host device mode.
In Host Pipe mode, selected connect to existing pipe/socket, and Path/Address: /dev/ttyUSB0, Virtualbox throws an error that it cannot connect to /dev/ttyUSB0,
so I switched back to host device mode.
While in host device mode, when I pull out the USB serial cable, Virtualbox throws an error becaus it cannot reach /dev/ttyUSB0 anymore, so I suppose virtualbox was connected to the serial port, and the problem is in HA settings.
When I go on the HA commandline, and cd to /dev, I don’t see a ttyUSB0 device, but lots of other tty devices: tty, tty0, … , tty56.
So probably in configuration.yaml I should probably use another port, but which one, there are so many of them in /dev
# Example configuration.yaml entry for USB/serial connected Smartmeter
- platform: dsmr
port: /dev/ttyUSB1
dsmr_version: 5B
group:
meter_readings:
name: Meter readings
entities:
- sensor.energy_consumption_tarif_1
- sensor.energy_consumption_tarif_2
- sensor.energy_production_tarif_1
- sensor.energy_production_tarif_2
# HA logs
2021-01-09 17:03:05 ERROR (MainThread) [homeassistant.components.dsmr.config_flow] Error connecting to DSMR
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/serial/serialposix.py", line 322, 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 82, in validate_connect
transport, protocol = await asyncio.create_task(reader_factory())
File "/usr/local/lib/python3.8/site-packages/serial_asyncio/ **init** .py", line 445, in create_serial_connection
serial_instance = serial.serial_for_url(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/serial/ **init** .py", line 90, in serial_for_url
instance.open()
File "/usr/local/lib/python3.8/site-packages/serial/serialposix.py", line 325, 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'