Skip to content

Commit

Permalink
remove mac from sensor id
Browse files Browse the repository at this point in the history
  • Loading branch information
jakub.pawlowski committed Apr 8, 2022
1 parent b6b7a6c commit 7f6937e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions custom_components/huawei_solar/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
"active_grid_C_current",
"active_grid_power_factor",
"active_grid_frequency",
"daily_yield_energy",
"accumulated_yield_energy",
"grid_exported_energy",
"grid_accumulated_energy",
"active_grid_A_B_voltage",
Expand Down Expand Up @@ -216,7 +218,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
device_class=DEVICE_CLASS_ENERGY,
parent_sensor=huawei_solar_sensor,
register=ATTR_DAILY_YIELD,
name_prefix="daily_yield",
name_prefix=static_attributes["model_name"] + "_daily_yield",
state_class=STATE_CLASS_MEASUREMENT,
),
HuaweiSolarEntitySensor(
Expand All @@ -226,7 +228,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
device_class=DEVICE_CLASS_ENERGY,
parent_sensor=huawei_solar_sensor,
register=ATTR_ACCUMULATED_YIELD,
name_prefix="total_yield",
name_prefix=static_attributes["model_name"] +"_total_yield",
),
HuaweiSolarEntitySensor(
inverter=inverter,
Expand All @@ -235,7 +237,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
device_class=DEVICE_CLASS_ENERGY,
parent_sensor=huawei_solar_sensor,
register=ATTR_GRID_EXPORTED,
name_prefix="grid_exported",
name_prefix=static_attributes["model_name"] + "_grid_exported",
),
HuaweiSolarEntitySensor(
inverter=inverter,
Expand All @@ -244,7 +246,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
device_class=DEVICE_CLASS_ENERGY,
parent_sensor=huawei_solar_sensor,
register=ATTR_GRID_ACCUMULATED,
name_prefix="grid_accumulated",
name_prefix=static_attributes["model_name"] + "_grid_accumulated",
),
]

Expand Down Expand Up @@ -297,7 +299,7 @@ def __init__(
self.sensor_states = {}
self._attributes = static_attributes
self._name = (
self._attributes["model_name"] + "_" + self._attributes["serial_number"]
self._attributes["model_name"] # + "_" + self._attributes["serial_number"]
)
self._unique_id = self._name
self._pv_strings_voltage = [None] * self._attributes[ATTR_NB_PV_STRINGS]
Expand Down Expand Up @@ -368,7 +370,7 @@ async def async_update(self):
for register in DYNAMIC_ATTR_LIST:
try:
self._attributes[register] = (await self._inverter.get(register)).value
_LOGGER.debug("get register: %s", register)
_LOGGER.debug("get register: %s = %s", register, self._attributes[register])
await asyncio.sleep(DEFAULT_COOLDOWN_INTERVAL)
except (ReadException, ConnectionException) as ex:
_LOGGER.error("could not get register '%s': %s", register, ex)
Expand Down Expand Up @@ -459,7 +461,7 @@ def __init__(
self._register = register
if name_prefix:
self._name = (
name_prefix + "_" + self._parent_sensor._attributes[ATTR_SERIAL_NUMBER]
name_prefix # + "_" + self._parent_sensor._attributes[ATTR_SERIAL_NUMBER]
)
else:
self._name = (
Expand Down

0 comments on commit 7f6937e

Please sign in to comment.