uart:
  - id: uart_modbus_client
    tx_pin: ${client_tx_pin}
    rx_pin: ${client_rx_pin}
    baud_rate: 9600
  - id: uart_modbus_server
    tx_pin: ${server_tx_pin}
    rx_pin: ${server_rx_pin}
    baud_rate: 9600

modbus:
  - id: mod_bus1
    uart_id: uart_modbus_client
    flow_control_pin: ${flow_control_pin}
  - id: mod_bus2
    uart_id: uart_modbus_server
    role: server

modbus_controller:
  - id: modbus_controller1
    address: 0x2
    modbus_id: mod_bus1
    allow_duplicate_commands: false
    on_online:
      then:
        logger.log: "Module Online"
  - id: modbus_controller2
    address: 0x2
    modbus_id: mod_bus2
    server_registers:
      - address: 0x0000
        value_type: S_DWORD_R
        read_lambda: |-
          return 42.3;
    max_cmd_retries: 0

binary_sensor:
  - platform: modbus_controller
    modbus_controller_id: modbus_controller1
    id: modbus_binary_sensor1
    name: Test Binary Sensor
    register_type: read
    address: 0x3200
    bitmask: 0x80

number:
  - platform: modbus_controller
    modbus_controller_id: modbus_controller1
    id: modbus_number1
    name: Test Number
    address: 0x9001
    value_type: U_WORD
    multiply: 1.0

output:
  - platform: modbus_controller
    modbus_controller_id: modbus_controller1
    id: modbus_output1
    address: 2048
    register_type: holding
    value_type: U_WORD
    multiply: 1000

select:
  - platform: modbus_controller
    modbus_controller_id: modbus_controller1
    id: modbus_select1
    name: Test Select
    address: 1000
    value_type: U_WORD
    optionsmap:
      "Zero": 0
      "One": 1
      "Two": 2
      "Three": 3

sensor:
  - platform: modbus_controller
    modbus_controller_id: modbus_controller1
    id: modbus_sensor1
    name: Test Sensor
    register_type: holding
    address: 0x9001
    unit_of_measurement: "AH"
    value_type: U_WORD

switch:
  - platform: modbus_controller
    modbus_controller_id: modbus_controller1
    id: modbus_switch1
    name: Test Switch
    register_type: coil
    address: 0x15
    bitmask: 1

text_sensor:
  - platform: modbus_controller
    modbus_controller_id: modbus_controller1
    id: modbus_text_sensor1
    name: Test Text Sensor
    register_type: holding
    address: 0x9013
    register_count: 3
    raw_encode: HEXBYTES
    response_size: 6
