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

How would I handle this? #162

Open
stephankaag opened this issue Jan 17, 2019 · 2 comments
Open

How would I handle this? #162

stephankaag opened this issue Jan 17, 2019 · 2 comments

Comments

@stephankaag
Copy link

stephankaag commented Jan 17, 2019

Let's say for example my machine represents a light bulb. The two obvious states would be 'on' and 'off'.
But, if the bulb is dimmable and the dimmer value is some value between 1 and 100 how would I handle this 'second state' that a bulb has?

I think defining the states ['on_1', 'on_2', 'on_3'.., 'on_100'] would be suboptimal. Is there a better way?

@ctmackay
Copy link

Why does the dimness of the light bulb have to be a state at all? You should use the variable “brightness” in the internal logic of the on state.

The value of the brightness doesn’t matter to be able to transition to the off state. All 100 brightness levels transition to the off state, is that right ? Or do they transition to one another ?

I would design the architecture such that you do not have a need for any other state other than on / off

@andreabadesso
Copy link

I have a finite state machine (in erlang) describing an light bulb on my home automation startup, the way we designed it was to have two states:

idle()
The light bulb is available to be messed with.

We have methods here to turn on and off, dim the light, etc...

wait_reply()
Everytime a message is sent, we transition to this state until the response is received (our products communicate via RF).

We process the message here and transition to idle back again, storing the new state.

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