[RELEASE] Shelly Plug US Gen4 (Zigbee) driver: plug-reported units, no relay toggle on Configure

I wrote a driver for the Shelly Plug US Gen4 (S4PL-00116US) in Zigbee mode. It's on HPM and GitHub.

GitHub: GitHub - chsbusch-dot/hubitat-shelly-gen4-zigbee: Hubitat Elevation driver for the Shelly Plug US Gen4 in Zigbee mode: plug-reported units, bundled reports, no relay toggle on configure (HPM package) · GitHub
HPM: search for "Shelly Plug US Gen4". The package is "Shelly Plug US Gen4 (Zigbee)", author Chris Busch. If the search does not find it yet, choose From a URL and paste https://raw.githubusercontent.com/chsbusch-dot/hubitat-shelly-gen4-zigbee/main/packageManifest.json

Why I wrote it

The plug pairs as a Generic Zigbee Outlet. I moved mine to the Shelly 1PM Gen 4 Zigbee driver by @joaomf and @kkossev, which is written for the 1PM relay.

On plug firmware 020000FF, power comes in watts and current in milliamps. The 1PM driver divides both by 100, so a 1000 W heater shows as 10 W and 9 A as 90 A. The plug states its own multiplier and divisor in the standard Zigbee attributes. This driver reads those and scales every reading with them, so the numbers stay right when a firmware update changes the units again.

The plug also often sends current and power in one message. Reading only the first value leaves power frozen while current keeps updating. This driver reads every value in the message.

Configure leaves the relay alone. The built-in Generic Zigbee Outlet driver switches the outlet off and on while it configures, which is the last thing I want on a plug that runs a space heater.

Features

  • Switch, power, energy, voltage, current and AC frequency. Power factor and the light sensor's level where the firmware offers them (firmware 2.0.1 and up for the light level).
  • Trip detection: when the plug switches itself off under load (its overpower, overcurrent or overvoltage protection), the driver logs it and counts it in tripCount, so a rule can stop switching a heater back on.
  • Plug settings from Hubitat, sent only when you set them: power-on state, overpower cutoff, current and voltage limits, an auto-off timer that the plug runs by itself, and the LED ring (mode, colours, brightness, night mode).
  • Bluetooth on or off, and setWifi and wifiOff, so the plug can fetch a firmware update over Wi-Fi without the Shelly app. None of these touch the relay.
  • Identify (blinks the LED), and a health check that does not mark an idle plug offline.

I've tested it on two plugs on firmware 2.0.0, 2.0.1 and 2.2.0-beta1, on a C-8. The README has a Safety section (please read it if the plug runs a heater), the units table per firmware, and what is not supported.

The driver is derived from the 1PM driver (Apache 2.0), with credit in the NOTICE file. Thank you joaomf and kkossev.

Post bugs and questions here or as a GitHub issue. For a wrong reading, please include the plug's firmware (the softwareBuild and firmwareMT data values) and the log lines from Configure.