We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Upgrade to Python 3.12
After HA 2024.2.0 is release we could upgrade alle python dependencies to Python 3.12
Also all github action can run on python 3.12

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `custom_components/powercalc/sensors/utility_meter.py`
Content:
```
1 from __future__ import annotations
2 
3 import inspect
4 import logging
5 from decimal import Decimal
6 from typing import cast
7 
8 import homeassistant.helpers.entity_registry as er
9 from homeassistant.components.select import DOMAIN as SELECT_DOMAIN
10 from homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN
11 from homeassistant.components.utility_meter.const import (
12     DATA_TARIFF_SENSORS,
13     DATA_UTILITY,
14 )
15 from homeassistant.components.utility_meter.select import TariffSelect
16 from homeassistant.components.utility_meter.sensor import UtilityMeterSensor
17 from homeassistant.core import HomeAssistant
18 from homeassistant.helpers.entity_component import EntityComponent
19 from homeassistant.helpers.typing import StateType
20 
21 from custom_components.powercalc.const import (
22     CONF_CREATE_UTILITY_METERS,
23     CONF_ENERGY_SENSOR_PRECISION,
24     CONF_IGNORE_UNAVAILABLE_STATE, CONF_UTILITY_METER_OFFSET,
25     CONF_UTILITY_METER_TARIFFS,
26     CONF_UTILITY_METER_TYPES,
27     DEFAULT_ENERGY_SENSOR_PRECISION,
28     DOMAIN,
29 )
30 
31 from .abstract import BaseEntity
32 from .energy import EnergySensor, RealEnergySensor
33 
34 _LOGGER = logging.getLogger(__name__)
35 
36 GENERAL_TARIFF = "general"
37 
38 
39 async def create_utility_meters(
40     hass: HomeAssistant,
41     energy_sensor: EnergySensor,
42     sensor_config: dict,
43     net_consumption: bool = False,
44 ) -> list[VirtualUtilityMeter]:
45     """Create the utility meters."""
46     if not sensor_config.get(CONF_CREATE_UTILITY_METERS):
47         return []
48 
49     utility_meters = []
50 
51     if DATA_UTILITY not in hass.data:  # pragma: no cover
52         hass.data[DATA_UTILITY] = {}
53 
54     tariffs = sensor_config.get(CONF_UTILITY_METER_TARIFFS)
55     meter_types = sensor_config.get(CONF_UTILITY_METER_TYPES)
56     for meter_type in meter_types:  # type: ignore
57         tariff_sensors = []
58 
59         name = f"{energy_sensor.name} {meter_type}"
60         entity_id = f"{energy_sensor.entity_id}_{meter_type}"
61         unique_id = None
62         if energy_sensor.unique_id:
63             unique_id = f"{energy_sensor.unique_id}_{meter_type}"
64 
65         # Prevent duplicate creation of utility meter. See #1322
66         if isinstance(energy_sensor, RealEnergySensor) and unique_id:
67             entity_registry = er.async_get(hass)
68             existing_entity_id = entity_registry.async_get_entity_id(
69                 domain=SENSOR_DOMAIN,
70                 platform=DOMAIN,
71                 unique_id=unique_id,
72             )
73             if existing_entity_id and hass.states.get(existing_entity_id):
74                 continue  # pragma: no cover
75 
76         # Create generic utility meter (no specific tariffs)
77         if not tariffs or GENERAL_TARIFF in tariffs:
78             utility_meter = await create_utility_meter(
79                 energy_sensor.entity_id,
80                 entity_id,
81                 name,
82                 sensor_config,
83                 meter_type,
84                 unique_id,
85                 net_consumption=net_consumption,
86             )
87             tariff_sensors.append(utility_meter)
88             utility_meters.append(utility_meter)
89 
90         # Create utility meter for each tariff, and the tariff select entity which allows you to select a tariff.
91         if tariffs:
92             filtered_tariffs = tariffs = [
93                 t for t in list(tariffs) if t != GENERAL_TARIFF
94             ]
95             tariff_select = await create_tariff_select(
96                 filtered_tariffs,
97                 hass,
98                 name,
99                 unique_id,
100             )
101 
102             for tariff in filtered_tariffs:
103                 utility_meter = await create_utility_meter(
104                     energy_sensor.entity_id,
105                     entity_id,
106                     name,
107                     sensor_config,
108                     meter_type,
109                     unique_id,
110                     tariff,
111                     tariff_select.entity_id,
112                 )
113                 tariff_sensors.append(utility_meter)
114                 utility_meters.append(utility_meter)
115 
116         hass.data[DATA_UTILITY][entity_id] = {DATA_TARIFF_SENSORS: tariff_sensors}
117 
118     return utility_meters
119 
120 
121 async def create_tariff_select(
122     tariffs: list,
123     hass: HomeAssistant,
124     name: str,
125     unique_id: str | None,
126 ) -> TariffSelect:
127     """Create tariff selection entity."""
128     _LOGGER.debug("Creating utility_meter tariff select: %s", name)
129 
130     select_component = cast(EntityComponent, hass.data[SELECT_DOMAIN])
131     select_unique_id = None
132     if unique_id:
133         select_unique_id = f"{unique_id}_select"
134 
135     tariff_select = TariffSelect(
136         name,
137         tariffs,
138         select_unique_id,
139     )
140 
141     await select_component.async_add_entities([tariff_select])
142 
143     return tariff_select
144 
145 
146 async def create_utility_meter(
147     source_entity: str,
148     entity_id: str,
149     name: str,
150     sensor_config: dict,
151     meter_type: str,
152     unique_id: str | None = None,
153     tariff: str | None = None,
154     tariff_entity: str | None = None,
155     net_consumption: bool = False,
156 ) -> VirtualUtilityMeter:
157     """Create a utility meter entity, one per tariff."""
158     parent_meter = entity_id
159     if tariff:
160         name = f"{name} {tariff}"
161         entity_id = f"{entity_id}_{tariff}"
162         if unique_id:
163             unique_id = f"{unique_id}_{tariff}"
164 
165     _LOGGER.debug("Creating utility_meter sensor: %s (entity_id=%s)", name, entity_id)
166 
167     params = {
168         "source_entity": source_entity,
169         "name": name,
170         "meter_type": meter_type,
171         "meter_offset": sensor_config.get(CONF_UTILITY_METER_OFFSET),
172         "net_consumption": net_consumption,
173         "tariff": tariff,
174         "tariff_entity": tariff_entity,
175     }
176 
177     signature = inspect.signature(UtilityMeterSensor.__init__)
178     if "parent_meter" in signature.parameters:
179         params["parent_meter"] = parent_meter
180     if "delta_values" in signature.parameters:
181         params["delta_values"] = False
182     if "unique_id" in signature.parameters:
183         params["unique_id"] = unique_id
184     if "cron_pattern" in signature.parameters:
185         params["cron_pattern"] = None
186     if "periodically_resetting" in signature.parameters:
187         params["periodically_resetting"] = False
188     if "sensor_always_available" in signature.parameters:
189         params["sensor_always_available"] = sensor_config.get(CONF_IGNORE_UNAVAILABLE_STATE) or False
190 
191     utility_meter = VirtualUtilityMeter(**params)
192     utility_meter.rounding_digits = sensor_config.get(CONF_ENERGY_SENSOR_PRECISION)  # type: ignore
193     utility_meter.entity_id = entity_id
194 
195     return utility_meter
196 
197 
198 class VirtualUtilityMeter(UtilityMeterSensor, BaseEntity):  # type: ignore
199     rounding_digits: int = DEFAULT_ENERGY_SENSOR_PRECISION
200 
201     @property
202     def unique_id(self) -> str | None:
203         """Return the unique id."""
204         return self._attr_unique_id
205 
206     @property
207     def native_value(self) -> Decimal | StateType:
208         """Return the state of the sensor."""
209         if self.rounding_digits and self._state is not None:
210             return round(self._state, self.rounding_digits)
211 
212         return self._state
213
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/custom_components/powercalc/sensors/utility_meter.py b/custom_components/powercalc/sensors/utility_meter.py
--- a/custom_components/powercalc/sensors/utility_meter.py
+++ b/custom_components/powercalc/sensors/utility_meter.py
@@ -21,7 +21,8 @@
 from custom_components.powercalc.const import (
     CONF_CREATE_UTILITY_METERS,
     CONF_ENERGY_SENSOR_PRECISION,
-    CONF_IGNORE_UNAVAILABLE_STATE, CONF_UTILITY_METER_OFFSET,
+    CONF_IGNORE_UNAVAILABLE_STATE,
+    CONF_UTILITY_METER_OFFSET,
     CONF_UTILITY_METER_TARIFFS,
     CONF_UTILITY_METER_TYPES,
     DEFAULT_ENERGY_SENSOR_PRECISION,

{"golden_diff": "diff --git a/custom_components/powercalc/sensors/utility_meter.py b/custom_components/powercalc/sensors/utility_meter.py\n--- a/custom_components/powercalc/sensors/utility_meter.py\n+++ b/custom_components/powercalc/sensors/utility_meter.py\n@@ -21,7 +21,8 @@\n from custom_components.powercalc.const import (\n     CONF_CREATE_UTILITY_METERS,\n     CONF_ENERGY_SENSOR_PRECISION,\n-    CONF_IGNORE_UNAVAILABLE_STATE, CONF_UTILITY_METER_OFFSET,\n+    CONF_IGNORE_UNAVAILABLE_STATE,\n+    CONF_UTILITY_METER_OFFSET,\n     CONF_UTILITY_METER_TARIFFS,\n     CONF_UTILITY_METER_TYPES,\n     DEFAULT_ENERGY_SENSOR_PRECISION,\n", "issue": "Upgrade to Python 3.12\nAfter HA 2024.2.0 is release we could upgrade alle python dependencies to Python 3.12\r\nAlso all github action can run on python 3.12\n", "before_files": [{"content": "from __future__ import annotations\n\nimport inspect\nimport logging\nfrom decimal import Decimal\nfrom typing import cast\n\nimport homeassistant.helpers.entity_registry as er\nfrom homeassistant.components.select import DOMAIN as SELECT_DOMAIN\nfrom homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN\nfrom homeassistant.components.utility_meter.const import (\n    DATA_TARIFF_SENSORS,\n    DATA_UTILITY,\n)\nfrom homeassistant.components.utility_meter.select import TariffSelect\nfrom homeassistant.components.utility_meter.sensor import UtilityMeterSensor\nfrom homeassistant.core import HomeAssistant\nfrom homeassistant.helpers.entity_component import EntityComponent\nfrom homeassistant.helpers.typing import StateType\n\nfrom custom_components.powercalc.const import (\n    CONF_CREATE_UTILITY_METERS,\n    CONF_ENERGY_SENSOR_PRECISION,\n    CONF_IGNORE_UNAVAILABLE_STATE, CONF_UTILITY_METER_OFFSET,\n    CONF_UTILITY_METER_TARIFFS,\n    CONF_UTILITY_METER_TYPES,\n    DEFAULT_ENERGY_SENSOR_PRECISION,\n    DOMAIN,\n)\n\nfrom .abstract import BaseEntity\nfrom .energy import EnergySensor, RealEnergySensor\n\n_LOGGER = logging.getLogger(__name__)\n\nGENERAL_TARIFF = \"general\"\n\n\nasync def create_utility_meters(\n    hass: HomeAssistant,\n    energy_sensor: EnergySensor,\n    sensor_config: dict,\n    net_consumption: bool = False,\n) -> list[VirtualUtilityMeter]:\n    \"\"\"Create the utility meters.\"\"\"\n    if not sensor_config.get(CONF_CREATE_UTILITY_METERS):\n        return []\n\n    utility_meters = []\n\n    if DATA_UTILITY not in hass.data:  # pragma: no cover\n        hass.data[DATA_UTILITY] = {}\n\n    tariffs = sensor_config.get(CONF_UTILITY_METER_TARIFFS)\n    meter_types = sensor_config.get(CONF_UTILITY_METER_TYPES)\n    for meter_type in meter_types:  # type: ignore\n        tariff_sensors = []\n\n        name = f\"{energy_sensor.name} {meter_type}\"\n        entity_id = f\"{energy_sensor.entity_id}_{meter_type}\"\n        unique_id = None\n        if energy_sensor.unique_id:\n            unique_id = f\"{energy_sensor.unique_id}_{meter_type}\"\n\n        # Prevent duplicate creation of utility meter. See #1322\n        if isinstance(energy_sensor, RealEnergySensor) and unique_id:\n            entity_registry = er.async_get(hass)\n            existing_entity_id = entity_registry.async_get_entity_id(\n                domain=SENSOR_DOMAIN,\n                platform=DOMAIN,\n                unique_id=unique_id,\n            )\n            if existing_entity_id and hass.states.get(existing_entity_id):\n                continue  # pragma: no cover\n\n        # Create generic utility meter (no specific tariffs)\n        if not tariffs or GENERAL_TARIFF in tariffs:\n            utility_meter = await create_utility_meter(\n                energy_sensor.entity_id,\n                entity_id,\n                name,\n                sensor_config,\n                meter_type,\n                unique_id,\n                net_consumption=net_consumption,\n            )\n            tariff_sensors.append(utility_meter)\n            utility_meters.append(utility_meter)\n\n        # Create utility meter for each tariff, and the tariff select entity which allows you to select a tariff.\n        if tariffs:\n            filtered_tariffs = tariffs = [\n                t for t in list(tariffs) if t != GENERAL_TARIFF\n            ]\n            tariff_select = await create_tariff_select(\n                filtered_tariffs,\n                hass,\n                name,\n                unique_id,\n            )\n\n            for tariff in filtered_tariffs:\n                utility_meter = await create_utility_meter(\n                    energy_sensor.entity_id,\n                    entity_id,\n                    name,\n                    sensor_config,\n                    meter_type,\n                    unique_id,\n                    tariff,\n                    tariff_select.entity_id,\n                )\n                tariff_sensors.append(utility_meter)\n                utility_meters.append(utility_meter)\n\n        hass.data[DATA_UTILITY][entity_id] = {DATA_TARIFF_SENSORS: tariff_sensors}\n\n    return utility_meters\n\n\nasync def create_tariff_select(\n    tariffs: list,\n    hass: HomeAssistant,\n    name: str,\n    unique_id: str | None,\n) -> TariffSelect:\n    \"\"\"Create tariff selection entity.\"\"\"\n    _LOGGER.debug(\"Creating utility_meter tariff select: %s\", name)\n\n    select_component = cast(EntityComponent, hass.data[SELECT_DOMAIN])\n    select_unique_id = None\n    if unique_id:\n        select_unique_id = f\"{unique_id}_select\"\n\n    tariff_select = TariffSelect(\n        name,\n        tariffs,\n        select_unique_id,\n    )\n\n    await select_component.async_add_entities([tariff_select])\n\n    return tariff_select\n\n\nasync def create_utility_meter(\n    source_entity: str,\n    entity_id: str,\n    name: str,\n    sensor_config: dict,\n    meter_type: str,\n    unique_id: str | None = None,\n    tariff: str | None = None,\n    tariff_entity: str | None = None,\n    net_consumption: bool = False,\n) -> VirtualUtilityMeter:\n    \"\"\"Create a utility meter entity, one per tariff.\"\"\"\n    parent_meter = entity_id\n    if tariff:\n        name = f\"{name} {tariff}\"\n        entity_id = f\"{entity_id}_{tariff}\"\n        if unique_id:\n            unique_id = f\"{unique_id}_{tariff}\"\n\n    _LOGGER.debug(\"Creating utility_meter sensor: %s (entity_id=%s)\", name, entity_id)\n\n    params = {\n        \"source_entity\": source_entity,\n        \"name\": name,\n        \"meter_type\": meter_type,\n        \"meter_offset\": sensor_config.get(CONF_UTILITY_METER_OFFSET),\n        \"net_consumption\": net_consumption,\n        \"tariff\": tariff,\n        \"tariff_entity\": tariff_entity,\n    }\n\n    signature = inspect.signature(UtilityMeterSensor.__init__)\n    if \"parent_meter\" in signature.parameters:\n        params[\"parent_meter\"] = parent_meter\n    if \"delta_values\" in signature.parameters:\n        params[\"delta_values\"] = False\n    if \"unique_id\" in signature.parameters:\n        params[\"unique_id\"] = unique_id\n    if \"cron_pattern\" in signature.parameters:\n        params[\"cron_pattern\"] = None\n    if \"periodically_resetting\" in signature.parameters:\n        params[\"periodically_resetting\"] = False\n    if \"sensor_always_available\" in signature.parameters:\n        params[\"sensor_always_available\"] = sensor_config.get(CONF_IGNORE_UNAVAILABLE_STATE) or False\n\n    utility_meter = VirtualUtilityMeter(**params)\n    utility_meter.rounding_digits = sensor_config.get(CONF_ENERGY_SENSOR_PRECISION)  # type: ignore\n    utility_meter.entity_id = entity_id\n\n    return utility_meter\n\n\nclass VirtualUtilityMeter(UtilityMeterSensor, BaseEntity):  # type: ignore\n    rounding_digits: int = DEFAULT_ENERGY_SENSOR_PRECISION\n\n    @property\n    def unique_id(self) -> str | None:\n        \"\"\"Return the unique id.\"\"\"\n        return self._attr_unique_id\n\n    @property\n    def native_value(self) -> Decimal | StateType:\n        \"\"\"Return the state of the sensor.\"\"\"\n        if self.rounding_digits and self._state is not None:\n            return round(self._state, self.rounding_digits)\n\n        return self._state\n", "path": "custom_components/powercalc/sensors/utility_meter.py"}], "after_files": [{"content": "from __future__ import annotations\n\nimport inspect\nimport logging\nfrom decimal import Decimal\nfrom typing import cast\n\nimport homeassistant.helpers.entity_registry as er\nfrom homeassistant.components.select import DOMAIN as SELECT_DOMAIN\nfrom homeassistant.components.sensor import DOMAIN as SENSOR_DOMAIN\nfrom homeassistant.components.utility_meter.const import (\n    DATA_TARIFF_SENSORS,\n    DATA_UTILITY,\n)\nfrom homeassistant.components.utility_meter.select import TariffSelect\nfrom homeassistant.components.utility_meter.sensor import UtilityMeterSensor\nfrom homeassistant.core import HomeAssistant\nfrom homeassistant.helpers.entity_component import EntityComponent\nfrom homeassistant.helpers.typing import StateType\n\nfrom custom_components.powercalc.const import (\n    CONF_CREATE_UTILITY_METERS,\n    CONF_ENERGY_SENSOR_PRECISION,\n    CONF_IGNORE_UNAVAILABLE_STATE,\n    CONF_UTILITY_METER_OFFSET,\n    CONF_UTILITY_METER_TARIFFS,\n    CONF_UTILITY_METER_TYPES,\n    DEFAULT_ENERGY_SENSOR_PRECISION,\n    DOMAIN,\n)\n\nfrom .abstract import BaseEntity\nfrom .energy import EnergySensor, RealEnergySensor\n\n_LOGGER = logging.getLogger(__name__)\n\nGENERAL_TARIFF = \"general\"\n\n\nasync def create_utility_meters(\n    hass: HomeAssistant,\n    energy_sensor: EnergySensor,\n    sensor_config: dict,\n    net_consumption: bool = False,\n) -> list[VirtualUtilityMeter]:\n    \"\"\"Create the utility meters.\"\"\"\n    if not sensor_config.get(CONF_CREATE_UTILITY_METERS):\n        return []\n\n    utility_meters = []\n\n    if DATA_UTILITY not in hass.data:  # pragma: no cover\n        hass.data[DATA_UTILITY] = {}\n\n    tariffs = sensor_config.get(CONF_UTILITY_METER_TARIFFS)\n    meter_types = sensor_config.get(CONF_UTILITY_METER_TYPES)\n    for meter_type in meter_types:  # type: ignore\n        tariff_sensors = []\n\n        name = f\"{energy_sensor.name} {meter_type}\"\n        entity_id = f\"{energy_sensor.entity_id}_{meter_type}\"\n        unique_id = None\n        if energy_sensor.unique_id:\n            unique_id = f\"{energy_sensor.unique_id}_{meter_type}\"\n\n        # Prevent duplicate creation of utility meter. See #1322\n        if isinstance(energy_sensor, RealEnergySensor) and unique_id:\n            entity_registry = er.async_get(hass)\n            existing_entity_id = entity_registry.async_get_entity_id(\n                domain=SENSOR_DOMAIN,\n                platform=DOMAIN,\n                unique_id=unique_id,\n            )\n            if existing_entity_id and hass.states.get(existing_entity_id):\n                continue  # pragma: no cover\n\n        # Create generic utility meter (no specific tariffs)\n        if not tariffs or GENERAL_TARIFF in tariffs:\n            utility_meter = await create_utility_meter(\n                energy_sensor.entity_id,\n                entity_id,\n                name,\n                sensor_config,\n                meter_type,\n                unique_id,\n                net_consumption=net_consumption,\n            )\n            tariff_sensors.append(utility_meter)\n            utility_meters.append(utility_meter)\n\n        # Create utility meter for each tariff, and the tariff select entity which allows you to select a tariff.\n        if tariffs:\n            filtered_tariffs = tariffs = [\n                t for t in list(tariffs) if t != GENERAL_TARIFF\n            ]\n            tariff_select = await create_tariff_select(\n                filtered_tariffs,\n                hass,\n                name,\n                unique_id,\n            )\n\n            for tariff in filtered_tariffs:\n                utility_meter = await create_utility_meter(\n                    energy_sensor.entity_id,\n                    entity_id,\n                    name,\n                    sensor_config,\n                    meter_type,\n                    unique_id,\n                    tariff,\n                    tariff_select.entity_id,\n                )\n                tariff_sensors.append(utility_meter)\n                utility_meters.append(utility_meter)\n\n        hass.data[DATA_UTILITY][entity_id] = {DATA_TARIFF_SENSORS: tariff_sensors}\n\n    return utility_meters\n\n\nasync def create_tariff_select(\n    tariffs: list,\n    hass: HomeAssistant,\n    name: str,\n    unique_id: str | None,\n) -> TariffSelect:\n    \"\"\"Create tariff selection entity.\"\"\"\n    _LOGGER.debug(\"Creating utility_meter tariff select: %s\", name)\n\n    select_component = cast(EntityComponent, hass.data[SELECT_DOMAIN])\n    select_unique_id = None\n    if unique_id:\n        select_unique_id = f\"{unique_id}_select\"\n\n    tariff_select = TariffSelect(\n        name,\n        tariffs,\n        select_unique_id,\n    )\n\n    await select_component.async_add_entities([tariff_select])\n\n    return tariff_select\n\n\nasync def create_utility_meter(\n    source_entity: str,\n    entity_id: str,\n    name: str,\n    sensor_config: dict,\n    meter_type: str,\n    unique_id: str | None = None,\n    tariff: str | None = None,\n    tariff_entity: str | None = None,\n    net_consumption: bool = False,\n) -> VirtualUtilityMeter:\n    \"\"\"Create a utility meter entity, one per tariff.\"\"\"\n    parent_meter = entity_id\n    if tariff:\n        name = f\"{name} {tariff}\"\n        entity_id = f\"{entity_id}_{tariff}\"\n        if unique_id:\n            unique_id = f\"{unique_id}_{tariff}\"\n\n    _LOGGER.debug(\"Creating utility_meter sensor: %s (entity_id=%s)\", name, entity_id)\n\n    params = {\n        \"source_entity\": source_entity,\n        \"name\": name,\n        \"meter_type\": meter_type,\n        \"meter_offset\": sensor_config.get(CONF_UTILITY_METER_OFFSET),\n        \"net_consumption\": net_consumption,\n        \"tariff\": tariff,\n        \"tariff_entity\": tariff_entity,\n    }\n\n    signature = inspect.signature(UtilityMeterSensor.__init__)\n    if \"parent_meter\" in signature.parameters:\n        params[\"parent_meter\"] = parent_meter\n    if \"delta_values\" in signature.parameters:\n        params[\"delta_values\"] = False\n    if \"unique_id\" in signature.parameters:\n        params[\"unique_id\"] = unique_id\n    if \"cron_pattern\" in signature.parameters:\n        params[\"cron_pattern\"] = None\n    if \"periodically_resetting\" in signature.parameters:\n        params[\"periodically_resetting\"] = False\n    if \"sensor_always_available\" in signature.parameters:\n        params[\"sensor_always_available\"] = sensor_config.get(CONF_IGNORE_UNAVAILABLE_STATE) or False\n\n    utility_meter = VirtualUtilityMeter(**params)\n    utility_meter.rounding_digits = sensor_config.get(CONF_ENERGY_SENSOR_PRECISION)  # type: ignore\n    utility_meter.entity_id = entity_id\n\n    return utility_meter\n\n\nclass VirtualUtilityMeter(UtilityMeterSensor, BaseEntity):  # type: ignore\n    rounding_digits: int = DEFAULT_ENERGY_SENSOR_PRECISION\n\n    @property\n    def unique_id(self) -> str | None:\n        \"\"\"Return the unique id.\"\"\"\n        return self._attr_unique_id\n\n    @property\n    def native_value(self) -> Decimal | StateType:\n        \"\"\"Return the state of the sensor.\"\"\"\n        if self.rounding_digits and self._state is not None:\n            return round(self._state, self.rounding_digits)\n\n        return self._state\n", "path": "custom_components/powercalc/sensors/utility_meter.py"}]}