home-assistant / architecture

Repo to discuss Home Assistant architecture
310 stars 101 forks source link

Add water/fluids to available device classes #697

Closed jensihnow closed 1 year ago

jensihnow commented 2 years ago

Context

With Energy management being a huge success and gas consumption already available a missing puzzle piece is water.

Proposal

Make water available as device class and therefore usable within sensors.

Maybe instead of implementing water it is an option to implement fluid as this would cover others like oil as well. Interestingly, with multiple sorts of carbon / nitrogen available maybe it should be rather fluid_water and fluid_oil.

Water or fluids should be supported similarly as Gas in regard to Energy Management, e.g. on Frontend (Water consumptuon graph) see Lovelace Energy.

Consequences

Water or fluids are most likely very similar to gas, as they are measured in m³/ ft³. It needs a decision if every fluid should be implemented individually or similar like gas in a more generic way covering all gas types.

As one m³ reflects 1,000 liters there could be use-cases where people would rather user liters instead of m³. One could argue having liters is another way of implementing fluids. Obviously this might cause complexity about m³ vs. ft³. I'm actually not sure if ft³ are stored in m³ or ft³ (... Volume of gas, statistics will be stored in m³. ..., see sensor).

The alternative

Using device class gas is an alternative as it is also measured in m³. While it works, it is technically not correct.

Additional note

Hedda commented 2 years ago

Water or fluids are most likely very similar to gas, as they are measured in m³/ ft³. It needs a decision if every fluid should be implemented individually or similar like gas in a more generic way covering all gas types.

I believe there are at least 9 existing integrations that could show running water flow measured in litres or gallons per minute.

Note however that water meter monitoring systems for main incoming drinking water doesn't only measure water usage (m³or ft³) and water flow (l/m or g/m), but also water temperature and pressure in your water pipes/plumbing. That is because water monitoring is not always only monitoring consumption with water as a consumable, users will also want a few more other sensors used to detect leaks and/or environment changes like freezing temperatures risking bursts pipes.

Some of these example water monitoring products do feature integrations which monitor; flow, temperature, and pressure sensors:

Anyway, see these related feature requests with discussion threads in the forum here which shows there is a real demand for this:

Other references from governments that indicate that active water usage monitoring will become more important in the future:

jensihnow commented 2 years ago

Thanks @Hedda for adding all these details.

Pressure (cbar, bar, hPa, inHg, kPa, mbar, Pa, psi) and temperature (°C, °F) are already available as device classes, therefore they could be implemented already within the integrations.

Flow rate is something to consider, especially for fluids. I'm actually wondering if flow-rate only becomes a number at the end, due to impulse counting of the sensor. Maybe there are sensors exposing something like liters per minute?

In this example a pulse sensor is used, which h as 27 counts for 1 liter. Additionally, the example shows _unit_ofmeasurement: "L/hr" in combindation with matchin calculation, as well as _unit_ofmeasurement: "L" being used.

If we could now make this a device class of water or fluid and just name it water we might have what we need to ensure it is properly recorded and displayed e.g. in a dashboard similar/same like the Energy one.

I like the intention of renaming the Energy to Utilities and extend it.

Hedda commented 2 years ago

Flow rate is something to consider, especially for fluids. I'm actually wondering if flow-rate only becomes a number at the end, due to impulse counting of the sensor. Maybe there are sensors exposing something like liters per minute?

Yes, there are indeed, there are many types of volumetric flow meter technologies exposing liter per minute or milliliter per second, others will expose output in volume taken from their flow measurements of meter per second (m/s).

So I personally think that the unit of measurements in Home Assistants integrations should always both be "liter/litre/gallons for volume consumption" as well as "liter/litre/gallon per minute" during active flow when the water is running to activate leak or overconsumption notifications.

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

The impulse counting method is really only used by basic water meters that implement a turbine flow meter such as the utility companies use to measure, as such they only offer an amount of pulses for a set of determined liters or gallons, so guess such measurements will only use for example "P1 Monitor" and "SML sensor" based integrations to help calculate water consumption. (Still, there can be big differences in resolution between different turbine-based water meter sensors.)

Ultrasonic flow meters however do not have any moving parts and instead use ultrasound to measure the velocity to calculate volume flow, thus they can have very highly accurate resolution and offer great properties for clean drinking water meter for homes as they are maintenance-free.

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

https://realpars.com/ultrasonic-flow-meter/

I think those often output meter per second (m/s) and then you need to calculate volume based on pipe diameter ("differential transit time measured by the sensors is directly proportional to the flow velocity in the pipe"). See example:

https://www.pce-instruments.com/eu/measuring-instruments/test-meters/ultrasonic-flow-meter-kat_152137.htm

There are also magnetic flow meters (a.k.a. mag meters, or rather electromagnetic flow meters) which technology that uses Induction to determine the flow of liquid in a pipe does not either have any moving parts but I understand that such flowmeters are much less commonly used for "clean water" (i.e. drinking water / tap water) and are instead more commonly used for "dirty water" (i.e. waste water).

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

PimDoos commented 1 year ago

I'd suggest using 'volume' as a generic device class for measuring incremental meters for both gas and fluids, as we're measuring the volume (in 'L' or 'm³') of a certain substance. This generalizes the class. When measuring a flow of that same substance, I propose the device class to be something like flow or volume_flow, measured in a volume unit per time unit, ex: 'm³/s' or 'l/min'. Examples of usecases:

epenet commented 1 year ago

Sample implementation PR for a new "water" device class (for water consumption): https://github.com/home-assistant/core/pull/80886

jensihnow commented 1 year ago

Love it, thanks to @epenet and @frenck and whoever else contributed to it. Looking forward to 2022.11.🤩

jensihnow commented 1 year ago

This is now available see https://www.home-assistant.io/docs/energy/water and release notes for 2022.11.