Page 1 of 1

SOLVED Docker and access to gpio pins on Rasp Pi using linuxserver image

Posted: Monday 24 February 2020 22:17
by AlanGpio
SOLVED SOLVED SOLVED SOLVED SOLVED
------------------------------------------------------------------------
The problem was the linuxserver/domoticz:arm32v7-latest image. I downloaded another image joshuacox/mkdomoticz, cleared out the mapped config directory, edited the compose file to use joshuacox/mkdomoticz + added "privileged: true" and then ran. Added my Rasp Pi as hardware and went to Devices and there were my 2 GPIOs. Hope this helps someone else.
Note: joshuacox/mkdomoticz is a 600MB download so don't try it on a Rasp Pi Zero ;)
------------------------------------------------------------------------

Hi. New install of Domoticz within Docker on a Rasp Pi 4 running Buster. I'm having problems getting Domoticz to see the gpio pins.
I've spent the whole day searching for a solution but no luck.
To test I have a push button GPIO 6 and an LED GPIO 13. I've defined the gpio pins in the host:

Code: Select all

echo 6 > /sys/class/gpio/export 
echo in > /sys/class/gpio/gpio6/direction 
echo falling > /sys/class/gpio/gpio6/edge 

echo 13 > /sys/class/gpio/export 
echo out > /sys/class/gpio/gpio13/direction 
echo 0 > /sys/class/gpio/gpio13/value
gpio exports
GPIO Pins exported:
   6: in   1  falling
  13: out  0  none
>>> Test LED on & off
echo 1 > /sys/class/gpio/gpio13/value
echo 0 > /sys/class/gpio/gpio13/value
>>>> Works !
So I know the Pi and the hardware are OK.

I installed Domoticz as a Docker Container. I selected the linuxserver/domoticz:arm32v7-latest image purely on the basis it had 10M+ downloads and therefore lots of people will have used it, many on a Pi. Hopefully some will read this post :) Here is the compose file:

Code: Select all

version: "2"
services:
  domoticz:
    container_name: domoticz
    image: linuxserver/domoticz:arm32v7-latest
    restart: unless-stopped     
    volumes:
      - /home/pi/bin/hms/docker_volumes/domoticz_data/domoticz_data:/config
      - /sys:/sys
    environment:
      - PUID=1001   # user pi
      - PGID=1001   # user pi
      - TZ=Europe/London
#     - WEBROOT=domoticz # optional for subfolder reverse proxy
    ports:
      - 18080:8080   # web ui - set to 18080 as openHAB uses 8080 # Also 8090 did not work
      - 6144:6144   # comms
      - 1443:1443   # comms
    # devices: # to be defined if needed, e.g for zigbee usb dongle
    # - path to device:path to device
I then started it via Portainer and accessed Domoticz via Firefox and defined my hardware:

Code: Select all

Name		Raspberry Pi 4 HMS
Type		Generic sysfs GPIO
Data Timeout	Disabled
Auto config devices	Yes
sysfsdebounce	Default
Enabled		Yes


I then went to the Devices page where Domoticz said "Loading..." then eventually "No data available"

Short log below.

I've read that one needs to edit rc.local to do the echo commands but a) I cannot find an existing rc.local file and b) I believe this is used when Domoticz is started at boot. In my case I manually installed and started Domoticz after the echo commands (I know they will not survive a re-boot)

One thought I've had, is that the linuxserver/domoticz doesn't have the dependencies for GPIO access. All user examples I've seen are accessing via MQTT or via USB devices. Despite 10M+ downloads I cannot find a forum for that container.

EDIT: Using Portainers CLI for Domoticz I typed:

Code: Select all

root@7f5d950c85a5:/# gpio exports
bash: gpio: command not found
root@7f5d950c85a5:/#
I understand that gpio is WiringPi. Maybe that's not installed. On the Pi host gpio is installed at /lib/modules/4.19.93-v8+/kernel/drivers/gpio but a find -name gpio in the Domoticz container finds nothing outside the sys directory (which is mapped to the Pi)
END EDIT

I do hope this is possible as Domoticz looks very good, especially the GUI Rules, and looks simpler to get going and maintain than openHAB. I would be grateful for any suggestions.

Alan
Log

Code: Select all

2020-02-24 20:20:12.980 Status: Domoticz V4.11719 (c)2012-2020 GizMoCuz
2020-02-24 20:20:12.981 Status: Build Hash: 08149c5ee, Date: 2020-02-21 18:00:16
2020-02-24 20:20:12.981 Status: Startup Path: /var/lib/domoticz/
2020-02-24 20:20:13.041 Active notification Subsystems: gcm, http (2/13)
2020-02-24 20:20:13.052 Starting shared server on: 0.0.0.0:6144
2020-02-24 20:20:13.036 Status: PluginSystem: Started, Python version '3.7.5'.
2020-02-24 20:20:13.043 Status: WebServer(HTTP) started on address: 0.0.0.0 with port 8080
2020-02-24 20:20:13.050 Status: WebServer(SSL) started on address: 0.0.0.0 with port 1443
2020-02-24 20:20:13.052 Status: TCPServer: shared server started...
2020-02-24 20:20:13.053 Status: RxQueue: queue worker started...
2020-02-24 20:20:15.077 Status: Sysfs GPIO: Startup - polling:no interrupts:no debounce:50msec inputs:0 outputs:0
2020-02-24 20:20:15.078 Status: NotificationSystem: thread started...
2020-02-24 20:20:15.078 Status: EventSystem: reset all events...
2020-02-24 20:20:15.079 Status: EventSystem: reset all device statuses...
2020-02-24 20:20:15.129 Status: Python EventSystem: Initalizing event module.
2020-02-24 20:20:15.130 Status: EventSystem: Started
2020-02-24 20:20:15.130 Status: EventSystem: Queue thread started...
2020-02-24 20:20:15.499 Status: PluginSystem: Entering work loop.
2020-02-24 20:20:29.202 Status: Incoming connection from: 192.168.1.15
2020-02-24 20:21:57.315 Status: Sysfs GPIO: Worker stopped
2020-02-24 20:22:28.357 Status: Sysfs GPIO: Startup - polling:no interrupts:no debounce:50msec inputs:0 outputs:0
2020-02-24 20:54:38.728 Status: Incoming connection from: 192.168.1.15