Moving to new Template sensor configuration but failing (Current Cost & Others)

I’ve been using the Current Cost Custom Component for a few years now along with several other custom components and official add ons
I noticed recently that I appear to be using the OLD template sensor format in my configuration.yaml file so I decided to update it
After several hours of trial and error I manage to re write my config yaml file and run a check that had no errors
BUT after restating NONE of the sensors show up
Strangley I can check them in the Developer Tools Template check and they do exist and work

ANY suggestions greatly appreciated

A section from my original configuration.yaml file which works fine

##########################
### Current Cost EnviR ###
##########################
sensor 1:  
  - platform: currentcost
    serial_port: /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0
    name: Current Cost
    baudrate: 57600
    devices:
      - 0 # ELECTRICITY #
      - 1 # GARAGE SOLAR #
      - 2 # GAS #
      - 4 # SOLAR iBOOST #
      - 7 # ELECTRICITY METER #
      - 8 # GARAGE SOLAR METER #
      - 9 # GAS METER #
      
  - platform: template
    sensors:
      currentcost_temperature:
        entity_id: sensor.current_cost
        unit_of_measurement: '°C'
        value_template: '{{ state_attr("sensor.current_cost", "Temperature") | float -2 }}'
        friendly_name: CurrentCost Temperature
        
              
      currentcost_electricity:
        entity_id: sensor.current_cost
        unit_of_measurement: 'W'
        value_template: '{{ state_attr("sensor.current_cost", "Appliance 0")  }}'
        friendly_name: CurrentCost Electricity
        
        
      currentcost_electricity_2:
        entity_id: sensor.current_cost
        unit_of_measurement: 'kWh'
        value_template: "{{ (states('sensor.currentcost_electricity')| float /1000 | float) | round (3) }}"
        friendly_name: CurrentCost Electricity 2
        
        
      currentcost_garage_solar:
        entity_id: sensor.current_cost
        unit_of_measurement: 'W'
        value_template: "{{ (state_attr('sensor.current_cost', 'Appliance 1') | float) | round (0) }}"
        friendly_name: CurrentCost Garage Solar
        
        
      currentcost_garage_solar_2:
        entity_id: sensor.current_cost
        unit_of_measurement: 'kWh'
        value_template: "{{ (states('sensor.currentcost_garage_solar')| float /1000 | float) | round (2) }}"
        friendly_name: CurrentCost Garage Solar 2
        
      currentcost_gas:
        entity_id: sensor.current_cost
        unit_of_measurement: 'W'
        value_template: "{{ (state_attr('sensor.current_cost', 'Appliance 2') | float *1.02264 | float *40.1 | float /3.6 | float) | round (3)  }}"
        friendly_name: CurrentCost Gas
        # CONVERTS UNITS TO WATTS #

A section from my updated configuration.yaml file which does not works as I hoped

##########################
### Current Cost EnviR ###
##########################
sensor:  
  - platform: currentcost
    serial_port: /dev/serial/by-id/usb-Prolific_Technology_Inc._USB-Serial_Controller-if00-port0
    name: Current Cost
    baudrate: 57600
    devices:
      - 0 # ELECTRICITY #
      - 1 # GARAGE SOLAR #
      - 2 # GAS #
      - 4 # SOLAR iBOOST #
      - 7 # ELECTRICITY METER #
      - 8 # GARAGE SOLAR METER #
      - 9 # GAS METER #
      
  - platform: integration
    source: sensor.current_cost
    name: Total Energy
    unit_prefix: k
    round: 2

template:
  - sensor:
      - name: "Currentcost Temperature"
        unit_of_measurement: '°C'
        state: '{{ state_attr("sensor.current_cost", "Temperature") | float -2 }}'
        device_class: temperature
        state_class: measurement # Add state_class: measurement for long term statistics are required
        
  - sensor:
      - name: "Currentcost Electricity"
        unit_of_measurement: 'W'
        state: '{{ state_attr("sensor.current_cost", "Appliance 0")  }}'
        device_class: power
        state_class: measurement
        
  - sensor:
      - name: "Currentcost Electricity 2"
        unit_of_measurement: 'kWh'
        state: "{{ (states('sensor.currentcost_electricity')| float /1000 | float) | round (3) }}"
        device_class: energy
        state_class: measurement
        
  - sensor:
      - name: "Currentcost Garage Solar"
        unit_of_measurement: 'W'
        state: "{{ (state_attr('sensor.current_cost', 'Appliance 1') | float) | round (0) }}"
        device_class: power
        state_class: measurement
        
  - sensor:
      - name: "Currentcost Garage Solar 2"
        unit_of_measurement: 'kWh'
        state: "{{ (states('sensor.currentcost_garage_solar')| float /1000 | float) | round (2) }}"
        device_class: energy
        state_class: measurement
        
  - sensor:
      - name: "Currentcost Gas"
        unit_of_measurement: 'W'
        state: "{{ (state_attr('sensor.current_cost', 'Appliance 2') | float *1.02264 | float *40.1 | float /3.6 | float) | round (3)  }}"
        device_class: power
        state_class: measurement
        # CONVERTS UNITS TO WATTS #

