How can I convert a buffer [4] into a number value?

Here is a nice reference for reading/writing buffers on the W3Schools site.

For instance, if you just want to replace the 4-byte payload buffer with its 32-bit signed
big-endian integer value, try this:

msg.payload = msg.payload.readInt32BE();
return msg;