💾 Archived View for gemini.susa.net › home_automation.gmi captured on 2022-04-28 at 17:35:04. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2022-03-01)

-=-=-=-=-=-=-

Home Automation with Home Assistant

To start the server (based on the systemd configuration information), the following should work


sudo su - homeassistant
./bin/hass --daemon -c /home/homeassistant/.homeassistant

or simply

./bin/hass --daemon  # the above is the default configuration location

The following would run a non-detached instance as my own user (and create a new .homeassistant configuration folder in my home directory).

cd /srv/homeassistant
source bin/activate
./bin/hass

To SSH into the gateway, use root password from /home/homeassistant/README.gmi

ssh root@192.168.1.51

The boot process runs:

/etc/init.d/rcS -> /tuya/tuya_start.sh -> /tuya/serialgateway &

So check that serialgateway is running properly, and kill/restart if needed.

The web server is accessible on http://admin1:8123. No TLS for my LAN.

For reference, the hass usage is:

$ hass -h
usage: hass [-h] [--version] [-c path_to_config_dir] [--safe-mode] [--debug]
            [--open-ui] [--skip-pip] [-v] [--pid-file path_to_pid_file]
            [--log-rotate-days LOG_ROTATE_DAYS] [--log-file LOG_FILE]
            [--log-no-color] [--runner] [--script ...] [--daemon]

Home Assistant: Observe, Control, Automate.

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -c path_to_config_dir, --config path_to_config_dir
                        Directory that contains the Home Assistant
                        configuration
  --safe-mode           Start Home Assistant in safe mode
  --debug               Start Home Assistant in debug mode
  --open-ui             Open the webinterface in a browser
  --skip-pip            Skips pip install of required packages on startup
  -v, --verbose         Enable verbose logging to file.
  --pid-file path_to_pid_file
                        Path to PID file useful for running as daemon
  --log-rotate-days LOG_ROTATE_DAYS
                        Enables daily log rotation and keeps up to the
                        specified days
  --log-file LOG_FILE   Log file to write to. If not set, CONFIG/home-
                        assistant.log is used
  --log-no-color        Disable color logs
  --runner              On restart exit with code 100
  --script ...          Run one of the embedded scripts
  --daemon              Run Home Assistant as daemon

Running bellows (EZSP) directly

TL;DR - bellows is the driver that speaks EZSP with the zigbee radio firmware. It can be run standalone. zigpy is a higher level of abstraction that offers a unified interface to different types of radio hardware and firmware (currently ezsp, deconz, xbee, zigate, and znp). At the moment, I am only using ezsp, so only the bellows driver is relevant, hence it may be that zigpy brings nothing useful right now.

Home automation uses zigpy to talk to Zigbee Coordinators (gateways). My gateway is a RealTek RTL8196, with a TuYa TYZS4 ZigBee module, which contains a Silicon Labs ARM-M4 CPU with integrated RF stack (EFR32MG1B232).

The 'EmberZNet Serial Protocol' (EZSP) is the protocol used to interact with Silicon Labs Zigbee Coordinator. The coordinator is the entity that creates and manages the network for end nodes to join.

Paul Banks did some fantastic work rooting and hacking this device to make it useful.

Note that the hass server has to be shut down in order to use bellows directly, because the TCP->UART bridge only allows one connection to be made (obviously, since two processes driving the UART would be problematic!).

./bin/bellows --device 'socket://192.168.178.51:8888' info

The output is as follows:

[58:8e:81:ff:fe:d8:e2:73]
[0x0000]
[<EmberNetworkStatus.JOINED_NETWORK: 2>]
[<EmberStatus.SUCCESS: 0>, <EmberNodeType.COORDINATOR: 1>, EmberNetworkParameters(extendedPanId=5e:9e:4f:93:fd:4a:25:a6, panId=0x4ec9, radioTxPower=13, radioChannel=15, joinMethod=<EmberJoinMethod.USE_MAC_ASSOCIATION: 0>, nwkManagerId=0x0000, nwkUpdateId=0, channels=<Channels.ALL_CHANNELS: 134215680>)]
[<EmberStatus.SUCCESS: 0>, EmberCurrentSecurityState(bitmask=<EmberCurrentSecurityBitmask.TRUST_CENTER_USES_HASHED_LINK_KEY|64|32|HAVE_TRUST_CENTER_LINK_KEY|GLOBAL_LINK_KEY: 244>, trustCenterLongAddress=58:8e:81:ff:fe:d8:e2:73)]
Manufacturer:
Board name:
EmberZNet version: 6.5.0.0 build 188

The bellows package can be installed with 'pip3 install bellows'. A higher level of abstraction is available from zigpy - 'pip3 install git+https://github.com/zigpy/zigpy-cli.git'

For bellows, use -d to specify the serial port or socket address, or define it as an environment variable:

export EZSP_DEVICE=socket://192.168.1.51:8888

The LED Bulbs

The bulbs I have contain a Tuya module. See 'ZS3L Module Datasheet' for more details. This module can almost certainly be re-purposed, along with the power supply in the bulb, though perhaps via a low amp fuse for extra safety if it's only being used for switching.

Embedded low-power 32-bit Arm Cortex-M33 processor, which provides a digital signal processor (DSP) instructions and floating-point units (FPUs) and can also function as an application processor
    Clock rate: 80 MHz
    Operating voltage: 2.0 to 3.8 V
    Peripherals: 9×GPIOs, 1×UART, 1×ADC
    Zigbee Connectivity
        802.15.4 MAC/PHY
        Channels 11 - 26@2.400-2.483GHz, 250 Kbit/s air interface rate
        Maximum output power: +20 dBm
        Runtime power consumption: 60 µA/MHz; current in sleep mode: 5 µA
        Onboard PCB antenna with a gain of 1.8 dBi
        Operating temperature: –40℃ to +105℃
        AES 128/256 hardware encryption