Skip to content

Commit

Permalink
refactor: Streamlined constants
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrapan committed Dec 9, 2024
1 parent f8f56a2 commit f0ee3c1
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 63 deletions.
8 changes: 4 additions & 4 deletions custom_components/solarman/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
# return False

if (new_data := {**config_entry.data}) and (new_options := {**config_entry.options}):
bulk_migrate(new_data, new_data, { CONF_SERIAL: CONF_OLD_SERIAL })
bulk_migrate(new_options, new_options, { CONF_HOST: "inverter_host", CONF_PORT: "inverter_port" })
bulk_migrate(new_data, new_data, OLD_)
bulk_migrate(new_options, new_options, OLD_)
bulk_inherit(new_options.setdefault(CONF_ADDITIONAL_OPTIONS, {}), new_options, CONF_BATTERY_NOMINAL_VOLTAGE, CONF_BATTERY_LIFE_CYCLE_RATING)
bulk_delete(new_data, CONF_OLD_SERIAL)
bulk_delete(new_options, CONF_OLD_SERIAL, "inverter_host", "inverter_port", CONF_BATTERY_NOMINAL_VOLTAGE, CONF_BATTERY_LIFE_CYCLE_RATING)
bulk_delete(new_data, OLD_[CONF_SERIAL])
bulk_delete(new_options, OLD_[CONF_SERIAL], OLD_[CONF_HOST], OLD_[CONF_PORT], CONF_BATTERY_NOMINAL_VOLTAGE, CONF_BATTERY_LIFE_CYCLE_RATING)

if not new_options.get(CONF_ADDITIONAL_OPTIONS):
del new_options[CONF_ADDITIONAL_OPTIONS]
Expand Down
8 changes: 4 additions & 4 deletions custom_components/solarman/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ def set_request(code, start, end):

def lookup_profile(response, attr):
if response and (device_type := get_addr_value(response, *AUTODETECTION_DEVICE_DEYE)):
f, m, c = next(iter([AUTODETECTION_TABLE_DEYE[i] for i in AUTODETECTION_TABLE_DEYE if device_type in i]))
f, m, c = next(iter([AUTODETECTION_DEYE[i] for i in AUTODETECTION_DEYE if device_type in i]))
if (t := get_addr_value(response, *AUTODETECTION_TYPE_DEYE)) and device_type in (0x0003, 0x0300):
attr[ATTR_TABLE[CONF_PHASE]] = min(t if t == 1 else 3, attr[ATTR_TABLE[CONF_PHASE]])
attr[ATTR_[CONF_PHASE]] = min(t if t == 1 else 3, attr[ATTR_[CONF_PHASE]])
if (v := get_addr_value(response, AUTODETECTION_CODE_DEYE, c)) and (t := (v & 0x0F00) // 0x100) and (p := v & 0x000F):
attr[ATTR_TABLE[CONF_MOD]], attr[ATTR_TABLE[CONF_MPPT]], attr[ATTR_TABLE[CONF_PHASE]] = max(m, attr[ATTR_TABLE[CONF_MOD]]), min(t, attr[ATTR_TABLE[CONF_MPPT]]), min(p, attr[ATTR_TABLE[CONF_PHASE]])
attr[ATTR_[CONF_MOD]], attr[ATTR_[CONF_MPPT]], attr[ATTR_[CONF_PHASE]] = max(m, attr[ATTR_[CONF_MOD]]), min(t, attr[ATTR_[CONF_MPPT]]), min(p, attr[ATTR_[CONF_PHASE]])
return f
raise Exception("Unable to read Device Type at Modbus register address: 0x0000")

Expand All @@ -76,7 +76,7 @@ async def yaml_open(file):
return yaml.safe_load(await f.read())

def process_profile(filename):
return filename if not filename in PROFILE_REDIRECT_TABLE else PROFILE_REDIRECT_TABLE[filename]
return filename if not filename in PROFILE_REDIRECT else PROFILE_REDIRECT[filename]

def build_device_info(serial, mac, name, info, filename):
manufacturer = "Solarman"
Expand Down
44 changes: 17 additions & 27 deletions custom_components/solarman/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,23 @@
_LOGGER = logging.getLogger(__name__)

DATA_SCHEMA = {
vol.Required(CONF_NAME, default = DEFAULT_TABLE[CONF_NAME]): str,
vol.Required(CONF_NAME, default = DEFAULT_[CONF_NAME]): str,
vol.Required(CONF_SERIAL, default = None): vol.All(vol.Coerce(int), vol.Range(min = 0, max = 4294967295))
}

OPTS_SCHEMA = {
vol.Optional(CONF_HOST, default = DEFAULT_TABLE[CONF_HOST], description = {"suggested_value": DEFAULT_TABLE[CONF_HOST]}): str,
vol.Optional(CONF_PORT, default = DEFAULT_TABLE[CONF_PORT], description = {"suggested_value": DEFAULT_TABLE[CONF_PORT]}): cv.port,
vol.Optional(CONF_LOOKUP_FILE, default = DEFAULT_TABLE[CONF_LOOKUP_FILE], description = {"suggested_value": DEFAULT_TABLE[CONF_LOOKUP_FILE]}): str,
vol.Optional(CONF_HOST, default = DEFAULT_[CONF_HOST], description = {"suggested_value": DEFAULT_[CONF_HOST]}): str,
vol.Optional(CONF_PORT, default = DEFAULT_[CONF_PORT], description = {"suggested_value": DEFAULT_[CONF_PORT]}): cv.port,
vol.Optional(CONF_LOOKUP_FILE, default = DEFAULT_[CONF_LOOKUP_FILE], description = {"suggested_value": DEFAULT_[CONF_LOOKUP_FILE]}): str,
vol.Required(CONF_ADDITIONAL_OPTIONS): section(
vol.Schema(
{
vol.Optional(CONF_MOD, default = DEFAULT_TABLE[CONF_MOD], description = {"suggested_value": DEFAULT_TABLE[CONF_MOD]}): bool,
vol.Optional(CONF_MPPT, default = DEFAULT_TABLE[CONF_MPPT], description = {"suggested_value": DEFAULT_TABLE[CONF_MPPT]}): vol.All(vol.Coerce(int), vol.Range(min = 1, max = 12)),
vol.Optional(CONF_PHASE, default = DEFAULT_TABLE[CONF_PHASE], description = {"suggested_value": DEFAULT_TABLE[CONF_PHASE]}): vol.All(vol.Coerce(int), vol.Range(min = 1, max = 3)),
vol.Optional(CONF_BATTERY_NOMINAL_VOLTAGE, default = DEFAULT_TABLE[CONF_BATTERY_NOMINAL_VOLTAGE], description = {"suggested_value": DEFAULT_TABLE[CONF_BATTERY_NOMINAL_VOLTAGE]}): cv.positive_int,
vol.Optional(CONF_BATTERY_LIFE_CYCLE_RATING, default = DEFAULT_TABLE[CONF_BATTERY_LIFE_CYCLE_RATING], description = {"suggested_value": DEFAULT_TABLE[CONF_BATTERY_LIFE_CYCLE_RATING]}): cv.positive_int,
vol.Optional(CONF_MB_SLAVE_ID, default = DEFAULT_TABLE[CONF_MB_SLAVE_ID], description = {"suggested_value": DEFAULT_TABLE[CONF_MB_SLAVE_ID]}): cv.positive_int
vol.Optional(CONF_MOD, default = DEFAULT_[CONF_MOD], description = {"suggested_value": DEFAULT_[CONF_MOD]}): bool,
vol.Optional(CONF_MPPT, default = DEFAULT_[CONF_MPPT], description = {"suggested_value": DEFAULT_[CONF_MPPT]}): vol.All(vol.Coerce(int), vol.Range(min = 1, max = 12)),
vol.Optional(CONF_PHASE, default = DEFAULT_[CONF_PHASE], description = {"suggested_value": DEFAULT_[CONF_PHASE]}): vol.All(vol.Coerce(int), vol.Range(min = 1, max = 3)),
vol.Optional(CONF_BATTERY_NOMINAL_VOLTAGE, default = DEFAULT_[CONF_BATTERY_NOMINAL_VOLTAGE], description = {"suggested_value": DEFAULT_[CONF_BATTERY_NOMINAL_VOLTAGE]}): cv.positive_int,
vol.Optional(CONF_BATTERY_LIFE_CYCLE_RATING, default = DEFAULT_[CONF_BATTERY_LIFE_CYCLE_RATING], description = {"suggested_value": DEFAULT_[CONF_BATTERY_LIFE_CYCLE_RATING]}): cv.positive_int,
vol.Optional(CONF_MB_SLAVE_ID, default = DEFAULT_[CONF_MB_SLAVE_ID], description = {"suggested_value": DEFAULT_[CONF_MB_SLAVE_ID]}): cv.positive_int
}
),
{"collapsed": True}
Expand All @@ -50,7 +50,7 @@ async def async_update_listener(hass: HomeAssistant, config_entry: ConfigEntry)
await hass.config_entries.async_reload(config_entry.entry_id)

async def data_schema(hass: HomeAssistant, data_schema: dict[str, Any]) -> vol.Schema:
lookup_files = [DEFAULT_TABLE[CONF_LOOKUP_FILE]] + await async_listdir(hass.config.path(LOOKUP_DIRECTORY_PATH)) + await async_listdir(hass.config.path(LOOKUP_CUSTOM_DIRECTORY_PATH), "custom/")
lookup_files = [DEFAULT_[CONF_LOOKUP_FILE]] + await async_listdir(hass.config.path(LOOKUP_DIRECTORY_PATH)) + await async_listdir(hass.config.path(LOOKUP_CUSTOM_DIRECTORY_PATH), "custom/")
_LOGGER.debug(f"step_user_data_schema: {LOOKUP_DIRECTORY_PATH}: {lookup_files}")
data_schema[CONF_LOOKUP_FILE] = vol.In(lookup_files)
_LOGGER.debug(f"step_user_data_schema: data_schema: {data_schema}")
Expand All @@ -61,7 +61,7 @@ def validate_connection(user_input: dict[str, Any], errors: dict) -> dict[str, A

try:
if host := user_input.get(CONF_HOST, IP_ANY):
getaddrinfo(host, user_input.get(CONF_PORT, DEFAULT_TABLE[CONF_PORT]), family = 0, type = 0, proto = 0, flags = 0)
getaddrinfo(host, user_input.get(CONF_PORT, DEFAULT_[CONF_PORT]), family = 0, type = 0, proto = 0, flags = 0)
except herror:
errors["base"] = "invalid_host"
except (gaierror, timeout):
Expand All @@ -79,29 +79,18 @@ def remove_defaults(user_input: dict[str, Any]):
for k in list(user_input.keys()):
if k == CONF_ADDITIONAL_OPTIONS:
for l in list(user_input[k].keys()):
if user_input[k][l] == DEFAULT_TABLE.get(l):
if user_input[k][l] == DEFAULT_.get(l):
del user_input[k][l]
if not user_input[k]:
del user_input[k]
elif user_input[k] == DEFAULT_TABLE.get(k):
elif user_input[k] == DEFAULT_.get(k):
del user_input[k]
return user_input

class ConfigFlowHandler(ConfigFlow, domain = DOMAIN):
MINOR_VERSION = 4
VERSION = 1

async def _async_set_and_abort_if_unique_id_configured(self, suffix: str):
await self.async_set_unique_id(f"solarman_{suffix}") # self._abort_if_unique_id_configured(updates={CONF_HOST: url.host})
self._abort_if_unique_id_configured()

async def async_step_dhcp(self, discovery_info: DhcpServiceInfo) -> ConfigFlowResult:
_LOGGER.debug(f"ConfigFlowHandler.async_step_dhcp: {discovery_info}")
#await self.async_set_unique_id(format_mac(discovery_info.macaddress))
discovery_input = { CONF_NAME: DEFAULT_TABLE[CONF_NAME], CONF_HOST: discovery_info.ip, CONF_PORT: DEFAULT_TABLE[CONF_PORT] }
self._async_abort_entries_match(discovery_input)
return await self.async_step_user(user_input = discovery_input)

async def async_step_user(self, user_input: dict[str, Any] | None = None) -> ConfigFlowResult:
_LOGGER.debug(f"ConfigFlowHandler.async_step_user: {user_input}")
if user_input is None:
Expand All @@ -118,7 +107,7 @@ async def async_step_user(self, user_input: dict[str, Any] | None = None) -> Con
continue
for i in range(0, 1000):
try:
self._async_abort_entries_match({ CONF_NAME: (name := ' '.join(filter(None, (DEFAULT_TABLE[CONF_NAME], None if not i else str(i if i != 1 else 2))))) })
self._async_abort_entries_match({ CONF_NAME: (name := ' '.join(filter(None, (DEFAULT_[CONF_NAME], None if not i else str(i if i != 1 else 2))))) })
break
except:
continue
Expand All @@ -127,7 +116,8 @@ async def async_step_user(self, user_input: dict[str, Any] | None = None) -> Con
errors = {}

if validate_connection(user_input, errors):
await self._async_set_and_abort_if_unique_id_configured(user_input[CONF_SERIAL])
await self.async_set_unique_id(user_input[CONF_SERIAL])
self._abort_if_unique_id_configured() # self._abort_if_unique_id_configured(updates={CONF_HOST: url.host})
return self.async_create_entry(title = user_input[CONF_NAME], data = filter_by_keys(user_input, DATA_SCHEMA), options = remove_defaults(filter_by_keys(user_input, OPTS_SCHEMA)))

_LOGGER.debug(f"ConfigFlowHandler.async_step_user: connection validation failed: {user_input}")
Expand Down
16 changes: 7 additions & 9 deletions custom_components/solarman/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
CONF_BATTERY_LIFE_CYCLE_RATING = "battery_life_cycle_rating"
CONF_MB_SLAVE_ID = "mb_slave_id"

CONF_OLD_SERIAL = "inverter_serial"
OLD_ = { CONF_SERIAL: "inverter_serial", CONF_HOST: "inverter_host", CONF_PORT: "inverter_port" }

UPDATE_INTERVAL = "update_interval"
IS_SINGLE_CODE = "is_single_code"
Expand All @@ -42,7 +42,7 @@
REGISTERS_MAX_SIZE = "registers_max_size"
DIGITS = "digits"

DEFAULT_TABLE = {
DEFAULT_ = {
"name": "Inverter",
CONF_HOST: "",
CONF_PORT: 8899,
Expand All @@ -61,14 +61,16 @@
DIGITS: 6
}

AUTODETECTION_REDIRECT_TABLE = [DEFAULT_TABLE[CONF_LOOKUP_FILE], "deye_string.yaml", "deye_p1.yaml", "deye_hybrid.yaml", "deye_micro.yaml", "deye_4mppt.yaml", "deye_2mppt.yaml", "deye_p3.yaml", "deye_sg04lp3.yaml", "deye_sg01hp3.yaml"]
AUTODETECTION_REDIRECT = [DEFAULT_[CONF_LOOKUP_FILE], "deye_string.yaml", "deye_p1.yaml", "deye_hybrid.yaml", "deye_micro.yaml", "deye_4mppt.yaml", "deye_2mppt.yaml", "deye_p3.yaml", "deye_sg04lp3.yaml", "deye_sg01hp3.yaml"]
AUTODETECTION_CODE_DEYE = 0x03
AUTODETECTION_REQUEST_DEYE = (AUTODETECTION_CODE_DEYE, 0x00, 0x16)
AUTODETECTION_DEVICE_DEYE = (AUTODETECTION_CODE_DEYE, 0x00)
AUTODETECTION_TYPE_DEYE = (AUTODETECTION_CODE_DEYE, 0x08)
AUTODETECTION_TABLE_DEYE = { (0x0002, 0x0200): ("deye_string.yaml", 0, 0x12), (0x0003, 0x0300): ("deye_hybrid.yaml", 0, 0x12), (0x0004, 0x0400): ("deye_micro.yaml", 0, 0x12), (0x0005, 0x0500): ("deye_p3.yaml", 0, 0x16), (0x0006, 0x0007, 0x0600, 0x0008, 0x0601): ("deye_p3.yaml", 1, 0x16) }
AUTODETECTION_DEYE = { (0x0002, 0x0200): ("deye_string.yaml", 0, 0x12), (0x0003, 0x0300): ("deye_hybrid.yaml", 0, 0x12), (0x0004, 0x0400): ("deye_micro.yaml", 0, 0x12), (0x0005, 0x0500): ("deye_p3.yaml", 0, 0x16), (0x0006, 0x0007, 0x0600, 0x0008, 0x0601): ("deye_p3.yaml", 1, 0x16) }

PROFILE_REDIRECT_TABLE = { "deye_4mppt.yaml": "deye_micro.yaml", "deye_2mppt.yaml": "deye_micro.yaml", "sofar_hyd3k-6k-es.yaml": "sofar_hyd-es.yaml", "hyd-zss-hp-3k-6k.yaml": "zcs_azzurro-hyd-zss-hp.yaml", "solis_1p8k-5g.yaml": "solis_1p-5g.yaml" }
PROFILE_REDIRECT = { "sofar_hyd3k-6k-es.yaml": "sofar_hyd-es.yaml", "hyd-zss-hp-3k-6k.yaml": "zcs_azzurro-hyd-zss-hp.yaml", "solis_1p8k-5g.yaml": "solis_1p-5g.yaml" }

ATTR_ = { CONF_MOD: CONF_MOD, CONF_MPPT: CONF_MPPT, CONF_PHASE: "l" }

STATE_SENSORS = [{"name": "Connection", "artificial": "state", "platform": "binary_sensor"}, {"name": "Update Interval", "artificial": "interval"}]

Expand Down Expand Up @@ -101,10 +103,6 @@
ACTION_ATTEMPTS = 5
ACTION_ATTEMPTS_MAX = ACTION_ATTEMPTS * 6

ATTR_FRIENDLY_NAME = "friendly_name"

ATTR_TABLE = { CONF_MOD: CONF_MOD, CONF_MPPT: CONF_MPPT, CONF_PHASE: "l" }

REQUEST_UPDATE_INTERVAL = UPDATE_INTERVAL
REQUEST_MIN_SPAN = "min_span"
REQUEST_MAX_SIZE = "max_size"
Expand Down
4 changes: 2 additions & 2 deletions custom_components/solarman/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from homeassistant.util import slugify
from homeassistant.core import split_entity_id, callback
from homeassistant.const import EntityCategory, STATE_UNKNOWN
from homeassistant.const import EntityCategory, STATE_UNKNOWN, CONF_FRIENDLY_NAME
from homeassistant.helpers.entity import EntityDescription
from homeassistant.helpers.entity_registry import RegistryEntry
from homeassistant.helpers.update_coordinator import CoordinatorEntity
Expand Down Expand Up @@ -93,7 +93,7 @@ def __init__(self, coordinator, sensor, platform):
self._attr_entity_category = sensor.get("category") or sensor.get("entity_category")
self._attr_entity_registry_enabled_default = not "disabled" in sensor
self._attr_entity_registry_visible_default = not "hidden" in sensor
self._attr_friendly_name = sensor.get(ATTR_FRIENDLY_NAME)
self._attr_friendly_name = sensor.get(CONF_FRIENDLY_NAME)
self._attr_icon = sensor.get("icon")

if (unit_of_measurement := sensor.get("uom") or sensor.get("unit_of_measurement")):
Expand Down
12 changes: 6 additions & 6 deletions custom_components/solarman/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

class ParameterParser:
def __init__(self, profile, attr):
self._update_interval = DEFAULT_TABLE[UPDATE_INTERVAL]
self._is_single_code = DEFAULT_TABLE[IS_SINGLE_CODE]
self._code = DEFAULT_TABLE[REGISTERS_CODE]
self._min_span = DEFAULT_TABLE[REGISTERS_MIN_SPAN]
self._max_size = DEFAULT_TABLE[REGISTERS_MAX_SIZE]
self._digits = DEFAULT_TABLE[DIGITS]
self._update_interval = DEFAULT_[UPDATE_INTERVAL]
self._is_single_code = DEFAULT_[IS_SINGLE_CODE]
self._code = DEFAULT_[REGISTERS_CODE]
self._min_span = DEFAULT_[REGISTERS_MIN_SPAN]
self._max_size = DEFAULT_[REGISTERS_MAX_SIZE]
self._digits = DEFAULT_[DIGITS]
self._requests = None
self._result = {}

Expand Down
16 changes: 8 additions & 8 deletions custom_components/solarman/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ def name(self):

@cached_property
def serial(self):
return protected(self.config_entry.data.get(CONF_SERIAL, self.config_entry.data.get(CONF_OLD_SERIAL)), "Configuration parameter [serial] does not have a value")
return protected(self.config_entry.data.get(CONF_SERIAL, self.config_entry.data.get(OLD_[CONF_SERIAL])), "Configuration parameter [serial] does not have a value")

@cached_property
def host(self):
return self._options.get(CONF_HOST, IP_ANY)

@cached_property
def port(self):
return self._options.get(CONF_PORT, DEFAULT_TABLE[CONF_PORT])
return self._options.get(CONF_PORT, DEFAULT_[CONF_PORT])

@cached_property
def filename(self):
return self._options.get(CONF_LOOKUP_FILE, DEFAULT_TABLE[CONF_LOOKUP_FILE])
return self._options.get(CONF_LOOKUP_FILE, DEFAULT_[CONF_LOOKUP_FILE])

@cached_property
def mb_slave_id(self):
return self._additional_options.get(CONF_MB_SLAVE_ID, DEFAULT_TABLE[CONF_MB_SLAVE_ID])
return self._additional_options.get(CONF_MB_SLAVE_ID, DEFAULT_[CONF_MB_SLAVE_ID])

@cached_property
def directory(self):
Expand Down Expand Up @@ -104,20 +104,20 @@ def __getattr__(self, attr: str) -> Any:

@cached_property
def auto(self) -> bool:
return not self.filename or self.filename in AUTODETECTION_REDIRECT_TABLE
return not self.filename or self.filename in AUTODETECTION_REDIRECT

@cached_property
def attributes(self) -> str:
return {ATTR_TABLE[k]: int(self._additional_options.get(k, DEFAULT_TABLE[k])) for k in ATTR_TABLE}
return {ATTR_[k]: int(self._additional_options.get(k, DEFAULT_[k])) for k in ATTR_}

async def resolve(self, request: Callable[[], Awaitable[None]] | None = None):
_LOGGER.debug(f"Device autodetection is {"enabled" if self.auto and request else f"disabled. Selected profile: {self.filename}"}")

f = lookup_profile(await request(-1, [set_request(*AUTODETECTION_REQUEST_DEYE)]), self.attributes) if self.auto and request else self.filename

if f and f != DEFAULT_TABLE[CONF_LOOKUP_FILE] and (n := process_profile(f)) and (p := await yaml_open(self.config.directory + n)):
if f and f != DEFAULT_[CONF_LOOKUP_FILE] and (n := process_profile(f)) and (p := await yaml_open(self.config.directory + n)):
self.parser = ParameterParser(p, self.attributes)

return build_device_info(self.serial, self.endpoint.mac, self.name, unwrap(p["info"], "model", self.attributes[ATTR_TABLE[CONF_MOD]]) if "info" in p else None, f)
return build_device_info(self.serial, self.endpoint.mac, self.name, unwrap(p["info"], "model", self.attributes[ATTR_[CONF_MOD]]) if "info" in p else None, f)

raise Exception(f"Unable to resolve and process selected profile: {self.filename}")
6 changes: 3 additions & 3 deletions custom_components/solarman/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def _create_entity(coordinator, description, options):
case "interval":
return SolarmanIntervalSensor(coordinator, description)
elif (name := description["name"]) and "Battery" in name and (additional := options.get(CONF_ADDITIONAL_OPTIONS, {})) is not None:
battery_nominal_voltage = additional.get(CONF_BATTERY_NOMINAL_VOLTAGE, DEFAULT_TABLE[CONF_BATTERY_NOMINAL_VOLTAGE])
battery_life_cycle_rating = additional.get(CONF_BATTERY_LIFE_CYCLE_RATING, DEFAULT_TABLE[CONF_BATTERY_LIFE_CYCLE_RATING])
battery_nominal_voltage = additional.get(CONF_BATTERY_NOMINAL_VOLTAGE, DEFAULT_[CONF_BATTERY_NOMINAL_VOLTAGE])
battery_life_cycle_rating = additional.get(CONF_BATTERY_LIFE_CYCLE_RATING, DEFAULT_[CONF_BATTERY_LIFE_CYCLE_RATING])
if "registers" in description:
if name == "Battery":
return SolarmanBatterySensor(coordinator, description, battery_nominal_voltage, battery_life_cycle_rating)
Expand Down Expand Up @@ -121,7 +121,7 @@ def __init__(self, coordinator, sensor, battery_nominal_voltage, battery_life_cy
super().__init__(coordinator, sensor)
self._battery_nominal_voltage = battery_nominal_voltage
self._battery_life_cycle_rating = battery_life_cycle_rating
self._digits = sensor[DIGITS] if DIGITS in sensor else DEFAULT_TABLE[DIGITS]
self._digits = sensor[DIGITS] if DIGITS in sensor else DEFAULT_[DIGITS]

def update(self):
#super().update()
Expand Down

0 comments on commit f0ee3c1

Please sign in to comment.