MQTT select with numeric options and histroy graph

Hello,
I have a MQTT message from an external program returning a numeric value.
This value can be one of { 2, 10, 20, 30, 40, 50, 60, 70, 80 }.

I defined a MQTT select to represent this value (and change it)

mqtt:
  - select:
        - name: "Voltronic Set AC Charge Current"
          unique_id: voltronic_set_ac_charge_current
          state_topic: "voltronic-7200/status/max_ac_charging_current/value"
          command_topic: "nuc/voltronic-7200-out/cmd"
          optimistic: true
          retain: true
          options:
            - 2
            - 10
            - 20
            - 30
            - 40
            - 50
            - 60
            - 70
            - 80
          command_template: >-
            {{ 'MUCHGC0%02d' | format(value|int) }}
          value_template:  >
            {% if value|is_number %}
               {{ value | int }}
            {% else %}
               unavailable
            {% endif %}
          device:
            name: "voltronic-7200"
            identifiers: "voltronic-7200"
            model: "voltronic-7200"

This generate and error in HA logs:

Invalid option for select.voltronic_set_ac_charge_current: '2' (valid options: [2, 10, 20, 30, 40, 50, 60, 70, 80])

Instead, if I define select as:

mqtt:
  - select:
        - name: "Voltronic Set AC Charge Current"
          unique_id: voltronic_set_ac_charge_current
          state_topic: "voltronic-7200/status/max_ac_charging_current/value"
          command_topic: "nuc/voltronic-7200-out/cmd"
          optimistic: true
          retain: true
          options:
            - "2"
            - "10"
            - "20"
            - "30"
            - "40"
            - "50"
            - "60"
            - "70"
            - "80"
          command_template: >-
            {{ 'MUCHGC0%02d' | format(value|int) }}
          value_template:  >
            {% if value|is_number %}
               {{ value | int }}
            {% else %}
               unavailable
            {% endif %}
          device:
            name: "voltronic-7200"
            identifiers: "voltronic-7200"
            model: "voltronic-7200"

it works.

But history is very ugly:

If I define an helper input_select with same options, rendering is better, I can see a graph:

Is there a way to force MQTT select to render as the helper input_select?

Thanks

The history is always going to be ugly. It’s a select entity, it’s assumed to be a string.

If you want it to be numerical, use a mqtt number.

How could restric values to { 2, 10, 20, 30, 40, 50, 60, 70, 80 } ?

Just round the values to the nearest 10. Or have 0 under the hood be treated as 2 and set the stepsize to 10.

I tried using number instead of select:

mqtt:
  - number:
        - name: "Voltronic Set AC Charge Current 2"
          unique_id: voltronic_set_ac_charge_current_2
          state_topic: "voltronic-7200/status/max_ac_charging_current/value"
          command_topic: "nuc/voltronic-7200-out/cmd"
          optimistic: true
          retain: true
          device_class: current
          min: 0
          max: 80
          step: 10
          mode: box
          unit_of_measurement: A
          command_template: >-
            {% set num = (value|int) if (value|int) > 0 else 2 %}
            {{ 'MUCHGC0%02d' | format(num|int) }}
          value_template:  >
            {% if value|is_number %}
               {{ (value|int) if (value|int) > 0 else 2 }}
            {% else %}
               unavailable
            {% endif %}
          device:
            name: "voltronic-7200"
            identifiers: "voltronic-7200"
            model: "voltronic-7200"
            manufacturer: "MPP-Solar"

and result is what I was looking for

The only thing is that when I selected 0 as value, it took some time to refresh to 2 (after MQTT refresh).

Thanks