Fix calculating gas cost for gas measured in ft3 (#78327)
This commit is contained in:
parent
b5402f9b57
commit
8a9edea2c1
2 changed files with 8 additions and 3 deletions
|
@ -20,6 +20,7 @@ from homeassistant.const import (
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
ENERGY_MEGA_WATT_HOUR,
|
ENERGY_MEGA_WATT_HOUR,
|
||||||
ENERGY_WATT_HOUR,
|
ENERGY_WATT_HOUR,
|
||||||
|
VOLUME_CUBIC_FEET,
|
||||||
VOLUME_CUBIC_METERS,
|
VOLUME_CUBIC_METERS,
|
||||||
)
|
)
|
||||||
from homeassistant.core import (
|
from homeassistant.core import (
|
||||||
|
@ -44,7 +45,7 @@ SUPPORTED_STATE_CLASSES = [
|
||||||
SensorStateClass.TOTAL_INCREASING,
|
SensorStateClass.TOTAL_INCREASING,
|
||||||
]
|
]
|
||||||
VALID_ENERGY_UNITS = [ENERGY_WATT_HOUR, ENERGY_KILO_WATT_HOUR, ENERGY_MEGA_WATT_HOUR]
|
VALID_ENERGY_UNITS = [ENERGY_WATT_HOUR, ENERGY_KILO_WATT_HOUR, ENERGY_MEGA_WATT_HOUR]
|
||||||
VALID_ENERGY_UNITS_GAS = [VOLUME_CUBIC_METERS] + VALID_ENERGY_UNITS
|
VALID_ENERGY_UNITS_GAS = [VOLUME_CUBIC_FEET, VOLUME_CUBIC_METERS] + VALID_ENERGY_UNITS
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ from homeassistant.const import (
|
||||||
ENERGY_MEGA_WATT_HOUR,
|
ENERGY_MEGA_WATT_HOUR,
|
||||||
ENERGY_WATT_HOUR,
|
ENERGY_WATT_HOUR,
|
||||||
STATE_UNKNOWN,
|
STATE_UNKNOWN,
|
||||||
|
VOLUME_CUBIC_FEET,
|
||||||
VOLUME_CUBIC_METERS,
|
VOLUME_CUBIC_METERS,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers import entity_registry as er
|
from homeassistant.helpers import entity_registry as er
|
||||||
|
@ -841,10 +842,13 @@ async def test_cost_sensor_handle_price_units(
|
||||||
assert state.state == "20.0"
|
assert state.state == "20.0"
|
||||||
|
|
||||||
|
|
||||||
async def test_cost_sensor_handle_gas(hass, hass_storage, setup_integration) -> None:
|
@pytest.mark.parametrize("unit", (VOLUME_CUBIC_FEET, VOLUME_CUBIC_METERS))
|
||||||
|
async def test_cost_sensor_handle_gas(
|
||||||
|
hass, hass_storage, setup_integration, unit
|
||||||
|
) -> None:
|
||||||
"""Test gas cost price from sensor entity."""
|
"""Test gas cost price from sensor entity."""
|
||||||
energy_attributes = {
|
energy_attributes = {
|
||||||
ATTR_UNIT_OF_MEASUREMENT: VOLUME_CUBIC_METERS,
|
ATTR_UNIT_OF_MEASUREMENT: unit,
|
||||||
ATTR_STATE_CLASS: SensorStateClass.TOTAL_INCREASING,
|
ATTR_STATE_CLASS: SensorStateClass.TOTAL_INCREASING,
|
||||||
}
|
}
|
||||||
energy_data = data.EnergyManager.default_preferences()
|
energy_data = data.EnergyManager.default_preferences()
|
||||||
|
|
Loading…
Add table
Reference in a new issue