Why these sensors are "invalid"?

I have an Energy Price sensor defined in my template.yaml as:

- sensor:
    - name: Energy Price
      unique_id: energy_price
      icon: mdi:counter
      state_class: total_increasing
      device_class: energy
      unit_of_measurement: USD/kWh
      state: >
        {% set consumption=states('sensor.energy_meter_consumption')|float(0) %}
        {% set fuel_adjustment=consumption*0.04260 %}
        {{ 0.05214 if consumption > 1000 else 0.04989 + fuel_adjustment }}
      availability: "{{  states('sensor.energy_meter_consumption')|is_number }}"

and a Water Meter Consumption sensor defined in my sensors.yaml file as follows:

- platform: template
  sensors:
    # convert value from add-in into statistic
    water_meter_total_gal:
      friendly_name: "Total Water Consumption"
      device_class: water
      unit_of_measurement: gal
      value_template: "{{ (states('sensor.water_meter_consumption') | float)  }}"
      attribute_templates:
        state_class: total_increasing

and they both are included in my configuration.yaml as:

sensor: !include_dir_list includes/sensors/
template: !include includes/templates/template.yaml

those are meant to be used in my Energy Dashboard but for some reason, HA keeps telling me that those are unavailable, Why? I do not get it?


I see the configuration for two sensor entities:

sensor.energy_price
sensor.water_meter_total_gal

The screenshots indicate the following sensor entities are not available:

sensor.energy_meter
sensor.water_meter

The entities that are not available don’t have the same entity_id as the entities in the configuration.

Did you rename the first two entities via the UI or are the entities in the screenshot truly different entities?

1 Like

I don’t know why you get these unavailable warnings, but your Energy Price sensor has the wrong unit_of_measurement.
You are calculating the total_increasing amount of USD paid, so the unit_of_measurement should be USD and not USD/kWh.
Also, I am not sure whether you can use such an Energy Paid sensor in the energy dashboard, but it might be possible if all the used sensors are in USD?

1 Like

Yeah, my bad I just noticed that … something got misconfigured I am using GitHub - mdegat01/addon-amr2mqtt: HA Addon which runs rtlamr to read IDM power meter data and send to MQTT broker and I opened an issue a while ago without any answer.

Probably this change PSA: MQTT Name changes in 2023.8 is affecting that add-on and it just stopped working. I am seeing it receiving data but the sensors are not available to the HA