Multi-state switch for Modbus

Hello there,
I am currently trying to figure out how to create a 4-state switch/ control, that would allow me to send 4 different Modbus commands (same function code and address, 4 different register values). In my configuration.yaml so far I was able to create only a 2-state switch:

    switches:
      - name: "Quiet mode"
        unique_id: 6646bbb7-0644-4d4e-af22-9d00d0355954
        slave: 1
        address: 21
        write_type: coil
        command_on: 1
        command_off: 0
        scan_interval: 30
        verify:
            input_type: coil
            address: 21
            delay: 1
            state_on: 1
            state_off: 0

What I need to do now is to create a control that would allow me to modify a holding register with different register values (1, 2, and 4), to control the Heat Pump heating mode:

I am not very proficient with HA yet. In case of any hints, I would appreciate some code/ syntax examples!
I would appreciate all help!

Hi, So far I was able to create 3 separate scripts. Each one does a write holding register with a different value. I am able to run the scripts separately, but cannot figure out how to tie them with an input select item.

Anyone willing to help in connect this with input select?

Hey @bremenpl did you figure this one out?

Hi, have you tried using a helper to create a four way switch and use that to input into an automation that sends a value to the modbus register. You can pick up the status of the switch elsewhere.

Further to this, the switch doesn`t need to be a switch, perhaps it should be a sensor as you can write to the holding register using a service call.