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
72.75k stars 30.46k forks source link

Riemann sum integral no longer accepts custom "unit_of_measurement" #115208

Closed Olen closed 1 month ago

Olen commented 6 months ago

The problem

Until 2024.4 I could have my custom integration set the unit_of_measurement for the Riemann sum integral sensors. After 2024.4 it wil override the unit_of_measurement set in the sensor in the integration and create its own based solely on the source sensor.

This is the root cause of this previous issue: https://github.com/home-assistant/core/issues/114493

The custom plant-integration tries to set the unit_of_measurement for this sensor to "mol/d⋅m²", however that is overwritten by the Riemann integration to be "mol/s⋅m²s" because the source sensors unit_of_measurement is "mol/s⋅m²"

class PlantTotalLightIntegral(IntegrationSensor):
(...)
        self._unit_of_measurement = UNIT_DLI
(...)

What version of Home Assistant Core has the issue?

2024.4

What was the last working version of Home Assistant Core?

2024.3

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Riemann sum integral

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 6 months ago

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

Code owner commands Code owners of `integration` 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 integration` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


integration documentation integration source (message by IssueLinks)

dgomes commented 6 months ago

This is related to https://github.com/home-assistant/core/pull/113932

I don't quite understand your unit... is it mol/d⋅m²or mol⋅m² / d? in which d is day

Olen commented 6 months ago

DLI is a pretty complex calculation, but is measured as mol/m²*day

https://en.wikipedia.org/wiki/Daily_light_integral

dgomes commented 6 months ago

This is very tricky to extract through a string processing method...

mol/(m²d) should IMHO be the proper unit, and can probably be best worked out

Olen commented 6 months ago

The easiest would be if the sensor just accepted the unit that is set in the class (if one is set) as it used to...

ronweikamp commented 4 months ago

I'm happy to believe that this is a side effect of https://github.com/home-assistant/core/pull/113932 , but I cannot yet see why. As far as I can see the integral sensor derived the unit of measurement from the source during a state change and this (existing) functionality was only extracted in a separate method?

issue-triage-workflows[bot] commented 1 month ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

ChristophCaina commented 4 weeks ago

should be reopened, still an issue. I did not recognize the notification from the triage workflow :-(