esphome / esphome/feature-requests
Intergrate C runtime interpreter for dynamic lambdas
- Dominant language
- No language data
- Stars
- 450
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the problem you have/What new integration you would like**
Integrate C-based interpreter, like https://github.com/jingoro2112/wrench
**Please describe your use case for this integration and alternatives you've tried:**
I want to make HA and ESPHome automations more "transactional". Now it’s more convenient for me to configure sequential commands through HA automation YAML, but this method is not resistant to communication problems between ESP32 and HA.
Using lambdas requires recompiling the config, which is inconvenient for regular updates
**Additional context**
https://home.workshopfriends.com/wrench/www
A full-featured compiler+interpreter that uses a bare minimum of ram and program space.
How little? The wrench Virtual Machine compiles to ~28k on an Arduino, and
uses less than 700 Bytes of RAM to operate, it is fully functional on an Uno Mini.
Highlights:
- Weakly typed, supporting native 32-bit int, float and string.
Code is easy to write with familiar c-syntax
- Optimizing compiler and very fast VM
- Produces very compact endian-neutral bytecode: compile-anywhere-run-anywhere.
- Can execute from ROM, no local copy of the code is made
- Multiple concurrent contexts supported
- Code is easy to write, imagine c with the typenames removed; that's pretty much it.
- Supports everything a good interpreter should: if/then/else/do/while/for/switch/functions/operators/etc..
- Yes structs too
- Yes switch (and NO it's not if-else sugar)
- Can operate directly on data and exposes all static values to be manipulated externally and directly.
- Can call back and forth to native code with minimal overhead
- API is designed to be easily extended, that's the whole point!
- Memory is garbage-collected but only for dynamic arrays. Unless you are allocating/de-allocating arrays the gc _never_ runs.
- Includes a handy command-line tool
Also, https://github.com/esphome/feature-requests/issues/805 (conditions, loops, expressions) https://github.com/esphome/feature-requests/issues/1840 (changing at runtime)
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the proposed Wrench interpreter and the related feature requests about conditions, loops, expressions, and runtime changes. Define the integration scope around executing dynamic lambdas on ESPHome devices without recompiling configuration, including the stated Home Assistant and ESP32 communication use case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100