Closed buelowp closed 5 months ago
Hi @buelowp , how are you?
I think the solution is simple, just instantiate your SM with allow_event_without_transition=True
.
Ref: https://python-statemachine.readthedocs.io/en/latest/api.html#statemachine
I'm good, thanks for the rapid response. I completely missed that in the docs. Thank you. A quick test, and it doesn't fail. I'll let it run until the next transition to make sure I get what I want.
I think that this can be better documented as a feature, it only appears here at the "API" docs. Sorry about that.
Feel free to send suggestions on how to properly document this.
Best!
I saw a few things I had some troubles with, so I'll send some notes later. Thanks for listening.
Hi @buelowp, it looks like we've resolved the issue, so I'm going to close it for now. If you need to, please feel free to reopen this one or start a new issue. Best!
I have a very complicated home built FSM I wrote in python a few years ago to control lights in my house from an RPi. I want to migrate the code to a real FSM so I can clean it up, simplify, and fix a bunch of silly bugs I am working around. What I want to do is to create a circular FSM that can be triggered to change based on the conditions below and to silently ignore if the condition to allow a state transition isn't met. That way, I can just merrily check once a second if it's time to do something and always know I'm in the right state.
My expectation was that cond=function would simply not allow a transition if it evaluates to false. But on false, it throws an exception and even if I call
pass
in the exception handler, it never works right. I never see it move to the next state when cond=True once the exception handler fires the first time. If I start this after sunset, it works for a single transition, but not again because the next iteration causes the exception.What's the right way to do this with this FSM implementation?
This is the error I'm getting.
I