Switch statement and multiple devices


#1

1) Give a description of the problem
I have multiple Echo’s that control my bathroom speakers. I am using Echo Speaks to determine which Echo device was spoken to last. I have to enter the CASE device using an Expression. Can I put more than one device in the Switch statement as indicated below ? If so, I cannot figure out the syntax for an Expression listing more than one device.

Screenshot_2020-07-04%20webCoRE%20Dashboard


#3

I think what you want to do is change the switch behavior to the ‘fall through’ method so then you can have multiple cases that execute the same code. You just have to remember to put a ‘break’ at the end of each case section you don’t want to operate on the same code. So it Weill look like this:

switch (lastEcho)
  case Echo1
  case Echo2
     do some stuff
     break
  case Echo3
  case Echo4
     do different stuff
     break
  default
     log unknown echo
     break
end switch

See this wiki page:

https://wiki.webcore.co/Case_Traversal_Policy


#4

Excellent suggestion my friend! I’ll give it a try.


#5

Works perfectly. Thanks!