Skip to content

Commit

Permalink
Update esp8266 guide. Koenkk/zigbee2mqtt#2576
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Dec 23, 2019
1 parent b639095 commit b33badd
Showing 1 changed file with 5 additions and 140 deletions.
145 changes: 5 additions & 140 deletions docs/information/connecting_cc2530.md
Expand Up @@ -141,148 +141,13 @@ j. Event processing: Generic

Press Submit, the setup is now completed.

### Mounting the serialport
The following instructions need to be executed on the computer that Zigbee2mqtt is running on.

```bash
# Install soccat
sudo apt-get install -y socat

# Create directory for mount point
sudo mkdir /opt/zigbee2mqtt/vusb/

# Give pi user owner rights to /opt/zigbee2mqtt/vusb/
sudo chown -R pi:pi /opt/zigbee2mqtt/vusb/
```

### Comfirm that the connection works
Change the `IP` and `PORT` and execute:

```bash
socat -d -d pty,raw,echo=0,link=/opt/zigbee2mqtt/vusb/zigbee_cc2530 tcp-connect:IP:PORT
```
or

```bash
socat -d -d pty,raw,b115200,echo=0,link=/opt/zigbee2mqtt/vusb/zigbee_cc2530 tcp:127.0.0.1:1775
```

### Mounting the serialport on boot
```bash
sudo nano /etc/systemd/system/socat-vusb.service
```

Add the following to this file (make sure to change the `IP` and `PORT`)

```bash
[Unit]
Description=socat-vusb
After=network-online.target

[Service]
User=pi
ExecStart=/usr/bin/socat -d -d pty,raw,echo=0,link=/opt/zigbee2mqtt/vusb/zigbee_cc2530 tcp:IP:PORT,reuseaddr
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
```
Save the file and exit.

Update systemd:

```bash
sudo systemctl --system daemon-reload
```

Verify that the configuration works:
```bash
sudo systemctl start socat-vusb.service
```

Show status
```bash
systemctl status socat-vusb.service
```

In case you run Zigbee2mqtt as daemon, replace the contents of `sudo nano /etc/systemd/system/zigbee2mqtt.service` with below:

```
[Unit]
Description=zigbee2mqtt
Wants=socat-vusb.service
After=network.target socat-vusb.service
[Service]
ExecStart=/usr/bin/npm start
WorkingDirectory=/opt/zigbee2mqtt
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi
[Install]
WantedBy=multi-user.target
```

### Restart and check Log
```bash
sudo systemctl restart socat-vusb.service && sudo journalctl -f -u socat-vusb.service
```

Now that everything works, we want systemctl to start socat-vusb automatically on boot, this can be done by executing:

```bash
sudo systemctl enable socat-vusb.service
```

### Some tips that can be handy later:
Stopping socat-vusb
```bash
sudo systemctl stop socat-vusb
```

Starting socat-vusb
```bash
sudo systemctl start socat-vusb
```

### View the log of socat-vusb
```bash
sudo journalctl -u socat-vusb.service -f

Output should look like:
```bash
pi@hassbian:~ $ systemctl status socat-vusb.service
● socat-vusb.service - socat-vusb
Loaded: loaded (/etc/systemd/system/socat-vusb.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-02-01 15:35:24 UTC; 4min 11s ago
Main PID: 1406 (socat)
CGroup: /system.slice/socat-vusb.service
└─1406 /usr/bin/socat -d -d pty,raw,b115200,echo=0,link=/opt/zigbee2mqtt/vusb/zigbee_cc2530 tcp:127.0.0.1:1775,reuseaddr
Feb 01 15:35:24 hassbian systemd[1]: Started socat-vusb.
Feb 01 15:35:24 hassbian socat[1406]: 2019/02/01 15:35:24 socat[1406] N PTY is /dev/pts/3
Feb 01 15:35:24 hassbian socat[1406]: 2019/02/01 15:35:24 socat[1406] N opening connection to AF=2 127.0.0.1:1775
Feb 01 15:35:24 hassbian socat[1406]: 2019/02/01 15:35:24 socat[1406] N successfully connected from local address AF=2 127.0.0.1:47512
Feb 01 15:35:24 hassbian socat[1406]: 2019/02/01 15:35:24 socat[1406] N starting data transfer loop with FDs [5,5] and [7,7]
```

### Adding virtual device to zigbee2mqtt config
```bash
sudo nano /opt/zigbee2mqtt/data/configuration.yaml
```
### Zigbee2mqtt configuration
Now add the following to the Zigbee2mqtt `configuration.yaml`:

```yaml
serial:
port: /opt/zigbee2mqtt/vusb/zigbee_cc2530
advanced:
rtscts: false
port: 'tcp://192.168.2.13:20108'
```

### Restart zigbee2mqtt and confirm it works.
```bash
sudo systemctl restart zigbee2mqtt.service && sudo journalctl -f -u zigbee2mqtt.service
```
Note to change the IP address and port.
You can now start Zigbee2qmtt.

0 comments on commit b33badd

Please sign in to comment.