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 #