There are plenty smart home devices offering virtually any function you may dream of, however the things get complicated if you are not necessarily keen on creating an account for each single gadget and sharing your life with unknown clouds.
My first requirement was to find electric plugs able to measure voltage and consumption (doesn't matter if expressed as a current, power or energy). A few years ago I was quite happy with TP-Link HS110. They are easy to decouple from the cloud and the communication protocol was easy to implement thanks to softScheck's reverse engineering. There is no access protection implemented, so they need to be operated in a separated network. Surprisingly, they deliver quite precise measurements. Unfortunately, not available anymore.
Basically, in order to avoid effort with reverse-engineering and still reach the goal, two standards could be considered: Tasmota, an open-source firmware for ESP-based devices and Zigbee. Both having their disadvantages:
Tasmota
Zigbee
For the time being, I'm testing both technologies with these devices:
Zigbee plug nous A1Z
Tasmota plug nous A1T
OSRAM/Ledvance Zigbee plug without energy monitoring
First approach was to control Zigbee devices via a gateway developed for Raspberry Pi, a product of dresden elektronik. The RaspBee dongle has deRFmega256 chip onboard. It communicates via serial line with the Raspberry Pi.
Software installation:
wget -O - http://phoscon.de/apt/deconz.pub.key 2>/dev/null | sudo tee /etc/apt/trusted.gpg.d/phoscon.gpg
sudo sh -c "echo 'deb http://phoscon.de/apt/deconz $(lsb_release -cs) main' > /etc/apt/sources.list.d/deconz.list"
deb [trusted=yes] http://phoscon.de/apt/deconz bullseye main
sudo apt update
and then sudo apt install deconz
Application is available under Programming > deCONZ in the Raspbian menu.
For a programmatic access:
curl -X POST -H "Content-Type: text/plain" --data "{ \"devicetype\": \"watering\" }" http://127.0.0.1:8080/api/
sudo systemctl enable deconz
and then sudo systemctl start deconz
Short summary:
A much better option, as I think, is the well-known zigbee2mqtt. However, it must be clear, it is just a bridge between the Zigbee protocol and the MQTT queues. Still, it provides a simple web interface for configuring and updating devices. There is no bridge function inside.
For MQTT install mosquitto:
sudo apt install mosquitto mosquitto-clients
sudo nano /etc/mosquitto/conf.d/your-configuration.conf
sudo systemctl enable mosquitto
sudo systemctl start mosquitto
your-configuration.conf (listen to 0.0.0.0; anonymous is a setting of the listener - the order matters):
listener 1883
allow_anonymous true
mosquitto_sub -t '#'
mosquitto_pub -t cmnd/tasmota_XXXXXX/Status -m 8
mosquitto_pub -t cmnd/tasmota_XXXXXX/TelePeriod -m 60
mosquitto_pub -t cmnd/tasmota_XXXXXX/VoltRes -m 1
mosquitto_pub -t cmnd/tasmota_XXXXXX/WattRes -m 1
It's another gateway for the Zigbee network. It's based on the TI CC2652P chip.
Firmware upgrade:
pip install pyserial
and pip install intelhex
python3 cc2538-bsl.py -evw -p /dev/ttyUSB0 --bootloader-sonoff-usb CC1352P2_CC2652P_launchpad_coordinator_20221226.hex
Next: Processing emails using IMAP and Thunderbird files