Issue with setting up templates, etc

Hi guys i’m getting the fellow errors but for the life of me cant fix ti. i coppied it from Github repos. the main issues are happening from Server1_CPU1_Temperature

Error:

Invalid config for [sensor.template]: expected dictionary for dictionary value @ data[‘sensors’]. Got None
extra keys not allowed @ data[‘Server1_CPU1_Temperature’]. Got OrderedDict([(‘state’, “{{states(‘sensor.SRV1CPU1Temp’)}}”), (‘unit_of_measurement’, ‘°C’), (‘device_class’, ‘temperature’), (‘state_class’, ‘measurement’)])
extra keys not allowed @ data[‘Server1_CPU2_Temperature’]. Got OrderedDict([(‘state’, “{{states(‘sensor.SRV1CPU2Temp’)}}”), (‘unit_of_measurement’, ‘°C’), (‘device_class’, ‘temperature’), (‘state_class’, ‘measurement’)])
extra keys not allowed @ data[‘Server1_Fan_Speed_Avg’]. Got OrderedDict([(‘state’, “{{ (( states(‘sensor.SRV1Fan1Speed’) | float +\n states(‘sensor.SRV1Fan2Speed’) | float) / 2) | round(0) }}\n”), (‘unit_of_measurement’, ‘RPM’), (‘icon’, ‘mdi:fan’)])
extra keys not allowed @ data[‘Server1_Inlet_Temperature’]. Got OrderedDict([(‘state’, “{{states(‘sensor.SRV1IntakeTemp’)}}”), (‘unit_of_measurement’, ‘°C’), (‘device_class’, ‘temperature’), (‘state_class’, ‘measurement’)])
extra keys not allowed @ data[‘Server1_Power’]. Got OrderedDict([(‘state’, “{{states(‘sensor.SRV1Power’)}}”), (‘unit_of_measurement’, ‘W’), (‘device_class’, ‘power’), (‘state_class’, ‘measurement’)])
extra keys not allowed @ data[‘Server2_CPU1_Temperature’]. Got OrderedDict([(‘state’, “{{states(‘sensor.SRV2CPU1Temp’)}}”), (‘unit_of_measurement’, ‘°C’), (‘device_class’, ‘temperature’), (‘state_class’, ‘measurement’)])
extra keys not allowed @ data[‘Server2_Fan_Speed_Avg’]. Got OrderedDict([(‘state’, “{{ (( states(‘sensor.SRV2Fan1Speed’) | float / 1) | round(0) }}\n”), (‘unit_of_measurement’, ‘RPM’), (‘icon’, ‘mdi:fan’)])
extra keys not allowed @ data[‘Server2_Inlet_Temperature’]. Got OrderedDict([(‘state’, “{{states(‘sensor.SRV2IntakeTemp’)}}”), (‘unit_of_measurement’, ‘°C’), (‘device_class’, ‘temperature’), (‘state_class’, ‘measurement’)])
extra keys not allowed @ data[‘Server2_Power’]. Got OrderedDict([(‘state’, “{{states(‘sensor.SRV2Power’)}}”), (‘unit_of_measurement’, ‘W’), (‘device_class’, ‘power’), (‘state_class’, ‘measurement’)]). (See ?, line ?).

My code:

#- platform: template
#  sensors:
#    last_alexa:
#      value_template: >
#        {{ states.media_player | selectattr('attributes.last_called','eq',true) | map(attribute='entity_id') | first }}
#Server1 IPMI Sensors
  - platform: mqtt
    name: "SRV1CPU1Temp"
    state_topic: "homeassistant/sensor/srv1/cpu2"
    unit_of_measurement: '°C'
    value_template: "{{((value | float) / 10) | float}}"
  - platform: mqtt
    name: "SRV1CPU2Temp"
    state_topic: "homeassistant/sensor/srv1/cpu2"
    unit_of_measurement: '°C'
    value_template: "{{((value | float) / 10) | float}}"
  - platform: mqtt
    name: "SRV1CPUUsage"
    state_topic: "homeassistant/sensor/srv1/cpuuse"
    unit_of_measurement: '%'
  - platform: mqtt
    name: "SRV1Intak Temp"
    state_topic: "homeassistant/sensor/srv1/intemp"
    unit_of_measurement: '°C'
    value_template: "{{((value | float) / 10) | float}}"
  - platform: mqtt
    name: "SRV1Fan1Speed"
    state_topic: "homeassistant/sensor/srv1/fan1"
    value_template: '{{ value | multiply(0.001) | round(1) }}'
    unit_of_measurement: 'kRPM'
  - platform: mqtt
    name: "SRV1Fan2Speed"
    state_topic: "homeassistant/sensor/srv1/fan2"
    value_template: '{{ value | multiply(0.001) | round(1) }}'
    unit_of_measurement: 'kRPM'
  - platform: mqtt
    name: "SRV1Power"
    state_topic: "homeassistant/sensor/srv1/power"
    unit_of_measurement: 'W'

    
#Server1 IPMI Sensors
  - platform: mqtt
    name: "SRV2CPU1Temp"
    state_topic: "homeassistant/sensor/srv2/cpu2"
    unit_of_measurement: '°C'
    value_template: "{{((value | float) / 10) | float}}"
  - platform: mqtt
    name: "SRV2IntakeTemp"
    state_topic: "homeassistant/sensor/srv2/intemp"
    unit_of_measurement: '°C'
    value_template: "{{((value | float) / 10) | float}}"
  - platform: mqtt
    name: "SRV2Fan1Speed"
    state_topic: "homeassistant/sensor/srv2/fan1"
    value_template: '{{ value | multiply(0.001) | round(1) }}'
    unit_of_measurement: 'kRPM'
  - platform: mqtt
    name: "SRV2Power"
    state_topic: "homeassistant/sensor/srv2/power"
    unit_of_measurement: 'W'
    

  - platform: integration
    source: sensor.server1_power
    name: "Dell1 Server Energy"
    unit_prefix: k
    unit_time: h
    round: 2
        
  - platform: integration
    source: sensor.server2_power
    name: "Dell2 Server Energy"
    unit_prefix: k
    unit_time: h
    round: 2


  - platform: template
    sensors:    
    Server1_Power:
      state: "{{states('sensor.SRV1Power')}}"
      unit_of_measurement: W
      device_class: power #Power, watts. Not "Energy" i.e. Wh.
      state_class: measurement
    
    Server2_Power:
      state: "{{states('sensor.SRV2Power')}}"
      unit_of_measurement: W
      device_class: power #Power, watts. Not "Energy" i.e. Wh.
      state_class: measurement
    
    Server1_Inlet_Temperature:
      state: "{{states('sensor.SRV1IntakeTemp')}}"
      unit_of_measurement: °C
      device_class: temperature
      state_class: measurement
    
    Server2_Inlet_Temperature:
      state: "{{states('sensor.SRV2IntakeTemp')}}"
      unit_of_measurement: °C
      device_class: temperature
      state_class: measurement
    
    Server1_CPU1_Temperature:
      state: "{{states('sensor.SRV1CPU1Temp')}}"
      unit_of_measurement: °C
      device_class: temperature
      state_class: measurement
    
    Server1_CPU2_Temperature:
      state: "{{states('sensor.SRV1CPU2Temp')}}"
      unit_of_measurement: °C
      device_class: temperature
      state_class: measurement
    
    Server2_CPU1_Temperature:
      state: "{{states('sensor.SRV2CPU1Temp')}}"
      unit_of_measurement: °C
      device_class: temperature
      state_class: measurement
    
    Server1_Fan_Speed_Avg:
      state: >
         {{ (( states('sensor.SRV1Fan1Speed') | float +
                states('sensor.SRV1Fan2Speed') | float) / 2) | round(0) }}
      unit_of_measurement: RPM
      icon: mdi:fan
    
    Server2_Fan_Speed_Avg:
      state: >
         {{ (( states('sensor.SRV2Fan1Speed') | float / 1) | round(0) }}
      unit_of_measurement: RPM
      icon: mdi:fan       

Incorrect indentation.

All lines below sensor: should be indented to the right by two more spaces. EDIT Not simply indentation; it’s the wrong Template Sensor format.

You’re using a mix of “legacy” and “modern” syntax for defining the Template Sensors. state and state_class are “modern” format and aren’t supported in “legacy” format which is what you started to define when you chose to use platform: template .

Although state has a legacy equivalent called value_template, you can’t define state_class directly in a legacy-format Template Sensor.

You should convert it to modern format (because you want state_class) but that means pulling out all the Template Sensors out of the sensors.yaml file because now they must all be defined under the template: key (see example in the documentation). Let me know if you need more help to do that.

In addition, don’t waste your time using uppercase letters when defining an entity_id. Home Assistant only uses lowercase.

Your indentation here is wrong - “Server1_Power” and all the lines below should be indented under sensors:. Having said that, you’re using the old format for mqtt and template sensors, and will have to change eventually. The new format has these in their own files with a slightly different format.

Only for MQTT. Template Sensors can be defined using the “modern” or “legacy” format (which was never deprecated).

They are also using slugs with capital letters:

Thanks everyone for the help after some mucking and suggestions i’ve got it to work. thanks again