Return value of Moes Scene Switch TS0042 button under Gladys

Hello,
I have paired a Moes brand 2-input button, recognized by zigbee2mqtt as TS0042 (TuYa),

In Gladys, I added a scene with a device state change, but what seems strange to me is that only integer values can be entered, whereas the button returns strings.

State under zigbee2mqtt:

{
    "battery": 100,
    "linkquality": 167,
    "action": "1_single"
}

The values for action are: 1_single, 1_double, 1_hold, 2_single, 2_double, 2_hold

In Gladys:

In zigbee2mqtt:
I can’t post an image as I’m new to the forum

Thank you for your time and help

Hello @MisterBin, and welcome to the community! :slight_smile:

Indeed, Gladys only handles numerical values for device states.

We need to convert between the static value and the numerical value in the Zigbee2mqtt integration.

@cicoub13 @AlexTrovato Is this device already supported or do we need to add the values to the Zigbee2mqtt integration?

If it’s not supported, you’ll need to create a GitHub issue @MisterBin: Issues · GladysAssistant/Gladys · GitHub

I saw this in the code, no idea if I’m in the right place
but if so, maybe we just need to add cases for the button values

        case 'single':
        case '1_single':
          result = BUTTON_STATUS.CLICK;
          break;
  convertValue.js
  -------------------------------
    // Case for Button devices
    case 'click': {
      switch (value) {
        case 'single':
          result = BUTTON_STATUS.CLICK;
          break;
        case 'double':
          result = BUTTON_STATUS.DOUBLE_CLICK;
          break;
        case 'hold':
          result = BUTTON_STATUS.LONG_CLICK;
          break;
        default:
          result = value;
      }
      break;
    }

You are in the right place!

You indeed need to add these values in these files + unit tests to check that it works well