lua_runtime now loads the running script from a new LittleFS-backed
drivers::storage (joltwallet/littlefs, the project's fifth external
managed component -- mounts the "storage" partition already reserved
in partitions.csv), falling back to the compiled-in default script
only on first boot. transport exposes GET/POST /api/script -- raw Lua
text, not JSON, since json_helpers.h can't round-trip scripts safely
-- relayed to lua_runtime via the same callback-registration pattern
already used for LedColorHandler, keeping transport free of a
dependency on lua_runtime. lua_runtime_reload() persists and hot-swaps
to a fresh Lua state immediately, no reboot.
Verified on real ESP32-C6 hardware: script loads via kvida-sdk, an
edited script hot-reloads within one tick, and the edit survives a
power cycle (proving LittleFS persistence, not just an in-RAM change).
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sandboxed Lua state (espressif/lua v5.5.0, base/table/string/math only,
no io/os/package/debug) exposes a kvida API table (chip_temperature,
set_led, publish) to a compiled-in default script that reads chip
temperature, maps it to an LED color, and publishes the reading to
Home Assistant. Generalizes transport's publish_chip_temperature()
into publish_value(name, value), the first real use of AGENTS.md's
semantic publish API. Requires -DLUA_32BITS globally since this
toolchain's long long support isn't visible to Lua's default build.
Verified on real ESP32-C6 hardware: no crashes/errors across multiple
serial monitor windows, LED changes color, chip_temperature sensor
appears in Home Assistant via MQTT Discovery.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Quick end-to-end data-flow proof using only what's on the ESP32-C6-
DevKitC-1 itself (no sensors on the bare devkit -- confirmed via
research: BOOT button, WS2812 LED, no external sensors):
- drivers::chip_temperature_* wraps ESP-IDF's built-in
temperature_sensor driver (SoC die temperature).
- drivers::rgb_led_* wraps the onboard WS2812 (GPIO8) via the
espressif/led_strip managed component (another external registry
dependency, like mdns/mqtt).
- profiles::ChipTemperatureSensor is the first real implementation of
the Sensor interface designed earlier, converting the driver's float
reading to the fixed-point convention once at the boundary.
- transport/mqtt.cpp publishes chip temperature as an HA "temperature"
sensor every 30s, and exposes the LED as an HA "light" entity
(rgb_command_topic) -- the first use of MQTT subscribe in this
project, not just publish.
Added a ChipTemperature SensorChannel (distinct from
AmbientTemperature -- different meaning/range) to sensor.h.
Verified live: both the chip temperature reading and LED color control
work from Home Assistant against the real device.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds espressif/mqtt and mdns as the project's first external managed
component dependencies (neither ships with ESP-IDF core in v6.0.2
anymore). Once Wi-Fi connects, the device advertises itself on the LAN
as kvida-xxxxxx.local and serves a persistent settings page there for
MQTT broker host/port and credentials -- the ongoing config channel
beyond the one-time Wi-Fi captive portal.
mDNS auto-discovery of _mqtt._tcp was the original plan, but verified
against a real Home Assistant OS + Mosquitto add-on that it doesn't
reliably answer PTR queries on the LAN (confirmed with a raw mDNS
query from the host, parsed properly with dnspython after an earlier
naive byte-check gave a false positive). Manual host/port entry is
now the primary path; mDNS discovery still runs as a secondary
fallback attempt, retried every 30s, in case it works on other
networks.
On MQTT_EVENT_CONNECTED, publishes retained HA MQTT Discovery for a
diagnostic "connectivity" binary_sensor (grouped under a Kvida/Xylon
device block) plus an online/offline availability topic driven by
MQTT's own LWT. Verified end-to-end on real hardware: the device
appears in Home Assistant with a "Connected" Connectivity sensor.
Also extracts url_decode() (previously local to commissioning.cpp)
and a new device_id() helper into shared headers, since both
commissioning's Wi-Fi form and the new MQTT settings form need them.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>