off-alarm intends to monitor if a critical device has been inadverdently turned off and alert user using audible alarm. It monitors measurements from Tasmota nodes sending connected device power usage, light sensor readings, and a custom device that sends messages when a button is pressed and is able to play a tune on a piezo buzzer. These messages are sent over MQTT. off-alarm also queries InfluxDB that stores the previous light sensor and device power readings to determine whether an audible alarm should be played. Querying InfluxDB is only done when off-alarm first starts.
This project is for a very specific use case and a very specific hardware setup, and you may not find it useful as is, but there may be some useful snippets in the code if you are interested in building something similar.
Server (ts running on bun): ./src
Web frontend (statically served by server): ./frontend
Device (ESP-IDF C code for ESP32): ./device-esp32
For more information on the device, see device-esp32/README.md.
To install dependencies:
bun installConfigure environment variables in .env file. Use .env.template as a template.
To run:
bun run devbun run prodbunx cross-env USE_FAKE_SENSORS=Y bun run devSubscribes to fake sensor topics instead of topics that send real sensor data. Use with fakeSensorReadingEmittor.ts.
bun src/testSupport/fakeSensorReadingEmittor.tsTo make it emit illuminance sensor data where the room is dark:
bun src/testSupport/fakeSensorReadingEmittor.ts darkTo make it emit power use sensor data where the device is active:
bun src/testSupport/fakeSensorReadingEmittor.ts activebunx cross-env LOG_LEVEL=debug bun run devSets log level to debug, the most verbose level. The default is info.
bunx cross-env PERSIST_SENSOR_DATA=Y bun run prodPersists received sensor data to sensor.sqlite file.
(C) 2025 Hoon Choi