function transform(message, previousMessage) {
  // Parse the JSON payload, because the message payload is always a string.
  const payloadJSON = JSON.parse(message.Payload);

  // Extract the temperature value (in Fahrenheit) and convert it to Celsius.
  const temperatureFahrenheit = payloadJSON.value;
  const temperatureCelsius = ((temperatureFahrenheit - 32) * 5) / 9;

  // Overwrite the message payload with the temperature value in Celsius,
  // rounded to one decimal place.
  message.Payload = temperatureCelsius.toFixed(1);

  // Don't send the message if the temperature value hasn't changed since the last message.
  if (previousMessage?.Payload === message.Payload) {
    console.debug("Value hasn't changed since the last message. Skipping send.");
    return false;
  }

  // Instead of using the default 'message received' timestamp,
  // use the sensor timestamp from the payload and convert it to ISO 8601.
  const unixTimestamp = parseInt(payloadJSON.timestamp);
  message.Timestamp = new Date(unixTimestamp * 1000).toISOString();
}
