Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add state machine #466

Open
spacemanspiff2007 opened this issue Dec 9, 2024 · 3 comments
Open

Add state machine #466

spacemanspiff2007 opened this issue Dec 9, 2024 · 3 comments

Comments

@spacemanspiff2007
Copy link
Owner

Add a simple state machine that plays nice with the HABApp environment.
Make it so the users can add building blocks for automatic state transition (e.g. transition if item > 5) to make usage easier.
I'm torn between making the state machine an HABApp internal item or a helper class that will be assigned as a rule variable.
In both it should be able to automatically push the current state to an openHAB item.
If it's stand alone it could be configured e.g. from some kind of yaml?

@nobbi1991
You're using a couple of state machines in your rules and I'd like and value your input on this.
How do you use your state machines and what features would you expect from an HABApp implementation?

@Rosi2143
Copy link
Contributor

Rosi2143 commented Jan 4, 2025

Hi @spacemanspiff2007,

I made very good experiences with python-statemachine. It has a lot of great features and I added it into many of my rules.

How about adding this module as a dependency - I just added it to the list of packages in my installation and it works like a charm.

@nobbi1991
Copy link

I use https://github.com/pytransitions/transitions, since it also supports hierarchical FSMs.
From my side no additions to HABApp are needed.

@spacemanspiff2007
Copy link
Owner Author

I thought it would be nice to have an item (HABApp internal order openHAB item) which reflects the current state the item is in.
Sending commands to the item could then trigger the corresponding transition to the next state.
I looked a little bit at python-statemachine but it keeps an internal reference to the event loop which breaks things during testing. Transistions does only allow sync or async callbacks but as far as I saw not a mixture of both.
It's also always difficult if the library launches it's own threads/tasks because we don't get the nice HABApp tracebacks and cleanup on rule reload is often not possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants