Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions custom_components/fronius_modbus/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from .const import (
DOMAIN,
ENTITY_PREFIX,
)

_LOGGER = logging.getLogger(__name__)
Expand All @@ -27,6 +28,7 @@ def __init__(self, hass: HomeAssistant, name: str, host: str, port: int, inverte
"""Init hub."""
self._hass = hass
self._name = name
self._entity_prefix = f'{ENTITY_PREFIX}_{name.lower()}_'

self._id = f'{name.lower()}_{host.lower().replace('.','')}'
self.online = True
Expand Down Expand Up @@ -113,6 +115,11 @@ def hub_id(self) -> str:
"""ID for hub."""
return self._id

@property
def entity_prefix(self) -> str:
"""Entity prefix for hub."""
return self._entity_prefix

@callback
def async_add_hub_entity(self, update_callback):
"""Listen for data updates."""
Expand Down
3 changes: 1 addition & 2 deletions custom_components/fronius_modbus/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from .const import (
STORAGE_NUMBER_TYPES,
ENTITY_PREFIX,
)

from homeassistant.core import callback
Expand Down Expand Up @@ -34,7 +33,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities) -> None:
max = number_info[2]['max']

number = FroniusModbusNumber(
ENTITY_PREFIX,
hub.entity_prefix,
hub,
hub.device_info_storage,
number_info[0],
Expand Down
11 changes: 5 additions & 6 deletions custom_components/fronius_modbus/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
INVERTER_STORAGE_SENSOR_TYPES,
METER_SENSOR_TYPES,
STORAGE_SENSOR_TYPES,
ENTITY_PREFIX,
)
from .hub import Hub
from .base import FroniusModbusBaseEntity
Expand All @@ -41,7 +40,7 @@ async def async_setup_entry(

for sensor_info in INVERTER_SENSOR_TYPES.values():
sensor = FroniusModbusSensor(
platform_name = ENTITY_PREFIX,
platform_name = hub.entity_prefix,
hub = hub,
device_info = hub.device_info_inverter,
name = sensor_info[0],
Expand All @@ -56,7 +55,7 @@ async def async_setup_entry(

for sensor_info in INVERTER_SYMO_SENSOR_TYPES.values():
sensor = FroniusModbusSensor(
platform_name = ENTITY_PREFIX,
platform_name = hub.entity_prefix,
hub = hub,
device_info = hub.device_info_inverter,
name = sensor_info[0],
Expand All @@ -73,7 +72,7 @@ async def async_setup_entry(
meter_id = '1'
for sensor_info in METER_SENSOR_TYPES.values():
sensor = FroniusModbusSensor(
platform_name = ENTITY_PREFIX,
platform_name = hub.entity_prefix,
hub = hub,
device_info = hub.get_device_info_meter(meter_id),
name = f'Meter {meter_id} ' + sensor_info[0],
Expand All @@ -89,7 +88,7 @@ async def async_setup_entry(
if hub.storage_configured:
for sensor_info in INVERTER_STORAGE_SENSOR_TYPES.values():
sensor = FroniusModbusSensor(
platform_name = ENTITY_PREFIX,
platform_name = hub.entity_prefix,
hub = hub,
device_info = hub.device_info_inverter,
name = sensor_info[0],
Expand All @@ -104,7 +103,7 @@ async def async_setup_entry(

for sensor_info in STORAGE_SENSOR_TYPES.values():
sensor = FroniusModbusSensor(
platform_name = ENTITY_PREFIX,
platform_name = hub.entity_prefix,
hub = hub,
device_info = hub.device_info_storage,
name = sensor_info[0],
Expand Down