[SOLVED] How to do a substring on a state

I have a Hue dimmer switch which stores 4 different values depending on how / how long a button was pressed, e.g. 1000, 1001, 1002, 1002 for button 1, 2000, 2001, 2003, 2004 for button 2 and so on. I would like to react to any form of how the button was pressed and was thinking about looking at the first digit only

switch substring(item, 1,1)
case 1
case 2

What would be the right way to get the first digit only from the state?

I have no experience with java and its object model, but after fiddling around a bit it seems as if


is the right solution, so LichtschalterBuero_DimmerSwitch.state.toString.substring(0,1) in my scenario, just in case that anyone else ever has a similar requirement

1 Like