message: fix: payload parse of rgb dimmers
diff: @@ -408,6 +408,16 @@ function copy (obj) {
  return JSON.parse(JSON.stringify(obj))
  }
  +/**
  + * Checks if an object_id is a rgb_dimmer
  + *
  + * @param {String} id object id of the hass discovery payload
  + * @returns true if the discovery payload object id is a rgb_dimmer
  + */
  +function isRgbDimmer (id) {
  + return id.startsWith('rgb_dimmer')
  +}
  +
  /**
  * Get the device Object to send in discovery payload
  *
  @@ -477,12 +487,14 @@ Gateway.prototype.parsePayload = function (payload, valueId, valueConf) {
  // Hass payload parsing
  if (this.discovered[valueId.value_id]) {
  // parse payload for switches
  - if ((valueId.type === 'bool' || this.discovered[valueId.value_id].object_id === 'rgb_dimmer') && typeof payload === 'string') {
  + const isDimmer = isRgbDimmer(this.discovered[valueId.value_id].object_id)
  +
  + if ((valueId.type === 'bool' || isDimmer) && typeof payload === 'string') {
  if (/\btrue\b|\bon\b|\block\b/gi.test(payload)) payload = true
  else if (/\bfalse\b|\boff\b|\bunlock\b/gi.test(payload)) payload = false
  }
  - if (this.discovered[valueId.value_id].object_id === 'rgb_dimmer') {
  + if (isDimmer) {
  if (typeof payload === 'boolean') payload = payload ? 99 : 0
  else payload = Math.round(payload / 255 * 99)
  }
  