mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Add country code to co2signal state attributes (#53512)
This commit is contained in:
parent
f28d8fae2f
commit
962ddf664c
@ -100,7 +100,10 @@ class CO2Sensor(update_coordinator.CoordinatorEntity[CO2SignalResponse], SensorE
|
|||||||
name = f"{extra_name} - {name}"
|
name = f"{extra_name} - {name}"
|
||||||
|
|
||||||
self._attr_name = name
|
self._attr_name = name
|
||||||
self._attr_extra_state_attributes = {ATTR_ATTRIBUTION: ATTRIBUTION}
|
self._attr_extra_state_attributes = {
|
||||||
|
"country_code": coordinator.data["countryCode"],
|
||||||
|
ATTR_ATTRIBUTION: ATTRIBUTION,
|
||||||
|
}
|
||||||
self._attr_device_info = {
|
self._attr_device_info = {
|
||||||
ATTR_IDENTIFIERS: {(DOMAIN, coordinator.entry_id)},
|
ATTR_IDENTIFIERS: {(DOMAIN, coordinator.entry_id)},
|
||||||
ATTR_NAME: "CO2 signal",
|
ATTR_NAME: "CO2 signal",
|
||||||
|
@ -218,12 +218,14 @@ async def test_import(hass: HomeAssistant) -> None:
|
|||||||
assert state.state == "45.99"
|
assert state.state == "45.99"
|
||||||
assert state.name == "CO2 intensity"
|
assert state.name == "CO2 intensity"
|
||||||
assert state.attributes["unit_of_measurement"] == "gCO2eq/kWh"
|
assert state.attributes["unit_of_measurement"] == "gCO2eq/kWh"
|
||||||
|
assert state.attributes["country_code"] == "FR"
|
||||||
|
|
||||||
state = hass.states.get("sensor.grid_fossil_fuel_percentage")
|
state = hass.states.get("sensor.grid_fossil_fuel_percentage")
|
||||||
assert state is not None
|
assert state is not None
|
||||||
assert state.state == "5.46"
|
assert state.state == "5.46"
|
||||||
assert state.name == "Grid fossil fuel percentage"
|
assert state.name == "Grid fossil fuel percentage"
|
||||||
assert state.attributes["unit_of_measurement"] == "%"
|
assert state.attributes["unit_of_measurement"] == "%"
|
||||||
|
assert state.attributes["country_code"] == "FR"
|
||||||
|
|
||||||
|
|
||||||
async def test_import_abort_existing_home(hass: HomeAssistant) -> None:
|
async def test_import_abort_existing_home(hass: HomeAssistant) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user