Examples as Arduino sketches: one folder per device type, each its own endpointId, Wi-Fi with a timeout

Light, DimmableLight, ColorTemperatureLight, ColorLight, TemperatureSensor, ContactSensor, Blind,
Thermostat, Lock, Scene, Doorbell and MultiDevice on the 2.0 API: addCapability(row, instance), one
onDirective() handler, the report helpers, ChangeReports from loop(), a deferred answer for the lock.
Wi-Fi is waited for 30 s, then the sketch says what to check and carries on.

examples/README.md has what each sketch does, its limits and the measured sizes for d1_mini: Light
takes 30,616 bytes of static RAM and 332,565 of flash; all 17 sketches build with 0 warnings.
test/test_examples compares the discovery object of every new sketch: 147 host tests (were 135).
The sketches were compiled, not run on a board.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
David 2026-09-28 21:41:51 +00:00
parent 7369883479
commit 69b4d59896
15 changed files with 2061 additions and 1 deletions

View file

@ -54,7 +54,7 @@ Then include the library in your project:
#include <Alex2ESP.h>
```
Complete sketches are in [`examples/legacy/`](examples/legacy/), one folder each: `basicLight`, `lightWithBrightness`, `lightWithColorTemp`, `tempSensor` and `blindControl`. Every example joins Wi-Fi with `WiFi.begin(WIFI_SSID, WIFI_PASSWORD)`; fill in the SSID, the password and your Alex2MQTT credentials before flashing.
Complete sketches are in [`examples/`](examples/), one folder per kind of device: `Light`, `DimmableLight`, `ColorTemperatureLight`, `ColorLight`, `TemperatureSensor`, `ContactSensor`, `Blind`, `Thermostat`, `Lock`, `Scene`, `Doorbell` and `MultiDevice`; [`examples/README.md`](examples/README.md) says what each does and what it takes of RAM and flash. The examples of 1.x are in [`examples/legacy/`](examples/legacy/). Every example joins Wi-Fi with `WiFi.begin(WIFI_SSID, WIFI_PASSWORD)`; fill in the SSID, the password and your Alex2MQTT credentials before flashing.
---