message: fix: better payload parsing
diff: @@ -903,11 +903,7 @@ Gateway.prototype.parsePayload = function (payload, valueId, valueConf) {
  ? payload.value
  : payload
  - const hassDevice = this.discovered[valueId.id]
  -
  - // Hass payload parsing
  - if (hassDevice) {
  - // try to parse string payloads in bools
  + // try to parse string to bools
  if (typeof payload === 'string' && isNaN(payload)) {
  if (/\btrue\b|\bon\b|\block\b/gi.test(payload)) payload = true
  else if (/\bfalse\b|\boff\b|\bunlock\b/gi.test(payload)) {
  @@ -920,6 +916,18 @@ Gateway.prototype.parsePayload = function (payload, valueId, valueConf) {
  payload = payload ? valueId.max : valueId.min
  }
  + if (valueId.commandClass === CommandClasses['Binary Toggle Switch']) {
  + payload = 1
  + } else if (
  + valueId.commandClass === CommandClasses['Multilevel Toggle Switch']
  + ) {
  + payload = valueId.value > 0 ? 0 : 0xff
  + }
  +
  + const hassDevice = this.discovered[valueId.id]
  +
  + // Hass payload parsing
  + if (hassDevice) {
  // map modes coming from hass
  if (valueId.list && isNaN(payload)) {
  // for thermostat_fan_mode command class use the fan_mode_map
  @@ -936,22 +944,6 @@ Gateway.prototype.parsePayload = function (payload, valueId, valueConf) {
  payload = hassDevice.mode_map[payload]
  }
  }
  -
  - if (valueId.commandClass === CommandClasses['Binary Toggle Switch']) {
  - payload = 1
  - } else if (
  - valueId.commandClass === CommandClasses['Multilevel Toggle Switch']
  - ) {
  - payload = valueId.value > 0 ? 0 : 0xff
  - }
  - }
  -
  - if (valueId.type === 'any') {
  - if (payload.type === 'Buffer' && payload.data) {
  - payload = Buffer.from(payload.data)
  - } else {
  - payload = Buffer.from(payload)
  - }
  }
  if (valueConf) {
  