Access to USB from addon

I’m newbie. I want to write an addon, inside which will be avrude for programming arduino from RPi with Hassio.

I had create /addons/avrdude and put 3 file:
config.json

{
  "name": "avrdude",
  "version": "0.1",
  "slug": "avrdude",
  "description": "Flash arduino from Hassio",
  "startup": "before",
  "boot": "auto",
  "options": {},
  "schema": {},
  "ports": {}
}

Dockerfile

ARG BUILD_FROM
FROM $BUILD_FROM
ENV LANG C.UTF-8

# Install AVRDude
RUN apk --no-cache add bash avrdude

WORKDIR /data

# Copy data for add-on
COPY run.sh /
RUN chmod a+x /run.sh

ENTRYPOINT [ "/run.sh" ]

run.sh

echo Hello world started!

echo ">docker -v"
docker -v

echo ">avrdude -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/addons/avrdude/Blink.ino.hex:i"
avrdude -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/addons/avrdude/Blink.ino.hex:i

echo Hello world finished!

Output in addon’s log

Hello world started!
>docker -v
/run.sh: line 4: docker: not found

>avrdude -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D -Uflash:w:/addons/avrdude/Blink.ino.hex:i
avrdude: Version 6.3, compiled on May  8 2018 at 16:59:46
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch
         System wide configuration file is "/etc/avrdude.conf"
         User configuration file is "/root/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping
         Using Port                    : /dev/ttyUSB0
         Using Programmer              : arduino
         Overriding Baud Rate          : 57600
avrdude: ser_open(): can't open device "/dev/ttyUSB0": No such file or directory
avrdude done.  Thank you.
Hello world finished!

As I see - avrdude works but has no access to /dev/ttyUSB0, it really exists and I can to see it on page Hassis/System, button Hardware. For grant the access Google tells use command docker run -t -i --device=/dev/ttyUSB0 ubuntu bash. But I get error /run.sh: line 4: docker: not found.
Please help with can't open device "/dev/ttyUSB0".

Upd.
Tried to add a line to the config.json:

"devices": ["/dev/ttyUSB0:/dev/ttyUSB0:rwm"]

Did no effect, the same error can't open device "/dev/ttyUSB0".
Please help!

Maybe someone knows the addon with access to the USB, so I use it as an example? There is nothing search by USB https://www.home-assistant.io/components/#all

Hi, I‘m accessing a USB device in one of my addons using this command:
“devices”: ["/dev/ttyUSB2:/dev/ttyUSB2:rwm"],

Seems identical so are you sure that USB0 is the correct device?

USB0 connected to Arduino. When I unplug Arduino, there is no USB0 device in info from page Hassis/System, button Hardware, therefore hardware is ok and name is correct.

On a PC with Linux Mint, this scheme works well.

@eXtatic - if your add-on is publicly available, please give me a link so that I can investigate it. Thank you :slight_smile:

Hey @ArtHome, sure, have a look in here.

1 Like

Could not find differences, apparently a bug…

Solved: after changing config.json, changes do not take effect even after reboot. Need to uninstall and install the addon.

@eXtatic thank you for help.

1 Like

ah, sure, btw. you can just increment the version number so you get an “update” option.

The example

Hi @ArtHome

I would like to make sure of your plug-in was wondering how ever what is the simplest way to install it i have tried adding the Git to home assistant Add-in store but had no luck, I must be honest i have not read up at all on how to load addons manually, was hoping you could just give me the rough steps needed to do so.

Cheers

May be it will be useful https://developers.home-assistant.io/docs/en/hassio_addon_tutorial.html
and instead hello_world use files from github

Hey

Thanks that was easy enough have not tested more then installing, will test uploading new firmware a bit later today.

Thanks

cheers

There are fast blink hex sketch included.