Add a sensor

Hi ! want a sensor that displays the difference between max cell voltage and min cell voltage.
Been trying with a sensor template but can’t get it to work. Some one who can help me?
Here is the code needed:

captive_portal:
uart:
  tx_pin: GPIO1
  rx_pin: GPIO3
  baud_rate: 9600
  rx_buffer_size: 512

daly_bms:
  update_interval: 10s

sensor:
  - platform: daly_bms
    voltage:
      name: "Battery Voltage"
    current:
      name: "Battery Current"
    battery_level:
      name: "Battery Level"
    max_cell_voltage:
      name: "Max Cell Voltage"
    max_cell_voltage_number:
      name: "Max Cell Voltage Number"
    min_cell_voltage:
      name: "Min Cell Voltage"
    min_cell_voltage_number:
      name: "Min Cell Voltage Number"
    max_temperature:
      name: "Max Temperature"
    max_temperature_probe_number:
      name: "Max Temperature Probe Number"
    min_temperature:
      name: "Min Temperature"
    min_temperature_probe_number:  
      name: "Min Temperature Probe Number"
    remaining_capacity:
      name: "Remaining Capacity"
    cells_number:
      name: "Cells Number"
    temperature_1:
      name: "Temperature 1"
    temperature_2:
      name: "Temperature 2"
    cell_1_voltage:
      name: "Cell 1 Voltage"
    cell_2_voltage:
      name: "Cell 2 Voltage"
    cell_3_voltage:
      name: "Cell 3 Voltage"
    cell_4_voltage:
      name: "Cell 4 Voltage"
    cell_5_voltage:
      name: "Cell 5 Voltage"
    cell_6_voltage:
      name: "Cell 6 Voltage"
    cell_7_voltage:
      name: "Cell 7 Voltage"
    cell_8_voltage:
      name: "Cell 8 Voltage"  
    cell_9_voltage:
      name: "Cell 9 Voltage"
    cell_10_voltage:
      name: "Cell 10 Voltage"
    cell_11_voltage:
      name: "Cell 11 Voltage"
    cell_12_voltage:
      name: "Cell 12 Voltage"  
    cell_13_voltage:
      name: "Cell 13 Voltage"
    cell_14_voltage:
      name: "Cell 14 Voltage"
    cell_15_voltage:
      name: "Cell 15 Voltage"
    cell_16_voltage:
      name: "Cell 16 Voltage" 
 
    
text_sensor:
  - platform: daly_bms
    status:
      name: "BMS Status"


binary_sensor:
  - platform: daly_bms
    charging_mos_enabled:
      name: "Daly Charging MOS"
      id: bin_daly_chg_mos # binary MOS sensor must have ID to use with switch
      internal: True # but you can make it internal to avoid duplication
    discharging_mos_enabled:
      name: "Daly Discharging MOS"
      id: bin_daly_dischg_mos # binary MOS sensor must have ID to use with switch
      internal: True # but you can make it internal to avoid duplication

switch:
  - platform: template
    name: "Daly Charging MOS"
    lambda: |-
      if (id(bin_daly_chg_mos).state) {
        return true;
      } else {
        return false;
      }
    turn_on_action:
      - uart.write:
          data: [0xA5, 0x40, 0xDA, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC8]
      - logger.log:
          format: "Send cmd to Daly: Set charge MOS on"
    turn_off_action:
      - uart.write:
          data: [0xA5, 0x40, 0xDA, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC7]
      - logger.log:
          format: "Send cmd to Daly: Set charge MOS off"

  - platform: template
    name: "Daly Discharging MOS"
    lambda: |-
      if (id(bin_daly_dischg_mos).state) {
        return true;
      } else {
        return false;
      }
    turn_on_action:
      - uart.write:
          data: [0xA5, 0x40, 0xD9, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC7]
      - logger.log:
          format: "Send cmd to Daly: Set discharge MOS on"
    turn_off_action:
      - uart.write:
          data: [0xA5, 0x40, 0xD9, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6]
      - logger.log:
          format: "Send cmd to Daly: Set discharge MOS off"