try like this:

template:
  - sensor:
      - name: "Currentcost Temperature"
        unit_of_measurement: '°C'
        state: '{{ state_attr("sensor.current_cost", "Temperature") | float -2 }}'
        device_class: temperature
        state_class: measurement # Add state_class: measurement for long term statistics are required
        
      - name: "Currentcost Electricity"
        unit_of_measurement: 'W'
        state: '{{ state_attr("sensor.current_cost", "Appliance 0")  }}'
        device_class: power
        state_class: measurement
        
      - name: "Currentcost Electricity 2"
        unit_of_measurement: 'kWh'
        state: "{{ (states('sensor.currentcost_electricity')| float /1000 | float) | round (3) }}"
        device_class: energy
        state_class: measurement
        
      - name: "Currentcost Garage Solar"
        unit_of_measurement: 'W'
        state: "{{ (state_attr('sensor.current_cost', 'Appliance 1') | float) | round (0) }}"
        device_class: power
        state_class: measurement
        
      - name: "Currentcost Garage Solar 2"
        unit_of_measurement: 'kWh'
        state: "{{ (states('sensor.currentcost_garage_solar')| float /1000 | float) | round (2) }}"
        device_class: energy
        state_class: measurement
        
      - name: "Currentcost Gas"
        unit_of_measurement: 'W'
        state: "{{ (state_attr('sensor.current_cost', 'Appliance 2') | float *1.02264 | float *40.1 | float /3.6 | float) | round (3)  }}"
        device_class: power
        state_class: measurement
        # CONVERTS UNITS TO WATTS #

Thanks for that suggestion, I’m now at work on nights so will try it in the morning

Also, make sure you assign defaults where necessary.

I’ve had a look at the link you posted but don’t really understand the topic, are you able to give me an example for my scenario

template:
  - sensor:
      - name: "Currentcost Temperature"
        unit_of_measurement: '°C'
        state: '{{ state_attr("sensor.current_cost", "Temperature") | float(0) -2 }}'
        device_class: temperature
        state_class: measurement # Add state_class: measurement for long term statistics are required
        availability: "{{ state_attr("sensor.current_cost", "Temperature")|is_number }}"

I’ve removed my additional “sensors” lines & added availability as per the 2 suggestions

template:
  - sensor:
      - name: "Currentcost Temperature"
        unit_of_measurement: '°C'
        state: '{{ state_attr("sensor.current_cost", "Temperature") | float -2 }}'
        device_class: temperature
        state_class: measurement
        availability: '{{ state_attr("sensor.current_cost", "Temperature")|is_number }}'
  
      - name: "Currentcost Electricity"
        unit_of_measurement: 'W'
        state: '{{ state_attr("sensor.current_cost", "Appliance 0")  }}'
        device_class: power
        state_class: measurement
        availability: '{{ state_attr("sensor.current_cost", "Appliance 0")|is_number }}'

then tested it in Developement Tool / Template and all passes ok BUT still the sensors do not appear!!

template:
  - sensor:
      - name: "Currentcost Temperature"
        unit_of_measurement: '°C'
        state: '20.1'
        device_class: temperature
        state_class: measurement
        availability: 'True'
  
      - name: "Currentcost Electricity"
        unit_of_measurement: 'W'
        state: '71'
        device_class: power
        state_class: measurement
        availability: 'True'

The template editor does not generate entities. You have to put it in your config and restart or reload templates.

Also, what relevant errors do you see in your log?

Sorry, what do you mean by “put it in your config”

Your configuration.yaml file.

Ah!, now I understand what you are referring too. Yes I know that thanks, I’m just TESTING it the template editor.
There are still no entities visible in HA after making all the adjustments suggested