Gateway Addon for Hass.io



  • Hi there,
    in these days I've been trying to get the Gateway working as an add-on for Hass.io, running on RaspberryPi3.
    You can find all my work (well, tons of hours for just some lines! :D) here on GitHub. Even it's the master branch, it's totally in development...
    So, now, I'm stuck.

    It looks like that if I start the Docker container as privileged, it works! But not when it start with the configuration you see, and neither I can give the privileged capability to the container.
    Any ideas on what on the host I should expose?



  • @ghiglie I presume you've seen this. Tried them all?

    Privilege for access to hardware/system. Available access: NET_ADMIN, SYS_ADMIN, SYS_RAWIO, SYS_TIME, SYS_NICE



  • Is this the error you're taking about?

    [services.d] starting services
    [services.d] done.
    ifelse: fatal: unable to exec /run.sh: Permission denied
    [cmd] /run.sh exited 111
    [cont-finish.d] executing container finish scripts...
    [cont-finish.d] 99-message.sh: executing... 
    -----------------------------------------------------------
                    Oops! Something went wrong.
     
     We are so sorry, but something went terribly wrong when
     starting or running this add-on.
     
     Be sure to check the log above, line by line, for hints.
    -----------------------------------------------------------
    [cont-finish.d] 99-message.sh: exited 0.
    [cont-finish.d] done.
    


  • Try setting permissions on run.sh.

    RUN chmod a+x /run.sh
    
    CMD [ "/run.sh" ]
    


  • oops, sorry, I've fixed that locally after I pushed the code to git. I see just now I'm not exposing the 5003 port... 😐

    I'll add the RUN command.

    I mean, mysgw hangs on activating the transport.

    @hautomate said in Gateway Addon for Hass.io:

    @ghiglie I presume you've seen this. Tried them all?

    Privilege for access to hardware/system. Available access: NET_ADMIN, SYS_ADMIN, SYS_RAWIO, SYS_TIME, SYS_NICE

    Yes, tried all, even with gpio set to true.



  • Add...

    "host_network": true,

    and for port 5003, what about this?

    "ports": {
    "5003/tcp": 5003
    },

    Or put the port as an option so it could be configured by the user. I'm not sure what else would be needed for this to work.

    "options": {
    "port": 5003,



  • @hautomate said in Gateway Addon for Hass.io:

    Add...

    "host_network": true,

    and for port 5003, what about this?

    "ports": {
    "5003/tcp": 5003
    },

    Or put the port as an option so it could be configured by the user. I'm not sure what else would be needed for this to work.

    "options": {
    "port": 5003,

    I've added it locally, since it's primaly a MQTT image.

    I'm stopping here now:

    mysgw: Starting gateway...
    mysgw: Protocol version - 2.2.0-rc.2
    mysgw: MCO:BGN:INIT GW,CP=RNNGL---,VER=2.2.0-rc.2
    mysgw: TSF:LRT:OK
    mysgw: TSM:INIT
    mysgw: TSF:WUR:MS=0

    so it's not starting the transport.
    Any idea on what I shoudl enable?



  • @ghiglie hmm, not sure. Would you please update your repo with the latest and I'll try a reinstall and have a closer look?



  • @hautomate said in Gateway Addon for Hass.io:

    @ghiglie hmm, not sure. Would you please update your repo with the latest and I'll try a reinstall and have a closer look?

    sorry, I'm out for work 😞 I'll do ASAP tomorrow!

    EDIT: Updated!



  • @ghiglie It shows the last commit as 14 days ago...



  • Will be watching with interest. I'd like to move to hass.io but this is the one thing stopping me.



  • @hautomate said in Gateway Addon for Hass.io:

    @ghiglie It shows the last commit as 14 days ago...

    git-noob mistake! updated!



  • @ghiglie said in Gateway Addon for Hass.io:

    git-noob mistake! updated!

    Haha! I forgot to tell you that I have no idea what I'm doing 🙂

    The 'run chmod' command is still missing in the dockerfile.



  • Wondering what the status of this is. Would love to try it out as I have migrated to hassio and would love to integrate mysensors gateway back on the same rpi.



  • I'm also trying to make a hassio addon for the mysensors gateway which is connected on the same raspberry pi 2.

    If I run the docker image with --privileged then it runs correctly: it manages to read from the nrf2401, it connects to the MQTT server and publishes incoming messages.

    However, if I run the container without --privileged (like hassio does), the mysgw program does not output anything else after:

    : Starting gateway...
    : Protocol version - 2.2.0
    : MCO:BGN:INIT GW,CP=RNNGL---,VER=2.2.0
    : TSF:LRT:OK
    : TSM:INIT
    : TSF:WUR:MS=0
    

    I'm running the container like this:

    docker run -it --rm --cap-add SYS_RAWIO --device /dev/mem --device /dev/gpiomem local/mysgw
    

    If I run a strace on the mysgw binary, I see:

    bash-4.4# strace mysgw -d 2>&1 | grep open
    open("/sys/class/gpio", O_RDONLY|O_LARGEFILE|O_DIRECTORY|O_CLOEXEC) = 3
    open("/sys/class/gpio/gpiochip0/base", O_RDONLY|O_LARGEFILE) = 4
    open("/sys/class/gpio/gpiochip0/ngpio", O_RDONLY|O_LARGEFILE) = 4
    open("/sys/class/gpio/gpiochip100/base", O_RDONLY|O_LARGEFILE) = 4
    open("/sys/class/gpio/gpiochip100/ngpio", O_RDONLY|O_LARGEFILE) = 4
    open("/etc/mysensors.dat", O_RDONLY|O_LARGEFILE) = 3
    open("/dev/urandom", O_RDONLY|O_LARGEFILE) = 3
    open("/dev/console", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 5
    open("/dev/console", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 5
    open("/dev/console", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 5
    open("/etc/mysensors.dat", O_RDONLY|O_LARGEFILE) = 5
    open("/dev/console", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 5
    open("/dev/console", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 5
    open("/dev/console", O_WRONLY|O_NOCTTY|O_LARGEFILE|O_CLOEXEC) = 5
    open("/proc/cpuinfo", O_RDONLY|O_LARGEFILE) = 5
    open("/proc/device-tree/soc/ranges", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
    open("/dev/mem", O_RDWR|O_SYNC|O_LARGEFILE) = 5
    

    It looks like it can't open a device which is also described in https://www.mysensors.org/apidocs/group__BCM2835grp.html

    It seems to be a symlink to some device in /sys, but this directory is empty somehow.

    bash-4.4# ls -al /proc/device-tree 
    lrwxrwxrwx    1 root     root            29 May  7 15:10 /proc/device-tree -> /sys/firmware/devicetree/base
    bash-4.4# ls -al /sys/firmware
    total 0
    drwxrwxrwt    2 root     root            40 May  7 15:34 .
    dr-xr-xr-x   12 root     root             0 May  7 15:34 ..
    

    That's how far I got. Does anyone know how to make this device available within the container without having to use --privileged?



  • Hi @kwek, sorry for taking so much to reply. We've been taking the same path!

    @kwek said in Gateway Addon for Hass.io:

    I'm also trying to make a hassio addon for the mysensors gateway which is connected on the same raspberry pi 2.

    If I run the docker image with --privileged then it runs correctly: it manages to read from the nrf2401, it connects to the MQTT server and publishes incoming messages.

    However, if I run the container without --privileged (like hassio does), the mysgw program does not output anything else after:

    Same here. I've been trying some time ago, if I get to start the container in privileged mode it runs without any problems!

    So, I've been looking to how enable the GPIO on the board to the container, using the ResinOS guide: https://docs.resin.io/learn/develop/hardware/gpio/

    ...but I got nothing of use. You see anyway that the GPIO definitions are under the /sys/class/gpio/ device tree...

    I hope to have some more spare time to test this.



  • @ghiglie Here's an add-on that uses a pi gpio pin. Maybe it will help.

    https://github.com/pantomax/hassio-addons/tree/master/rpi-rf-receiver

    It's discussed in this thread:
    https://community.home-assistant.io/t/rpi-rf-receiver-addon/32947



  • @hautomate Thanks! I didn't notice it at all.
    EDIT: A quick look:
    @pantomax in config.json "only" has:

        "devices": ["/dev/mem:/dev/mem:rw"],
        "privileged": ["SYS_RAWIO"],
        "gpio": "true",
    

    ...while I put an overpowered:

      "devices": [ "/dev/mem:/dev/mem:rw" ],
      "privileged": [ "SYS_RAWIO", "SYS_ADMIN", "NET_ADMIN" ],
      "gpio": "true",
    

    so... it should work 😞



  • Did you get this up and running?


Log in to reply
 

Suggested Topics

  • 1
  • 8
  • 5
  • 17
  • 1
  • 3

8
Online

11.4k
Users

11.1k
Topics

112.7k
Posts