[SOLVED] Rs485 to MQTT gateway?

Thanks to both @rossko57 and @vzorglub and everyone else… It appears I have it working now… Possibly not the most elegant rule but here it is…

rule "Ventillation Fan Serial"
when
   Item VentillationSerial received update
then
   val ReplaceString = triggeringItem.state.toString().replace(',"SSerialReceived":"', '').replace('"}', '')

   // Example of string published to VentillationSerial is 531C5002541900483956014D00
   // Extract the fan speed out of the big string using substring, it is 1C in the example above
   // It is after the 2nd character and up to the 4th character
   // Its a hexadecimal so we also convert it back to decimal to give us 28
   
   var Number SpeedPercent = Integer::parseInt(ReplaceString.substring(2,4), 16)
   var Number TempWholeNumber = Integer::parseInt(ReplaceString.substring(10,12), 16)
   var Number TempDecimalPoint = Integer::parseInt(ReplaceString.substring(12,14), 16)
   var Number HumidityPercent = Integer::parseInt(ReplaceString.substring(16,18), 16)
   var Number Mode = Integer::parseInt(ReplaceString.substring(20,22), 16)
   var Number Phase = Integer::parseInt(ReplaceString.substring(6,8), 16)
   var Number SummerMode = Integer::parseInt(ReplaceString.substring(24,26), 16)
   
   VentillationSpeed.postUpdate(SpeedPercent)
   VentillationTemp.postUpdate(TempWholeNumber + "." + TempDecimalPoint)
   VentillationHumid.postUpdate(HumidityPercent)
   VentillationMode.postUpdate(Mode) //0=OFF, 1=LOW, 2=MED, 3=HIGH, 4=LL and 5=TEST"
   VentillationPhase.postUpdate(Phase) //1=STARTUP, 2=ADJUST, 3=SLOWDOWN
   VentillationSummerMode.postUpdate(SummerMode) //0=OFF, 1=ON
end
1 Like

Oh yes, of course; for postUpdate we only need a string that looks like a number :smiley:
Saves doing maths.