Skip to content

Commit e77d1aa

Browse files
authored
Update README.md
Added usbip remote service.
1 parent 17e2ad7 commit e77d1aa

File tree

1 file changed

+93
-1
lines changed

1 file changed

+93
-1
lines changed

README.md

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ This integration has been tested with JA-80K /JA-82K central units, JA-81F keypa
3939
Tested sensors include wired/wireless PIRs & door sensors and wired/wireless fire alarms.
4040
4141
## Remote Support
42-
The JA-80T serial cable setup can work with remote serial devices using a device address of 'socket://[ipaddress:socket]' (e.g. socket://192.168.0.1:23) , see section at bottom of page for more details. This can be made to work even without a JA-80T serial cable (as these are hard to source)
42+
The JA-80T serial cable setup can work with remote serial devices using a device address of 'socket://[ipaddress:socket]' (e.g. socket://192.168.0.1:23) , see section at bottom of page for more details. This can be made to work even without a JA-80T serial cable (as these are hard to source).
43+
It does also work with a tool called usbipd, 'duplicating' the /dev/hidraw0 device from a server connected to the jablotron alarm to the homeassistant client machine.
4344
4445
## Examples & configuration
4546
@@ -290,6 +291,97 @@ Serial Port to be setup as `9600 baud, 8 bit, no partity, 1 stop bit`. Must be s
290291
Additional expected similar solutions could be constructed from USR-TCP232-306, USR-TCP232-304 connected directly to the control panel or
291292
USR-TCP232-302 conected to an existing JA-80T serial cable.
292293
294+
Another solution for remote usage could be via the use of USBIP that needs to be installed on the server (jablotron alarm side) and the client (homeassistant running this repo.)
295+
296+
Using the following command on the server to check if (in this case JA-82T) is visible:
297+
```
298+
dmesg | grep hid
299+
300+
[8740307.349070] hid-generic 0003:16D6:0007.0002: hiddev96,hidraw0: USB HID v1.11 Device [JABLOTRON ALARMS JA-82T PC Interface] on usb-0000:01:00.0-1.3/input0
301+
```
302+
Now we know the device we are looking for is hidraw0 and the ID **16D6:0007** the id can also be optained if the command ```lsusb``` is executed
303+
304+
Installation of usbip needs to be done on the **CLient** and **Server** via:
305+
After the above command on the Server execute:
306+
```
307+
sudo apt install usbip hwdata usbutils
308+
modprobe usbip_host
309+
echo 'usbip_host' >> /etc/modules
310+
311+
# Create a systemd service
312+
nano /lib/systemd/system/usbipd.service
313+
```
314+
315+
The file usbipd.service should contain.
316+
```
317+
[Unit]
318+
Description=usbip host daemon
319+
After=network.target
320+
321+
[Service]
322+
Type=forking
323+
ExecStart=/usr/sbin/usbipd -D
324+
ExecStartPost=/bin/sh -c "/usr/sbin/usbip bind --$(/usr/sbin/usbip list -p -l | grep '#usbid=16d6:0007#' | cut '-d#' -f1)"
325+
ExecStop=/bin/sh -c "/usr/sbin/usbip unbind --$(/usr/sbin/usbip list -p -l | grep '#usbid=16d6:0007#' | cut '-d#' -f1); killall usbipd"
326+
327+
[Install]
328+
WantedBy=multi-user.target
329+
```
330+
Only change the #usbid=16d6:0007# if necessary.
331+
Save the file and execute:
332+
333+
```
334+
# reload systemd, enable, then start the service
335+
sudo systemctl --system daemon-reload
336+
sudo systemctl enable usbipd.service
337+
sudo systemctl start usbipd.service
338+
```
339+
The server setup is now complete, move over to the client
340+
```
341+
sudo apt install usbip hwdata usbutils
342+
modprobe vhci-hcd
343+
echo 'vhci-hcd' >> /etc/modules
344+
```
345+
Much like we did on the server, we’re going to need to modify the ExecStart and ExecStop lines below to search for the correct USB device ID that’s being presented by your USB/IP server. Likewise, change the IP 192.168.0.10 to match your USB server.
346+
347+
```
348+
nano /lib/systemd/system/usbip.service
349+
```
350+
351+
```
352+
[Unit]
353+
Description=usbip client
354+
After=network.target
355+
356+
[Service]
357+
Type=oneshot
358+
RemainAfterExit=yes
359+
ExecStart=/bin/sh -c "/usr/sbin/usbip attach -r 192.168.0.10 -b $(/usr/sbin/usbip list -r 192.168.0.10 | grep '16d6:0007' | cut -d: -f1)"
360+
ExecStop=/bin/sh -c "/usr/sbin/usbip detach --port=$(/usr/sbin/usbip port | grep '<Port in Use>' | sed -E 's/^Port ([0-9][0-9]).*/\1/')"
361+
362+
[Install]
363+
WantedBy=multi-user.target
364+
365+
```
366+
Save that file, then run the following commands in your shell:
367+
368+
```
369+
# reload systemd, enable, then start the service
370+
sudo systemctl --system daemon-reload
371+
sudo systemctl enable usbip.service
372+
sudo systemctl start usbip.service
373+
```
374+
375+
You should now be able to access the USB device on the client as if the device was plugged in locally, ```(ls -l /dev/hidraw0)``` and you have an auto-starting systemd service to control things.)
376+
377+
Thanks to [derushadigital.com](https://derushadigital.com/other%20projects/2019/02/19/RPi-USBIP-ZWave.html)
378+
379+
For Docker users we need to add the following to the docker_compose file to enable homeassistant to use this device:
380+
381+
devices:
382+
- /dev/hidraw0
383+
384+
293385
## Troubleshooting
294386
295387
Additional logging can be enabled in configuration.yaml

0 commit comments

Comments
 (0)