the variable type contains the string "StandardLights=1"
Exactly, so the call to the parseInt() method is going to get an empty string, which, when converted to an int is zippity do dah. Which is what you are getting.
Once you know that the stream contained "lightMode", you could use findUntil() to capture/throw away everything up to the '=', and THEN parseInt() would have something to read and parse.
I thought parse int read the whole string and stopped at the first integer
No. There are two problems with this statement. First, by the time you call parseInt(), there is nothing left in the stream to read. The second is that parseInt() consumes everything from the stream that IS an int. It does not read and discard non-digits until it finds stuff that could be an int.
So I am confused why I cant parse int after stripping the string into a variable??
Because you are not getting data to convert to an int from the variable. You are getting it from the input stream, which you have emptied.
There is a completely different process for getting int data from a String.
m I right in thinking you empty the buffer when you read it's contents??
Serial.parseInt() returns the first valid (long) integer number from the serial buffer. Characters that are not integers (or the minus sign) are skipped. Serial.parseInt() is terminated by the first character that is not a digit.
the issue with this code is:
String type = client.readString();
which empties the serial buffer - if you remove this line; you'll find the number will be parsed with the parseInt function; what you should do; if you need to have the variable "type" for later is to use the stdlib c functions to extract the number instead.