Giter Club home page Giter Club logo

Comments (5)

alhirzel avatar alhirzel commented on July 17, 2024 1

I see that you've resolved this issue, thank you! I wanted to offer some thoughts in case they're useful in the future, particularly in response to your question "is there another way". Thank you for your work on this wonderful library!

You could pass a lambda to the constructor so that, only at construction time, the three methods can be called? These methods could then be made into no-ops after construction via some internal flag bool constructed. Or the lambda passed to the constructor could be initializer(add_state_lambda, add_input_lambda, add_transition_lambda) and this could be used to pass private methods indirectly (washing them of privateness via lambda indirection).

from esphome-state-machine.

muxa avatar muxa commented on July 17, 2024

Managed to capture the stack trace:

[08:00:31][D][sensor:126]: 'Garage Switch Debug Uptime': Sending state 0.00000 days with 1 decimals of accuracy
[08:00:31][D][cover:170]: 'Garage Door' - Pub
[08:00:31]User exception (panic/abort/assert)
[08:00:31]--------------- CUT HERE FOR EXCEPTION DECODER ---------------
[08:00:31]
[08:00:31]Panic core_esp8266_main.cpp:215 loop_task
[08:00:31]
[08:00:31]>>>stack>>>
WARNING Found stack trace! Trying to decode it
[08:00:31]
[08:00:31]ctx: sys
[08:00:31]sp: 3fffeee0 end: 3fffffb0 offset: 0000
[08:00:31]3fffeee0:  000000aa 0000a233 4025c4db 3ffe9d34  
WARNING Decoded 0x4025c4db: pp_enable_noise_timer
[08:00:31]3fffeef0:  000000fe 00000000 00000000 00000000  
[08:00:31]3fffef00:  00000000 00000000 00000000 3ffefb08  
[08:00:31]3fffef10:  80000000 3fffd9d0 3ffef0f0 3ffefac0  
[08:00:31]3fffef20:  3fffdad0 00000000 3ffe8610 4022c61a  
WARNING Decoded 0x4022c61a: raise_exception at core_esp8266_postmortem.cpp
[08:00:31]3fffef30:  402611ea 3fffdab0 00000000 4022c687  
WARNING Decoded 0x402611ea: ets_timer_handler_isr
WARNING Decoded 0x4022c687: __panic_func
[08:00:31]3fffef40:  00000000 3fffdad0 3ffefac0 4022bfc4  
WARNING Decoded 0x4022bfc4: loop_task(ETSEventTag*) at core_esp8266_main.cpp
[08:00:31]3fffef50:  40000f49 40000f65 3fffdab0 40000f49  
[08:00:32]3fffef60:  40000e19 0007a1ad 00000000 00000005  
[08:00:32]3fffef70:  00000000 aa55aa55 000000f7 40105779  
WARNING Decoded 0x40105779: call_user_start_local
[08:00:32]3fffef80:  4010577f 00000000 00000005 40100eb0  
WARNING Decoded 0x4010577f: call_user_start_local
WARNING Decoded 0x40100eb0: umm_init
[08:00:32]3fffef90:  4010000d 400fedef 0007a1ad 401000ac  
WARNING Decoded 0x4010000d: call_user_start
WARNING Decoded 0x401000ac: app_entry_redefinable
[08:00:32]3fffefa0:  40251800 3fffef3c 402517b1 3ffff2d8  
WARNING Decoded 0x40251800: cont_ret at cont.S.o
WARNING Decoded 0x402517b1: cont_continue at cont.S.o
[08:00:32]3fffefb0:  3fffffc0 00000000 00000000 3ffe8368  
[08:00:32]3fffefc0:  40236bc1 0000001c 00000020 40100f00  
WARNING Decoded 0x40236bc1: _Balloc at /workdir/repo/newlib/newlib/libc/stdlib/mprec.c:128
WARNING Decoded 0x40100f00: malloc
[08:00:32]3fffefd0:  40101172 feefeffe 00000001 40101164  
WARNING Decoded 0x40101172: calloc
WARNING Decoded 0x40101164: calloc
[08:00:32]3fffefe0:  feefeffe 0000001c 00000001 4022cce4  
WARNING Decoded 0x4022cce4: _calloc_r
[08:00:32]3fffeff0:  00000002 00000001 3ffe8368 3ffe8368  
[08:00:32]3ffff000:  40236bc1 00000018 00000020 40100f00  
WARNING Decoded 0x40236bc1: _Balloc at /workdir/repo/newlib/newlib/libc/stdlib/mprec.c:128
WARNING Decoded 0x40100f00: malloc
[08:00:32]3ffff010:  40101172 00000007 00000001 40101164  
WARNING Decoded 0x40101172: calloc
WARNING Decoded 0x40101164: calloc
[08:00:32]3ffff020:  3ffff054 00000018 00000001 4022cce4  
WARNING Decoded 0x4022cce4: _calloc_r
[08:00:32]3ffff030:  00000001 0000638e 3ffe8368 40236bc1  
WARNING Decoded 0x40236bc1: _Balloc at /workdir/repo/newlib/newlib/libc/stdlib/mprec.c:128
[08:00:32]3ffff040:  3fff3774 00000000 00000000 402361a5  
WARNING Decoded 0x402361a5: _dtoa_r at /workdir/repo/newlib/newlib/libc/stdlib/dtoa.c:854
[08:00:32]3ffff050:  ffffffd6 00000018 0000000a 00000000  
[08:00:32]3ffff060:  fffffffa 00000000 00000000 3fff3754  
[08:00:32]3ffff070:  3a6b8000 4000638e 3fff3774 0000002a  
[08:00:32]3ffff080:  00000006 00000003 ffffffff 00000000  
[08:00:32]3ffff090:  00000006 00000005 e0000000 3ec12f5b  
[08:00:32]3ffff0a0:  00000001 00000000 0000000a 00000000  
[08:00:32]3ffff0b0:  00000001 00000000 0000000a 00000000  
[08:00:32]3ffff0c0:  00000000 00000000 3ffff260 402376e4  
WARNING Decoded 0x402376e4: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:232
[08:00:32]3ffff0d0:  00000000 a0000000 00000000 0000001c  
[08:00:32]3ffff0e0:  00000001 00000000 0000000a 00000000  
[08:00:32]3ffff0f0:  00000001 00000000 0000000a 00000000  
[08:00:32]3ffff100:  3ffff1f2 3ffff1f3 00000000 3fff3774  
[08:00:32]3ffff110:  00000000 a0000000 00000000 0000001c  
[08:00:32]3ffff120:  00001000 00000000 00001000 3ffe8368  
[08:00:32]3ffff130:  00000000 00000004 3ffff2a0 402376e4  
WARNING Decoded 0x402376e4: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:232
[08:00:32]3ffff140:  3ffff230 3ffff233 00000000 3ffff260  
[08:00:32]3ffff150:  3fff091f 00000000 402330d1 3ffe8368  
WARNING Decoded 0x402330d1: _printf_i at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf_i.c:196 (discriminator 1)
[08:00:32]3ffff160:  00000003 00000000 3ffff2a0 402376e4  
WARNING Decoded 0x402376e4: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:232
[08:00:32]3ffff170:  40237620 3ffff230 00000003 3ffe8368  
WARNING Decoded 0x40237620: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:179
[08:00:32]3ffff180:  00000000 00000000 3ffff2f0 402376e4  
WARNING Decoded 0x402376e4: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:232
[08:00:32]3ffff190:  3fff1d78 3ffff283 00000000 40233200  
WARNING Decoded 0x40233200: _printf_i at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf_i.c:246
[08:00:32]3ffff1a0:  00000003 00000000 3ffff260 3ffe8368  
[08:00:32]3ffff1b0:  0000000b 00000000 3ffff2f0 402376e4  
WARNING Decoded 0x402376e4: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:232
[08:00:32]3ffff1c0:  40237620 3fff1d78 0000000b 00000000  
WARNING Decoded 0x40237620: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:179
[08:00:32]3ffff1d0:  3ffff300 3ffff2f0 00000008 3ffff2f0  
[08:00:32]3ffff1e0:  3fff08ff 00000000 3ffff240 40233200  
WARNING Decoded 0x40233200: _printf_i at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf_i.c:246
[08:00:32]3ffff1f0:  0000000b ffffffff ffffffff 3ffe8368  
[08:00:32]3ffff200:  0000000f 00000000 3ffff2f0 402376e4  
WARNING Decoded 0x402376e4: __ssputs_r at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:232
[08:00:32]3ffff210:  3ffff3b0 3fff08ff 0000000f ffff0208  
[08:00:32]3ffff220:  3ffff3b0 3ffff3a0 00000010 3fff08ff  
[08:00:32]3ffff230:  3fff090e 00000000 3ffff2f0 402378e5  
WARNING Decoded 0x402378e5: _svfprintf_r at /workdir/repo/newlib/newlib/libc/stdio/nano-vfprintf.c:528
[08:00:32]3ffff240:  00000000 0000000b 00000000 00000000  
[08:00:32]3ffff250:  0000000b 0000001b 00302073 40234e7d  
WARNING Decoded 0x40234e7d: _vsnprintf_r at /workdir/repo/newlib/newlib/libc/stdio/vsnprintf.c:71 (discriminator 4)
[08:00:32]3ffff260:  3ffff390 3ffff380 00000008 3ffe8368  
[08:00:32]3ffff270:  00000003 00000003 3ffe94b9 4022d0f8  
WARNING Decoded 0x4022d0f8: uart_write
[08:00:32]3ffff280:  00fe94ba 3fff08b4 000001c7 3ffe8e67  
[08:00:32]3ffff290:  00000005 3ffe8368 00000000 40234e7d  
WARNING Decoded 0x40234e7d: _vsnprintf_r at /workdir/repo/newlib/newlib/libc/stdio/vsnprintf.c:71 (discriminator 4)
[08:00:32]3ffff2a0:  3ffff440 3ffff430 00000014 ffff0208  
[08:00:32]3ffff2b0:  3ffff440 3ffff430 00000010 3ffe8368  
[08:00:32]3ffff2c0:  00000000 00000000 00000001 401004b4  
WARNING Decoded 0x401004b4: ets_post
[08:00:32]3ffff2d0:  4024a95d 3fff08b4 3fff0938 00000036  
WARNING Decoded 0x4024a95d: cnx_sta_scan_cmd
[08:00:32]3ffff2e0:  00000000 fffffffc 4022c0cf 3fffefa0  
WARNING Decoded 0x4022c0cf: yield
[08:00:32]3ffff2f0:  3fff0941 3fff0ca4 000001ba 4022c114  
WARNING Decoded 0x4022c114: optimistic_yield
[08:00:32]3ffff300:  00000000 00000036 3fff0938 4022d0f8  
WARNING Decoded 0x4022d0f8: uart_write
[08:00:32]3ffff310:  3fff0945 3fff08b4 000001ed 40234eb9  
WARNING Decoded 0x40234eb9: vsnprintf at /workdir/repo/newlib/newlib/libc/stdio/vsnprintf.c:41
[08:00:32]3ffff320:  3ffff390 3ffff380 00000008 3ffe8e67  
[08:00:32]3ffff330:  40229ec4 3fff090f 3ffef8fc 40229ed0  
WARNING Decoded 0x40229ec4: HardwareSerial::write(unsigned char const*, unsigned int)
WARNING Decoded 0x40229ed0: HardwareSerial::write(unsigned char const*, unsigned int)
[08:00:32]3ffff340:  40229ec4 3fff090f 3ffef8fc 4022af8c  
WARNING Decoded 0x40229ec4: HardwareSerial::write(unsigned char const*, unsigned int)
WARNING Decoded 0x4022af8c: _ZN5Print5writeEPKc$part$0 at Print.cpp
[08:00:32]3ffff350:  00000005 3fff090f 3ffef8fc 4022afb0  
WARNING Decoded 0x4022afb0: Print::write(char const*)
[08:00:32]3ffff360:  3ffff3b0 3fff08b4 000001d6 4022b07d  
WARNING Decoded 0x4022b07d: Print::println(char const*)
[08:00:32]3ffff370:  3ffff440 3fff090f 3fff08b4 40217171  
WARNING Decoded 0x40217171: esphome::logger::Logger::log_message_(int, char const*, int)
[08:00:32]3ffff380:  3ffff3b0 3ffff3a0 3ffe8cfe 3ffe89db  
[08:00:32]3ffff390:  3ffe8e67 000000aa 00000010 40217068  
WARNING Decoded 0x40217068: esphome::logger::Logger::vprintf_to_buffer_(char const*, __va_list_tag)
[08:00:32]3ffff3a0:  3ffff440 3ffff430 00000010 3ffe8e67  
[08:00:32]3ffff3b0:  00000005 00000000 3fff08b4 40217341  
WARNING Decoded 0x40217341: esphome::logger::Logger::log_vprintf_(int, char const*, int, __FlashStringHelper const*, __va_list_tag)
[08:00:32]3ffff3c0:  00000013 000000aa 3fff1b24 40218df4  
WARNING Decoded 0x40218df4: esphome::sensor::Sensor::internal_send_state_to_frontend(float)
[08:00:33]3ffff3d0:  e0000000 3ec12f5b 3ffff3e8 3f800000  
[08:00:33]3ffff3e0:  00000000 3ffe8e67 3fff1d6c 402200f8  
WARNING Decoded 0x402200f8: esphome::esp_log_vprintf_(int, char const*, int, __FlashStringHelper const*, __va_list_tag)
[08:00:33]3ffff3f0:  3ffff440 3ffff430 00000010 4023909c  
WARNING Decoded 0x4023909c: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_copy(char*, char const*, unsigned int) at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h:354
[08:00:33]3ffff400:  000004a5 000004a5 3ffe8614 40220124  
WARNING Decoded 0x40220124: esphome::esp_log_printf_(int, char const*, int, __FlashStringHelper const*, ...)
[08:00:33]3ffff410:  3ffff440 3ffff430 00000010 402397ac  
WARNING Decoded 0x402397ac: void std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct<char*>(char*, char*, std::forward_iterator_tag) at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc:234
[08:00:33]3ffff420:  3ffff440 3ffff430 00000010 40239756  
WARNING Decoded 0x40239756: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(char const*) const at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc:1430
[08:00:33]3ffff430:  3ffe8a96 00000001 3fff1d6c 402397e1  
WARNING Decoded 0x402397e1: std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) at /workdir/arena.x86_64/gcc-gnu/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h:453
[08:00:33]3ffff440:  3fff1d78 00000000 3fff1d6c 40220df4  
WARNING Decoded 0x40220df4: std::_Function_handler<esphome::optional<float> (), setup::{lambda()#4}>::_M_invoke(std::_Any_data const&) at main.cpp
[08:00:33]3ffff450:  3ffff401 00000000 534f4c43 402130b1  
WARNING Decoded 0x402130b1: esphome::cover::Cover::publish_state(bool)
[08:00:33]3ffff460:  40263c3b 4bc6a7f0 c1cac083 00000102  
WARNING Decoded 0x40263c3b: wifi_station_get_connect_status
[08:00:33]3ffff470:  00000001 00000001 3fff1d6c 401000e9  
WARNING Decoded 0x401000e9: std::function<esphome::optional<float> ()>::operator()() const
[08:00:33]3ffff480:  3ffff401 00000000 401005c9 3f800000  
WARNING Decoded 0x401005c9: millis
[08:00:33]3ffff490:  00000000 00000001 3fff1d6c 4021a99d  
WARNING Decoded 0x4021a99d: esphome::template_::TemplateCover::loop()
[08:00:33]3ffff4a0:  3ffff401 00000000 3ffe8614 00000102  
[08:00:33]3ffff4b0:  3fff0c64 00000015 3fff0c64 00000102  
[08:00:33]3ffff4c0:  3fff0c64 00000015 3ffef57c 4021a9bb  
WARNING Decoded 0x4021a9bb: non-virtual thunk to esphome::template_::TemplateCover::loop()
[08:00:33]3ffff4d0:  3fff0c64 00000015 3ffef57c 4022f554  
WARNING Decoded 0x4022f554: esphome::Component::call_loop()
[08:00:33]3ffff4e0:  3fff1cbc 3ffff500 00000016 4022f620  
WARNING Decoded 0x4022f620: esphome::Component::call()
[08:00:33]3ffff4f0:  3fff0c64 00000015 3ffef57c 4021f411  
WARNING Decoded 0x4021f411: esphome::Application::setup()
[08:00:33]3ffff500:  00000016 00000016 3fff36b4 40239878  
WARNING Decoded 0x40239878: operator delete(void*) at /workdir/repo/gcc-gnu/libstdc++-v3/libsupc++/del_op.cc:50
[08:00:33]3ffff510:  00000058 00000034 0000000d 4021e34e  
WARNING Decoded 0x4021e34e: esphome::Application::register_component_(esphome::Component*)
[08:00:33]3ffff520:  3fff29b4 00444554 3fffff54 3fff289c  
[08:00:33]3ffff530:  3fff284c 00000000 3ffef650 402247e7  
WARNING Decoded 0x402247e7: setup
[08:00:33]3ffff540:  3fff285c 3fff2860 3fff2860 0054554f  
[08:00:33]3ffff550:  43455445 00444554 3ffff560 00000005 <
[08:00:33]3ffff560:  53455250 feef0053 feefeffe feefeffe  
[08:00:33]3ffff570:  3ffff578 00000007 4e45504f 00474e49  
[08:00:33]3ffff580:  feefeffe feefeffe 3ffff590 00000007 <
[08:00:33]3ffff590:  4e45504f 00474e49 feefeffe feefeffe  
[08:00:33]3ffff5a0:  3ffff5a8 00000005 53455250 feef0053  
[08:00:33]3ffff5b0:  feefeffe feefeffe 3fff1e54 00000013  
[08:00:33]3ffff5c0:  00000013 feefeffe feefeffe feefeffe  
[08:00:33]3ffff5d0:  3fff1e6c 00000013 00000013 feefeffe  
[08:00:33]3ffff5e0:  feefeffe feefeffe 3ffff5f0 00000005 <
[08:00:33]3ffff5f0:  53455250 feef0053 feefeffe feefeffe  
[08:00:33]3ffff600:  3ffff608 00000007 534f4c43 00474e49  
[08:00:33]3ffff610:  feefeffe feefeffe 3ffff620 00000004 <
[08:00:33]3ffff620:  4e45504f feefef00 feefeffe feefeffe  
[08:00:33]3ffff630:  3ffff638 00000005 53455250 feef0053  
[08:00:33]3ffff640:  feefeffe feefeffe 3ffff650 00000007 <
[08:00:33]3ffff650:  534f4c43 00474e49 feefeffe feefeffe  
[08:00:33]3ffff660:  3ffff668 00000007 534f4c43 00474e49  
[08:00:33]3ffff670:  feefeffe feefeffe 3ffff680 00000005 <
[08:00:33]3ffff680:  53455250 feef0053 feefeffe feefeffe  
[08:00:33]3ffff690:  3fff1e84 00000013 00000013 feefeffe  
[08:00:33]3ffff6a0:  feefeffe feefeffe 3fff1e9c 00000013  
[08:00:33]3ffff6b0:  00000013 feefeffe feefeffe feefeffe  
[08:00:33]3ffff6c0:  3ffff6c8 00000005 53455250 feef0053  
[08:00:33]3ffff6d0:  feefeffe feefeffe 3ffff6e0 00000007 <
[08:00:33]3ffff6e0:  4e45504f 00474e49 feefeffe feefeffe  
[08:00:33]3ffff6f0:  3ffff6f8 00000007 4e45504f 00474e49  
[08:00:33]3ffff700:  feefeffe feefeffe 3ffff710 00000007 <
[08:00:33]3ffff710:  454d4954 0054554f feefeffe feefeffe  
[08:00:33]3ffff720:  3ffff728 00000004 4e45504f feefef00  
[08:00:33]3ffff730:  feefeffe feefeffe 3ffff740 00000007 <
[08:00:33]3ffff740:  534f4c43 00474e49 feefeffe feefeffe  
[08:00:33]3ffff750:  3ffff758 00000007 454d4954 0054554f  
[08:00:33]3ffff760:  feefeffe feefeffe 3ffff770 00000006 <
[08:00:33]3ffff770:  534f4c43 fe004445 feefeffe feefeffe  
[08:00:33]3ffff780:  3ffff788 00000006 534f4c43 fe004445  
[08:00:33]3ffff790:  feefeffe feefeffe 3fff1eb4 00000010  
[08:00:33]3ffff7a0:  00000010 feefeffe feefeffe feefeffe  
[08:00:33]3ffff7b0:  3ffff7b8 00000007 4e45504f 00474e49  
[08:00:33]3ffff7c0:  feefeffe feefeffe 3ffff7d0 00000007 <
[08:00:33]3ffff7d0:  534f4c43 00474e49 feefeffe feefeffe  
[08:00:33]3ffff7e0:  3fff1ecc 00000010 00000010 feefeffe  
[08:00:33]3ffff7f0:  feefeffe feefeffe 3ffff800 00000007 <
[08:00:33]3ffff800:  4e45504f 00474e49 feefeffe feefeffe  
[08:00:33]3ffff810:  3fff1ee4 00000013 00000013 feefeffe  
[08:00:33]3ffff820:  feefeffe feefeffe 3fff1efc 00000010  
[08:00:33]3ffff830:  00000010 feefeffe feefeffe feefeffe  
[08:00:33]3ffff840:  3ffff848 00000007 4e45504f 00474e49  
[08:00:33]3ffff850:  feefeffe feefeffe 3fff1f14 00000013  
[08:00:33]3ffff860:  00000013 feefeffe feefeffe feefeffe  
[08:00:33]3ffff870:  3fff1f2c 00000010 00000010 feefeffe  
[08:00:33]3ffff880:  feefeffe feefeffe 3ffff890 00000007 <
[08:00:33]3ffff890:  4e45504f 00474e49 feefeffe feefeffe  
[08:00:33]3ffff8a0:  3ffff8a8 00000007 534f4c43 00474e49  
[08:00:33]3ffff8b0:  feefeffe feefeffe 3ffff8c0 0000000f <
[08:00:33]3ffff8c0:  534f4c43 445f4445 43455445 00444554  
[08:00:33]3ffff8d0:  3ffff8d8 00000006 534f4c43 fe004445  
[08:00:33]3ffff8e0:  feefeffe feefeffe 3ffff8f0 00000004 <
[08:00:33]3ffff8f0:  4e45504f feefef00 feefeffe feefeffe  
[08:00:33]3ffff900:  3ffff908 0000000f 534f4c43 445f4445  
[08:00:33]3ffff910:  43455445 00444554 3ffff920 00000006 <
[08:00:33]3ffff920:  534f4c43 fe004445 feefeffe feefeffe  
[08:00:33]3ffff930:  3ffff938 00000007 4e45504f 00474e49  
[08:00:33]3ffff940:  feefeffe feefeffe 3ffff950 0000000f <
[08:00:33]3ffff950:  534f4c43 445f4445 43455445 00444554  
[08:00:33]3ffff960:  3ffff968 00000006 534f4c43 fe004445  
[08:00:33]3ffff970:  feefeffe feefeffe 3fff1f44 00000013  
[08:00:33]3ffff980:  00000013 feefeffe feefeffe feefeffe  
[08:00:33]3ffff990:  3ffff998 0000000f 534f4c43 445f4445  
[08:00:33]3ffff9a0:  43455445 00444554 3ffff9b0 00000006 <
[08:00:33]3ffff9b0:  534f4c43 fe004445 feefeffe feefeffe  
[08:00:33]3ffff9c0:  3fff1f5c 00000013 00000013 feefeffe  
[08:00:33]3ffff9d0:  feefeffe feefeffe 3ffff9e0 0000000f <
[08:00:33]3ffff9e0:  534f4c43 445f4445 43455445 00444554  
[08:00:33]3ffff9f0:  3ffff9f8 00000006 534f4c43 fe004445  
[08:00:33]3ffffa00:  feefeffe feefeffe 3ffffa10 00000006 <
[08:00:33]3ffffa10:  534f4c43 fe004445 feefeffe feefeffe  
[08:00:33]3ffffa20:  3ffffa28 00000004 4e45504f feefef00  
[08:00:33]3ffffa30:  feefeffe feefeffe 3ffffa40 00000007 <
[08:00:33]3ffffa40:  4e45504f 00474e49 feefeffe feefeffe  
[08:00:33]3ffffa50:  3ffffa58 00000007 534f4c43 00474e49  
[08:00:33]3ffffa60:  feefeffe feefeffe 3ffffa70 00000004 <
[08:00:33]3ffffa70:  4e45504f feefef00 feefeffe feefeffe  
[08:00:33]3ffffa80:  3fff1f74 00000013 00000013 feefeffe  
[08:00:33]3ffffa90:  feefeffe feefeffe 3fff1f8c 00000013  
[08:00:33]3ffffaa0:  00000013 feefeffe feefeffe feefeffe  
[08:00:33]3ffffab0:  3ffffab8 00000004 4e45504f feefef00  
[08:00:33]3ffffac0:  feefeffe feefeffe 3ffffad0 00000007 <
[08:00:33]3ffffad0:  4e45504f 00474e49 feefeffe feefeffe  
[08:00:33]3ffffae0:  3fff1fa4 00000013 00000013 feefeffe  
[08:00:33]3ffffaf0:  feefeffe feefeffe 3ffffb00 00000004 <
[08:00:33]3ffffb00:  4e45504f feefef00 feefeffe feefeffe  
[08:00:33]3ffffb10:  3ffffb18 00000007 534f4c43 00474e49  
[08:00:33]3ffffb20:  feefeffe feefeffe 3ffffb30 00000004 <
[08:00:33]3ffffb30:  4e45504f feefef00 feefeffe feefeffe  
[08:00:33]3ffffb40:  3ffffb48 00000005 534f4c43 feef0045  
[08:00:33]3ffffb50:  feefeffe feefeffe 3ffffb60 00000007 <
[08:00:33]3ffffb60:  534f4c43 00474e49 feefeffe feefeffe  
[08:00:33]3ffffb70:  3ffffb78 00000007 4e45504f 00474e49  
[08:00:33]3ffffb80:  feefeffe feefeffe 3ffffb90 00000005 <
[08:00:33]3ffffb90:  534f4c43 feef0045 feefeffe feefeffe  
[08:00:33]3ffffba0:  3fff1fbc 00000013 00000013 feefeffe  
[08:00:33]3ffffbb0:  feefeffe feefeffe 3fff1fd4 00000013  
[08:00:33]3ffffbc0:  00000013 feefeffe feefeffe feefeffe  
[08:00:33]3ffffbd0:  3ffffbd8 00000005 534f4c43 feef0045  
[08:00:33]3ffffbe0:  feefeffe feefeffe 3ffffbf0 00000007 <
[08:00:33]3ffffbf0:  534f4c43 00474e49 feefeffe feefeffe  
[08:00:33]3ffffc00:  3fff1fec 00000013 00000013 feefeffe  
[08:00:33]3ffffc10:  feefeffe feefeffe 3ffffc20 00000005 <
[08:00:33]3ffffc20:  534f4c43 feef0045 feefeffe feefeffe  
[08:00:33]3ffffc30:  3ffffc38 00000007 4e45504f 00474e49  
[08:00:33]3ffffc40:  feefeffe feefeffe 3ffffc50 00000007 <
[08:00:33]3ffffc50:  4e45504f 00474e49 feefeffe feefeffe  
[08:00:34]3ffffc60:  3ffffc68 00000004 504f5453 feefef00  
[08:00:34]3ffffc70:  feefeffe feefeffe 3fff2004 00000013  
[08:00:34]3ffffc80:  00000013 feefeffe feefeffe feefeffe  
[08:00:34]3ffffc90:  3ffffc98 00000007 534f4c43 00474e49  
[08:00:34]3ffffca0:  feefeffe feefeffe 3ffffcb0 00000004 <
[08:00:34]3ffffcb0:  504f5453 feefef00 feefeffe feefeffe  
[08:00:34]3ffffcc0:  3fff201c 00000013 00000013 feefeffe  
[08:00:34]3ffffcd0:  feefeffe feefeffe 3fffff54 00000001  
[08:00:34]3ffffce0:  3fff281c c65b0053 5a7e21ac cc9451d1  
[08:00:34]3ffffcf0:  3ffffcf8 00000007 454d4954 0054554f  
[08:00:34]3ffffd00:  feefeffe feefeffe 3fff1d74 00000010  
[08:00:34]3ffffd10:  00000010 feefeffe feefeffe feefeffe  
[08:00:34]3ffffd20:  3ffffd28 0000000f 534f4c43 445f4445  
[08:00:34]3ffffd30:  43455445 00444554 3ffffd40 00000004 <
[08:00:34]3ffffd40:  4e45504f feefef00 feefeffe feefeffe  
[08:00:34]3ffffd50:  3ffffd58 00000005 534f4c43 feef0045  
[08:00:34]3ffffd60:  feefeffe feefeffe 3ffffd70 00000004 <
[08:00:34]3ffffd70:  504f5453 feefef00 feefeffe feefeffe  
[08:00:34]3ffffd80:  3ffffcd8 00000003 534f4c43 fe004445  
[08:00:34]3ffffd90:  feefeffe feefeffe 3ffffda0 00000007 <
[08:00:34]3ffffda0:  4e45504f 00474e49 feefeffe feefeffe  
[08:00:34]3ffffdb0:  3ffffdb8 00000004 4e45504f feefef00  
[08:00:34]3ffffdc0:  feefeffe feefeffe 3fff1a4c 00000013  
[08:00:34]3ffffdd0:  00000013 feefeffe feefeffe feefeffe  
[08:00:34]3ffffde0:  3ffffde8 00000007 534f4c43 00474e49  
[08:00:34]3ffffdf0:  feefeffe feefeffe 3fff13c4 00000013  
[08:00:34]3ffffe00:  00000013 feefeffe feefeffe feefeffe  
[08:00:34]3ffffe10:  3ffffe18 00000006 6e2e646d fe00746f  
[08:00:34]3ffffe20:  feefeffe feefeffe feefef00 00000000  
[08:00:34]3ffffe30:  3ffffe38 0000000f 687a6f70 69756c61  
[08:00:34]3ffffe40:  20617473 00746f6e 00000000 00000000  
[08:00:34]3ffffe50:  00000000 00000000 00000000 00000000  
[08:00:34]3ffffe60:  00000000 00000000 f6432b4e 31ecf15e  
[08:00:34]3ffffe70:  9fa2a50f c65b618f 5a7e21ac cc9451d1  
[08:00:34]3ffffe80:  101695e9 bfa6e0c6 3ffffcd8 00000002  
[08:00:34]3ffffe90:  534f4c43 fe004445 feefeffe feefeffe  
[08:00:34]3ffffea0:  3ffffcd8 00000001 3fff27cc 3ffffcd8  
[08:00:34]3ffffeb0:  00000001 3fff1e34 3ffffcd8 00000003  
[08:00:34]3ffffec0:  3fff1d6c 3ffffcd8 00000001 3ffffcd8  
[08:00:34]3ffffed0:  00000001 feefeffe feefeffe 3ffffd80  
[08:00:34]3ffffee0:  00000001 3ffffcd8 00000002 3ffffcd8  
[08:00:34]3ffffef0:  00000001 3ffffcd8 00000001 3ffffcd8  
[08:00:34]3fffff00:  00000003 3ffffcd8 00000001 3ffffcd8  
[08:00:34]3fffff10:  00000002 3ffffcd8 00000001 3ffffcd8  
[08:00:34]3fffff20:  00000003 3ffffcd8 00000002 3ffffcd8  
[08:00:34]3fffff30:  00000003 3ffffcd8 00000001 3ffffcd8  
[08:00:34]3fffff40:  00000007 3ffffd80 00000006 3ffffcd8  
[08:00:34]3fffff50:  00000002 3fff289c feefeffe feefeffe  
[08:00:34]3fffff60:  3f800000 3fff2154 00000002 00000003  
[08:00:34]3fffff70:  00000001 3ffffe40 3ffffcd8 3ffffc40  
[08:00:34]3fffff80:  feefeffe feefeffe feefeffe feefeffe  
[08:00:34]3fffff90:  feefeffe feefeffe feefeffe 3ffefac0  
[08:00:34]3fffffa0:  3fffdad0 00000000 3ffefaac 4022c154  
WARNING Decoded 0x4022c154: loop_wrapper() at core_esp8266_main.cpp
[08:00:34]<<<stack<<<
[08:00:34]
[08:00:34]--------------- CUT HERE FOR EXCEPTION DECODER ---------------
[08:00:34]
[08:00:34] ets Jan  8 2013,rst cause:1, boot mode:(3,6)
[08:00:34]
[08:00:34]load 0x4010f000, len 3460, room 16 
[08:00:34]tail 4
[08:00:34]chksum 0xcc
[08:00:34]load 0x3fff20b8, len 40, room 4 
[08:00:34]tail 4
[08:00:34]chksum 0xc9
[08:00:34]csum 0xc9
[08:00:34]v0007a1b0
[08:00:34]~ld

from esphome-state-machine.

muxa avatar muxa commented on July 17, 2024

Config that's causing the error above:

substitutions:
  room: Garage
  device_name: Garage Switch Debug
  
esphome:
  name: garage-switch-debug
  platform: ESP8266
  board: esp01_1m

# esp8266:
#   board: esp01_1m
#   framework:
#     version: 2.7.4

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  fast_connect: true
    
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  # ap:
  #   ssid: "Garage-Switch"
  #   password: !secret ap_password

# captive_portal:

# Enable logging
logger:
  level: DEBUG

# Enable Home Assistant API
api:
  # password: !secret api_password
  encryption: 
    key: !secret api_encryption_key

ota:
  password: !secret ota_password

# mqtt:
#   broker: !secret mqtt_broker
#   username: !secret mqtt_username
#   password: !secret mqtt_password
#   discovery: false

external_components:
  # - source:
  #     type: git
  #     url: https://github.com/muxa/esphome-state-machine
  - source: ./components

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO13
      mode: INPUT_PULLUP
      inverted: True
    name: "${device_name} Button 1"
    internal: true
    on_press:
      - light.toggle: light1
  - platform: gpio
    pin:
      number: GPIO12
      mode: INPUT_PULLUP
      inverted: True
    name: "${device_name} Button 2"
    internal: true
    on_multi_click:
      - timing:
          - ON for at least 500ms
        then:
          - logger.log: "- Garage door button held over 1s"
          - switch.turn_on: garage_opener_relay
          # line below crashes ESP
          - state_machine.transition: PRESS
  - platform: status
    id: status_sensor
    internal: true
    name: "${device_name} API Status"
    on_press: # connected
      - logger.log: "CONNECTED"
      - delay: 1s
      - if:
          condition:
            binary_sensor.is_on: closed_endstop
          then: # open
            - logger.log: Garage door is open according to endstop
            - if:
                condition:
                  - state_machine.state: CLOSED
                then:
                  - state_machine.set: OPEN
          else: # closed
            - state_machine.set: CLOSED

    on_release: # disconnected
      - logger.log: "DISCONNECTED"
  - platform: homeassistant
    name: "Garage Door Contact"
    internal: true
    id: closed_endstop
    entity_id: binary_sensor.garage_door_sensor_contact
    on_press: # garage is open(ing)      
      - state_machine.transition: OPENING_DETECTED
    on_release: # garage is closed
      - state_machine.transition: CLOSED_DETECTED
  - platform: template
    name: "Garage Door Obstruction"
    device_class: problem # on means problem detected, off means no problem (OK)
    lambda: |-
      auto current_state = id(garage_sm).current_state();
      return current_state.compare("CLOSING_INTERRUPTED") == 0
        || current_state.compare("OPENING_INTERRUPTED") == 0;
    filters:
      delayed_on: 2s

light:
  - platform: binary
    name: "Garage Light"
    id: light1
    output: light_output

output:
  - id: light_output
    platform: gpio
    pin: GPIO2

switch:
  # - platform: gpio
  #   name: "Garage Light"
  #   pin: GPIO13 #D7
  #   id: load1
  - platform: gpio
    name: "Garage Door Switch"
    pin: GPIO2
    id: garage_opener_relay
    internal: true
    icon: "mdi:garage"
    on_turn_on:
      - delay: 200ms
      - switch.turn_off: garage_opener_relay

status_led:
  pin:
    number: GPIO2 #D4
    inverted: yes

sensor:
  - platform: wifi_signal
    name: "${device_name} WiFi Signal"
    update_interval: 60s

  - platform: uptime
    name: "${device_name} Uptime"
    filters:
      - lambda: return x / 86400.0;
    unit_of_measurement: "days"
    accuracy_decimals: 1

# text_sensor:
#   - platform: state_machine
#     name: Garage Door State

state_machine:
  - name: Garage Door State Machine
    id: garage_sm
    states:
      - name: CLOSED
        on_enter:
          - cover.template.publish:
              id: garage_door
              state: CLOSED
              current_operation: IDLE
      - name: OPENING
        on_enter:
          - cover.template.publish:
              id: garage_door
              state: OPEN
              current_operation: OPENING
          - delay: 16s
          - state_machine.transition: TIMEOUT
      - name: OPEN
        on_enter:
          - cover.template.publish:
              id: garage_door
              state: OPEN
              current_operation: IDLE
      - name: OPENING_INTERRUPTED
        on_enter:
          - cover.template.publish:
              id: garage_door
              state: OPEN
              current_operation: IDLE
      - name: CLOSING
        on_enter:
          - cover.template.publish:
              id: garage_door
              state: OPEN
              current_operation: CLOSING
          - delay: 17s
          - state_machine.transition: TIMEOUT
      - name: CLOSING_INTERRUPTED
        on_enter:
          - cover.template.publish:
              id: garage_door
              state: OPEN
              current_operation: IDLE
    inputs:
      - name: PRESS
        transitions:
          - CLOSED -> OPENING
          - OPENING -> OPENING_INTERRUPTED
          - OPENING_INTERRUPTED -> CLOSING
          - OPEN -> CLOSING
          - CLOSING -> CLOSING_INTERRUPTED
          - CLOSING_INTERRUPTED -> OPENING
      - name: TIMEOUT
        transitions:
          - OPENING -> OPEN
          - CLOSING -> CLOSED
      - name: OPENING_DETECTED
        transitions:
          - CLOSED -> OPENING
          # below is a fallback so that contact sensor can override "normal" transitions
          - CLOSING -> OPENING
          - OPENING_INTERRUPTED -> OPENING
          - CLOSING_INTERRUPTED -> OPENING
      - name: CLOSED_DETECTED
        transitions:
          - CLOSING -> CLOSED
          # below is a fallback so that contact sensor can override "normal" transitions
          - OPEN -> CLOSED
          - OPENING -> CLOSED
          - OPENING_INTERRUPTED -> CLOSED
          - CLOSING_INTERRUPTED -> CLOSED
      - name: OPEN
        transitions:
          - CLOSED -> OPENING
          - CLOSING -> CLOSING_INTERRUPTED
          - CLOSING_INTERRUPTED -> OPENING
          - OPENING_INTERRUPTED -> CLOSING
        on_input:
          - switch.turn_on: garage_opener_relay
          - delay: 1500ms
          - state_machine.transition: OPEN
      - name: CLOSE
        transitions:
          - OPEN -> CLOSING
          - OPENING -> OPENING_INTERRUPTED          
          - OPENING_INTERRUPTED -> CLOSING
          - CLOSING_INTERRUPTED -> OPENING
        on_input:
          - switch.turn_on: garage_opener_relay
          - delay: 1500ms
          - state_machine.transition: CLOSE
      - name: STOP
        transitions:
          - OPENING -> OPENING_INTERRUPTED
          - CLOSING -> CLOSING_INTERRUPTED
        on_input:
          #- logger.log: "Stop"
          - switch.turn_on: garage_opener_relay
#    diagram: mermaid

cover:
  - platform: template
    name: "Garage Door"
    id: garage_door
    device_class: garage
    lambda: |-
      if (id(garage_sm).current_state().compare("CLOSED") == 0) {
        return COVER_CLOSED;
      } else {
        return COVER_OPEN;
      }
    open_action: 
      - logger.log: "Garage door is being opened by HA"
      - state_machine.transition: OPEN
    close_action:
      - logger.log: "Garage door is being closed by HA"
      - state_machine.transition: CLOSE
    stop_action:
      - logger.log: "Garage door is stopped by HA"
      - state_machine.transition: STOP

from esphome-state-machine.

muxa avatar muxa commented on July 17, 2024

If I remove/comment out any of the following things it stops crashing:

  • state_machine.transition
  • state_machine.set
  • state machine transition definition (e.g. - CLOSING -> CLOSING_INTERRUPTED)
  • filter

This suggests that this might be something to do with memory allocation

from esphome-state-machine.

muxa avatar muxa commented on July 17, 2024

I think the problem is that when initialising the new state machine instance all the parameters (states/inputs/transitions) are passed to a constructor and it might be causing a stack overflow.

Here's an example of the code that gets generated for the above config (with an extra state and some extra transitions to cause a crash):

garage_sm = new state_machine::StateMachineComponent({"CLOSED", "OPENING", "OPEN", "OPENING_INTERRUPTED", "CLOSING", "CLOSING_INTERRUPTED", "UNKNOWN", "UNKNOWN1"}, {"PRESS", "TIMEOUT", "OPENING_DETECTED", "CLOSED_DETECTED", "OPEN", "CLOSE", "STOP"}, {state_machine::StateTransition{
      .from_state = "CLOSED",
      .input = "PRESS",
      .to_state = "OPENING",
    }, state_machine::StateTransition{
      .from_state = "OPENING",
      .input = "PRESS",
      .to_state = "OPENING_INTERRUPTED",
    }, state_machine::StateTransition{
      .from_state = "OPENING_INTERRUPTED",
      .input = "PRESS",
      .to_state = "CLOSING",
    }, state_machine::StateTransition{
      .from_state = "OPEN",
      .input = "PRESS",
      .to_state = "CLOSING",
    }, state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "PRESS",
      .to_state = "CLOSING_INTERRUPTED",
    }, state_machine::StateTransition{
      .from_state = "CLOSING_INTERRUPTED",
      .input = "PRESS",
      .to_state = "OPENING",
    }, state_machine::StateTransition{
      .from_state = "OPENING",
      .input = "TIMEOUT",
      .to_state = "OPEN",
    }, state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "TIMEOUT",
      .to_state = "CLOSED",
    }, state_machine::StateTransition{
      .from_state = "CLOSED",
      .input = "OPENING_DETECTED",
      .to_state = "OPENING",
    }, state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "OPENING_DETECTED",
      .to_state = "OPENING",
    }, state_machine::StateTransition{
      .from_state = "OPENING_INTERRUPTED",
      .input = "OPENING_DETECTED",
      .to_state = "OPENING",
    }, state_machine::StateTransition{
      .from_state = "CLOSING_INTERRUPTED",
      .input = "OPENING_DETECTED",
      .to_state = "OPENING",
    }, state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "CLOSED_DETECTED",
      .to_state = "CLOSED",
    }, state_machine::StateTransition{
      .from_state = "OPEN",
      .input = "CLOSED_DETECTED",
      .to_state = "CLOSED",
    }, state_machine::StateTransition{
      .from_state = "OPENING",
      .input = "CLOSED_DETECTED",
      .to_state = "CLOSED",
    }, state_machine::StateTransition{
      .from_state = "OPENING_INTERRUPTED",
      .input = "CLOSED_DETECTED",
      .to_state = "CLOSED",
    }, state_machine::StateTransition{
      .from_state = "CLOSING_INTERRUPTED",
      .input = "CLOSED_DETECTED",
      .to_state = "CLOSED",
    }, state_machine::StateTransition{
      .from_state = "CLOSED",
      .input = "OPEN",
      .to_state = "OPENING",
    }, state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "OPEN",
      .to_state = "CLOSING_INTERRUPTED",
    }, state_machine::StateTransition{
      .from_state = "CLOSING_INTERRUPTED",
      .input = "OPEN",
      .to_state = "OPENING",
    }, state_machine::StateTransition{
      .from_state = "OPENING_INTERRUPTED",
      .input = "OPEN",
      .to_state = "CLOSING",
    }, state_machine::StateTransition{
      .from_state = "OPEN",
      .input = "CLOSE",
      .to_state = "CLOSING",
    }, state_machine::StateTransition{
      .from_state = "OPENING",
      .input = "CLOSE",
      .to_state = "OPENING_INTERRUPTED",
    }, state_machine::StateTransition{
      .from_state = "OPENING_INTERRUPTED",
      .input = "CLOSE",
      .to_state = "CLOSING",
    }, state_machine::StateTransition{
      .from_state = "CLOSING_INTERRUPTED",
      .input = "CLOSE",
      .to_state = "OPENING",
    }, state_machine::StateTransition{
      .from_state = "OPENING",
      .input = "STOP",
      .to_state = "OPENING_INTERRUPTED",
    }, state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "STOP",
      .to_state = "CLOSING_INTERRUPTED",
    }, state_machine::StateTransition{
      .from_state = "OPEN",
      .input = "STOP",
      .to_state = "CLOSING",
    }, state_machine::StateTransition{
      .from_state = "CLOSED",
      .input = "STOP",
      .to_state = "OPENING",
    }, state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "STOP",
      .to_state = "OPEN",
  }}, "CLOSED");

