home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.72k stars 28.87k forks source link

Utility Meter (hourly reset) not showing unit_of_measurement #95406

Closed EddyK69 closed 9 months ago

EddyK69 commented 1 year ago

The problem

I made an (hourly reset) Utility Meter of a sensor with unit_of_measurement 'mm' (Rain), but the new sensor doesn't show any unit_of_measurement. If I change the sensors attributes with a manually added unit_of_measurement, it drops it when the reset occures.

What version of Home Assistant Core has the issue?

2023.6.3

What was the last working version of Home Assistant Core?

?

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Utility Meter

Link to integration documentation on our website

https://www.home-assistant.io/integrations/utility_meter/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

The unit of sensor.regen_dit_uur (mm) cannot be converted to the unit of previously compiled statistics (None). Generation of long term statistics will be suppressed unless the unit changes back to None or a compatible unit. Go to https://my.home-assistant.io/redirect/developer_statistics to fix this

…bit the sensor is not visible there

Additional information

The original sensor sensor.sonoff_th16_schuur_rain:

state_class: total_increasing
unit_of_measurement: mm
device_class: water
icon: mdi:weather-pouring
friendly_name: Sonoff TH16 Schuur Rain

The Utility Meter sensor.regen_dit_uur:

state_class: total_increasing
source: sensor.sonoff_th16_schuur_rain
status: collecting
last_period: '0'
last_valid_state: '0.0'
meter_period: hourly
cron pattern: 0 * * * *
last_reset: '2023-06-27T18:00:00.003392+00:00'
icon: mdi:weather-rainy
friendly_name: Regen dit uur
home-assistant[bot] commented 1 year ago

Hey there @dgomes, mind taking a look at this issue as it has been labeled with an integration (utility_meter) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `utility_meter` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign utility_meter` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


utility_meter documentation utility_meter source (message by IssueLinks)

Ih8rain2 commented 11 months ago

Hi,

I have more or less the same issue and perhaps even stranger. I have one source sensor for the watts, which I use in an integration to give me the kWh similar to what you have done in your description. After that I use the Utility Meter integration on 4 levels: hourly, daily, monthly and yearly cycle. The monthly and yearly give device_class: energy and unit_of_measurement: 'kWh', exactly as expected. The other 2, hourly and daily don't do that. The numeric value though is correct for all of them..

state_class: total_increasing
source: sensor.cum_kwh_heat_pump
status: collecting
last_period: 0
last_valid_state: 0.040
meter_period: monthly
cron pattern: 0 0 1 * *
last_reset: 2023-07-05T21:46:05.274063+00:00
unit_of_measurement: kWh
device_class: energy
icon: mdi:counter
friendly_name: kWh Heat Pump MTD

vs

state_class: total_increasing
source: sensor.cum_kwh_heat_pump
status: collecting
last_period: 0
last_valid_state: 0.040
meter_period: daily
cron pattern: 0 0 * * *
last_reset: 2023-07-07T23:00:00.046418+00:00
icon: mdi:flash
friendly_name: Heat Pump Energy

I have multiple set-ups for other 'consumers' working flawlessly. I can't find any typo's, I have searched and searched, modified and tried but so far no results.. I have no clue. A true bug perhaps?

the78mole commented 11 months ago

I have the same problem with the daily sensor, not showing unit of measurement. All others (hourly, weekly, monthly, quarterly, yearly) are fine.

I just created this sensors yesterday, because the utility meter I created some weeks/month ago, showed the wrong unit of measurement, namely Wh instead of kWh.

The underlying sensor is a homematic (measuring switch) energy counter and it's energy_counter-reading, which is usually in kWh.

Is there a way to set the unit of measurement for such helpers derived from other sensors after they have been created?

vincenzoca69 commented 11 months ago

idem if I create it with a certain name it gives me the unit of measurement as I change the name it disappears and in any case the problem is with daily, tried today with yearly reset same problem

blalor commented 10 months ago

Same here, although it's inconsistent.

image

Natural Gas Daily, Natural Gas Monthly, and Water Monthly have units, but Water Daily does not.

My config:

utility_meter:
  natural_gas_daily:
    unique_id: d0740580-f30f-4b61-9ecc-4d3b30ddd18a
    source: sensor.meter_gas
    name: Natural Gas Daily
    cycle: daily

  natural_gas_monthly:
    unique_id: eccfa12d-4d46-4615-95d6-2c2f789f8f39
    source: sensor.meter_gas
    name: Natural Gas Monthly

    ## reset manually; read date is inconsistent
    # cycle: monthly

  water_daily:
    unique_id: 8289b887-cddc-4e14-98fe-6d8ac2673779
    source: sensor.meter_water
    name: Water Daily
    cycle: daily

  water_monthly:
    unique_id: 10353dfd-449f-45ab-8f47-e17f87e4e158
    source: sensor.meter_water
    name: Water Monthly

    ## reset manually; read date is inconsistent
    # cycle: monthly

The attributes on sensor.meter_gas show

state_class: total_increasing
Message Type: SCM
ID: 46510694
Type: 12
TamperPhy: 0
TamperEnc: 0
Consumption: 813780
ChecksumVal: 60701
unit_of_measurement: ft³
device_class: gas
icon: mdi:meter-gas
friendly_name: Gas Meter

and sensor.meter_water:

state_class: total_increasing
Message Type: SCM
ID: 29947133
Type: 13
TamperPhy: 0
TamperEnc: 0
Consumption: 88429
ChecksumVal: 33263
unit_of_measurement: ft³
device_class: water
icon: mdi:gauge
friendly_name: Water Meter
Giel538 commented 10 months ago

Same problem here. I have 4 identical sensors for my meter readings (import low and high and export low and high). For all of them i created utility sensors. Two are working correctly and showing kWh. The other 2 dont.