lutzer / node-red-contrib-finite-statemachine

A finite state machine implementation for node red.
MIT License
16 stars 5 forks source link

Question #2

Closed michael-benoit closed 3 years ago

michael-benoit commented 4 years ago

Is it possible to define a data value for each state in addition to the initial state? Trying not to rely on the trigger messages to include the value. My states imply a value.

TIA,

Michael

lutzer commented 4 years ago

Hi Michael, sorry for the very late reply. it is currently not possible, but it will be added in the next release.

michael-benoit commented 4 years ago

Can't wait. This will clean up a lot of my flows.

Thanks. This node is one the most under-valued nodes. People need to understand state-machines.

StephanStS commented 4 years ago

Hello @michael-benoit, lutzer has implemented the feature to be able to change the "data" fields within the statemachine definition. I also appreciate this, now you can avoid some state related switch and change nodes around the state machine. See: https://flows.nodered.org/node/node-red-contrib-finite-statemachine

You can use these "data" field definitions during a valid "state change". This might also be a state transition to the active state (i.e. no state change, but a data msg output). Another use case I did was to have transient states, i.e. states which switch autonomously to the next state after one cycle. I did this with a cyclic topc "tAlways" which was evaluated within these transient states.

On hint: Be aware that within the state machine definition you cannot use variable names (like {"command": flow.LightOn} or similar). Only constants are possible.

Regards Stephan

StephanStS commented 4 years ago

@lutzer: I propose to close this issue. We assume that it is solved with your last release.

kasaidolar commented 4 years ago

Hi I recived:

msg : Object
object
code: 12
msg: "transition not possible from the current state.".

I have:

{
    "state": {
        "status": "IDLE"
    },
    "transitions": {
        "IDLE": {
            "run": "RUNNING"
        },
        "RUNNING": {
            "stop": "IDLE",
            "set": "RUNNING"
        }
    }
}

And I send "run". What is wrong?

Pawel

lutzer commented 4 years ago

hey Pawel,

You need to send "run" as the topic of the message, are you maybe sending it as a payload? Otherwise could you export your flow and post it here? Then i might be able to see the problem.

Cheers, Lutz

StephanStS commented 4 years ago

You could use the example flows as a basis. See also Manual.md.

-----Original Message----- From: lutzer notifications@github.com To: lutzer/node-red-contrib-finite-statemachine node-red-contrib-finite-statemachine@noreply.github.com Cc: StephanStS stephan.schultze@schultze-online.de, Comment comment@noreply.github.com Sent: Mi., 08 Juli 2020 17:59 Subject: Re: [lutzer/node-red-contrib-finite-statemachine] Question (#2)

hey Pawel,

You need to send "run" as the topic of the message, are you maybe sending it as a payload? Otherwise could you export your flow and post it here? Then i might be able to see the problem.

Cheers, Lutz

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/lutzer/node-red-contrib-finite-statemachine/issues/2#issuecomment-655608268