Page 1 of 1

Making a finite state machine (FSM), or switch/case

Posted: 08 Mar 2017 15:32
by vegardb123
Hi!

Me and a couple of friends have made a script for two Fibaro motion sensors and a FIbaro door/window sensor. The script checks if someone exits the house (the house/building), and calls a Python script which sends a message to a PC server. When the person comes back, the Python script is called again and the server recieves a message that says the person has come home.

The problem is that the main javascript has way to many if/else statements, and it's hard to keep track of them all. We would like to make a state machine, but we only have experience in making state machines in C#. Does anyone have any experience in making state machines in javascript? Or maybe a switch/case structure could work?