lociii / homeassistant-config

My HomeAssistant config
17 stars 1 forks source link

Consider switching from z2m to zha #17

Closed lociii closed 4 years ago

lociii commented 4 years ago

Pros:

Cons:

Comparison:

Topic zha
Firmware upgrades yes
Groups yes
Support CC26X2R1 yes
MiJia wireless switch yes
Bitron AV2010/32 wall thermostat yes, tested
TRADFRI LED bulb yes
Hue white and color ambiance LightStrip yes
Aqara smart home cube yes
Aqara temperature, humidity and pressure yes
Aqara door & window contact sensor yes
Aqara human body movement and illuminance sensor yes
Aqara water leak sensor yes
lociii commented 4 years ago

Test to forward the Zigbee coordinator from a Pi Zero W to the NUC using usbip, see thread.

lociii commented 4 years ago

This is just a copy of the contents of the aforementioned thread in case it gets deleted. All credits to luma

On the Pi Zero W (USB host) running latest Raspberry Pi OS

Get the USB ID of the coordinator device

lsusb
>> Bus 001 Device 002: ID 0451:16a8 Texas Instruments, Inc.

0451:16a8 is the ID we're looking for.

Set up usbip

Install usbip, load the kernel module and set it up to load on boot

sudo -s
apt-get install usbip
modprobe usbip_host
echo 'usbip_host' >> /etc/modules

Add a service definition to expose the device in /lib/systemd/system/usbipd.service

[Unit]
Description=usbip host daemon
After=network.target

[Service]
Type=forking
ExecStart=/usr/sbin/usbipd -D
ExecStartPost=/bin/sh -c "/usr/sbin/usbip bind --$(/usr/sbin/usbip list -p -l | grep '#usbid=0451:16a8#' | cut '-d#' -f1)"
ExecStop=/bin/sh -c "/usr/sbin/usbip unbind --$(/usr/sbin/usbip list -p -l | grep '#usbid=0451:16a8#' | cut '-d#' -f1`); killall usbipd"

[Install]
WantedBy=multi-user.target

Make the service known, load and start it

sudo systemctl --system daemon-reload
sudo systemctl enable usbipd.service
sudo systemctl start usbipd.service

On the client

Set up usbip

On Ubuntu usbip is part of the generic tools package, install it and load the virtual USB host controller module

sudo -s
apt-get install linux-tools-generic -y
modprobe vhci-hcd
echo 'vhci-hcd' >> /etc/modules

Add a service definition to make the remote device available in /lib/systemd/system/usbip.service

[Unit]
Description=usbip client
After=network.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c "/usr/lib/linux-tools/$(uname -r)/usbip attach -r 10.10.10.10 -b $(/usr/lib/linux-tools/$(uname -r)/usbip list -r 10.10.10.10 | grep '0451:16a8' | cut -d: -f1)"
ExecStop=/bin/sh -c "/usr/lib/linux-tools/$(uname -r)/usbip detach --port=$(/usr/lib/linux-tools/$(uname -r)/usbip port | grep '<Port in Use>' | sed -E 's/^Port ([0-9][0-9]).*/\\1/')"

[Install]
WantedBy=multi-user.target

Replace 10.10.10.10 by your IP address and 0451:16a8 by the ID of your USB device

Make the service known, load and start it

sudo systemctl --system daemon-reload
sudo systemctl enable usbipd.service
sudo systemctl start usbipd.service
lociii commented 4 years ago

Switch done. Everything working as expected except for Philips outdoor motion sensor SML002. See https://github.com/zigpy/zigpy-cc/issues/57

lociii commented 4 years ago

ZHA light groups aren't working as well. Using HA light groups as a workaround.

lociii commented 4 years ago

Group control fixed in https://github.com/zigpy/zigpy-cc/issues/58 and waiting for release

Hedda commented 4 years ago

@lociii Seen you posted in https://github.com/zigpy/zigpy-cc/issues/58 and got other alternative serial-over-network tips if don't want to move your NUC:

The first tip is to use ESP8266 with Jeelabs ESP-LINK firmware instead of a Pi Zero W. Function is same if can connect via serial:

  1. https://github.com/jeelabs/esp-link

The second cutting-edge tip is to buy the new Sonoff ZBBridge and run Tasmota with its serial-bridge, it is an all-in-one device:

  1. https://www.digiblur.com/2020/07/how-to-use-sonoff-zigbee-bridge-with.html 2b. https://www.youtube.com/watch?v=dC1AEyFhmnc

PS: Regarding your Bitron AV2010/32 wall thermostat, open new issue on -> https://github.com/zigpy/zha-device-handlers/issues PPS: Somewhat related issue posted here but that is not quite on-topic https://github.com/zigpy/zha-device-handlers/issues/357

lociii commented 4 years ago

Oh wow. Thanks @Hedda

I got USBIP running on a Pi 3 since a while and it's working like a charm. Will check out your other proposals nevertheless. However I'd prefer not to buy another zigbee coordinator as the CC26X2R1 I'm currently using was quite expensive :-) For the group support it's just a matter of time until @sanyatuning changes are published.

For the Bitron AV2010/32 I just didn't update the list. They're working flawlessly.

So the last thing that's not working yet, is the SML002 Philips outdoor motion sensor from https://github.com/zigpy/zigpy-cc/issues/57

Will all work out sooner or later. People are spending their spare time to make all of this work, so I will have to be calmly waiting :-)

Hedda commented 4 years ago

Cool! If you have the skill then you too can help with quirks for devices, checkout -> https://github.com/zigpy/zha-device-handlers

lociii commented 4 years ago

Based on the discussion in https://github.com/zigpy/zigpy-cc/issues/57 it seems like the Philips SML002 needs some changes either to zigpy-cc or zigpy core. At least with my amateur knowledge of how zigbee communicates, it cannot be fixed in a quirk. Even if I would love to help, this goes way beyond what I'm currently capable of :)

lociii commented 4 years ago

Group support merged into HA core master https://github.com/home-assistant/core/pull/39318

lociii commented 4 years ago

Switched now from zigpy-cc to zigpy-znp and everything is working properly!