mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Fix attribute check in prometheus exporter (#84321)
* fix attribute check * add test
This commit is contained in:
parent
0265aae247
commit
8a3fc2e82b
@ -396,7 +396,7 @@ class PrometheusMetrics:
|
|||||||
metric.labels(**self._labels(state)).set(value)
|
metric.labels(**self._labels(state)).set(value)
|
||||||
|
|
||||||
def _handle_climate_temp(self, state, attr, metric_name, metric_description):
|
def _handle_climate_temp(self, state, attr, metric_name, metric_description):
|
||||||
if temp := state.attributes.get(attr):
|
if (temp := state.attributes.get(attr)) is not None:
|
||||||
if self._climate_units == UnitOfTemperature.FAHRENHEIT:
|
if self._climate_units == UnitOfTemperature.FAHRENHEIT:
|
||||||
temp = TemperatureConverter.convert(
|
temp = TemperatureConverter.convert(
|
||||||
temp, UnitOfTemperature.FAHRENHEIT, UnitOfTemperature.CELSIUS
|
temp, UnitOfTemperature.FAHRENHEIT, UnitOfTemperature.CELSIUS
|
||||||
|
@ -293,6 +293,12 @@ async def test_climate(client, climate_entities):
|
|||||||
'friendly_name="Ecobee"} 24.0' in body
|
'friendly_name="Ecobee"} 24.0' in body
|
||||||
)
|
)
|
||||||
|
|
||||||
|
assert (
|
||||||
|
'climate_target_temperature_celsius{domain="climate",'
|
||||||
|
'entity="climate.fritzdect",'
|
||||||
|
'friendly_name="Fritz!DECT"} 0.0' in body
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("namespace", [""])
|
@pytest.mark.parametrize("namespace", [""])
|
||||||
async def test_humidifier(client, humidifier_entities):
|
async def test_humidifier(client, humidifier_entities):
|
||||||
@ -1001,6 +1007,23 @@ async def climate_fixture(hass, registry):
|
|||||||
data["climate_2"] = climate_2
|
data["climate_2"] = climate_2
|
||||||
data["climate_2_attributes"] = climate_2_attributes
|
data["climate_2_attributes"] = climate_2_attributes
|
||||||
|
|
||||||
|
climate_3 = registry.async_get_or_create(
|
||||||
|
domain=climate.DOMAIN,
|
||||||
|
platform="test",
|
||||||
|
unique_id="climate_3",
|
||||||
|
unit_of_measurement=TEMP_CELSIUS,
|
||||||
|
suggested_object_id="fritzdect",
|
||||||
|
original_name="Fritz!DECT",
|
||||||
|
)
|
||||||
|
climate_3_attributes = {
|
||||||
|
ATTR_TEMPERATURE: 0,
|
||||||
|
ATTR_CURRENT_TEMPERATURE: 22,
|
||||||
|
ATTR_HVAC_ACTION: climate.HVACAction.OFF,
|
||||||
|
}
|
||||||
|
set_state_with_entry(hass, climate_3, climate.HVACAction.OFF, climate_3_attributes)
|
||||||
|
data["climate_3"] = climate_3
|
||||||
|
data["climate_3_attributes"] = climate_3_attributes
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user