lutzer / node-red-contrib-finite-statemachine

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

Can't set data with key named other than "data" #33

Open Nertskull opened 1 year ago

Nertskull commented 1 year ago

If I have a FSM defined similar to as as follows:

 {
    "state": {
        "status": "OFF-RESET",
        "data": {
            "light-state": 0
        }
    },
    "transitions": {
        "OFF-RESET": {
            "motion-on": {
                "status": "ON-TRANSITIONING",
                "data": {
                    "light-state": "1"
                }
            },
            "switched-on": {
                "status": "ON-SWITCHED",
                "data": {
                    "light-state": "1"
                }
            },

then everything works as expected. But is must be named "data". Is there a way to change it to a different key name? Such as this:

   {
    "state": {
        "status": "OFF-RESET",
        "set-values": {
            "light-state": 0
        }
    },
    "transitions": {
        "OFF-RESET": {
            "motion-on": {
                "status": "ON-TRANSITIONING",
                "set-values": {
                    "light-state": "1"
                }
            },
            "switched-on": {
                "status": "ON-SWITCHED",
                "set-values": {
                    "light-state": "1"
                }
            },

If I do anything like this, and then put a debug node w/ msg.payload.set-values, I get light-state: 0. But it never will change to 1. I would prefer to not use "data" as that payload.data is used for so many things and conflicts with some of my other nodes. Is there a way to do this?