When I changed the code generation to pass each parameters separate the crash no longer occurred:

garage_sm = new state_machine::StateMachineComponent("CLOSED");
  garage_sm->add_state("CLOSED");
  garage_sm->add_state("OPENING");
  garage_sm->add_state("OPEN");
  garage_sm->add_state("OPENING_INTERRUPTED");
  garage_sm->add_state("CLOSING");
  garage_sm->add_state("CLOSING_INTERRUPTED");
  garage_sm->add_state("UNKNOWN");
  garage_sm->add_state("UNKNOWN1");
  garage_sm->add_input("PRESS");
  garage_sm->add_input("TIMEOUT");
  garage_sm->add_input("OPENING_DETECTED");
  garage_sm->add_input("CLOSED_DETECTED");
  garage_sm->add_input("OPEN");
  garage_sm->add_input("CLOSE");
  garage_sm->add_input("STOP");
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSED",
      .input = "PRESS",
      .to_state = "OPENING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPENING",
      .input = "PRESS",
      .to_state = "OPENING_INTERRUPTED",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPENING_INTERRUPTED",
      .input = "PRESS",
      .to_state = "CLOSING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPEN",
      .input = "PRESS",
      .to_state = "CLOSING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "PRESS",
      .to_state = "CLOSING_INTERRUPTED",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSING_INTERRUPTED",
      .input = "PRESS",
      .to_state = "OPENING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPENING",
      .input = "TIMEOUT",
      .to_state = "OPEN",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "TIMEOUT",
      .to_state = "CLOSED",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSED",
      .input = "OPENING_DETECTED",
      .to_state = "OPENING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "OPENING_DETECTED",
      .to_state = "OPENING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPENING_INTERRUPTED",
      .input = "OPENING_DETECTED",
      .to_state = "OPENING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSING_INTERRUPTED",
      .input = "OPENING_DETECTED",
      .to_state = "OPENING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "CLOSED_DETECTED",
      .to_state = "CLOSED",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPEN",
      .input = "CLOSED_DETECTED",
      .to_state = "CLOSED",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPENING",
      .input = "CLOSED_DETECTED",
      .to_state = "CLOSED",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPENING_INTERRUPTED",
      .input = "CLOSED_DETECTED",
      .to_state = "CLOSED",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSING_INTERRUPTED",
      .input = "CLOSED_DETECTED",
      .to_state = "CLOSED",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSED",
      .input = "OPEN",
      .to_state = "OPENING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "OPEN",
      .to_state = "CLOSING_INTERRUPTED",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSING_INTERRUPTED",
      .input = "OPEN",
      .to_state = "OPENING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPENING_INTERRUPTED",
      .input = "OPEN",
      .to_state = "CLOSING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPEN",
      .input = "CLOSE",
      .to_state = "CLOSING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPENING",
      .input = "CLOSE",
      .to_state = "OPENING_INTERRUPTED",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPENING_INTERRUPTED",
      .input = "CLOSE",
      .to_state = "CLOSING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSING_INTERRUPTED",
      .input = "CLOSE",
      .to_state = "OPENING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPENING",
      .input = "STOP",
      .to_state = "OPENING_INTERRUPTED",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "STOP",
      .to_state = "CLOSING_INTERRUPTED",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "OPEN",
      .input = "STOP",
      .to_state = "CLOSING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSED",
      .input = "STOP",
      .to_state = "OPENING",
  });
  garage_sm->add_transition(state_machine::StateTransition{
      .from_state = "CLOSING",
      .input = "STOP",
      .to_state = "OPEN",
  });

However this meant that I had to make the methods add_state, add_input and add_transition public. Which I think it's not a good idea (since it leaves the door open to change configuration later at runtime potentially causing unexpected problems).

Is there another way to achieve the same outcome?

from esphome-state-machine.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.