Skip to content
Merged
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
3 changes: 3 additions & 0 deletions custom_components/solix_ble/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
Generic,
PrimeCharger160w,
PrimeCharger250w,
Solarbank2,
SolixBLEDevice,
)

Expand All @@ -31,12 +32,12 @@
type SolixBLEConfigEntry = ConfigEntry[SolixBLEDevice]


def get_power_station_class(model: Models) -> SolixBLEDevice:

Check failure on line 35 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (PLR0911)

custom_components/solix_ble/__init__.py:35:5: PLR0911 Too many return statements (11 > 6)

Check failure on line 35 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (C901)

custom_components/solix_ble/__init__.py:35:5: C901 `get_power_station_class` is too complex (12 > 10)

Check failure on line 35 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (PLR0911)

custom_components/solix_ble/__init__.py:35:5: PLR0911 Too many return statements (11 > 6)

Check failure on line 35 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (C901)

custom_components/solix_ble/__init__.py:35:5: C901 `get_power_station_class` is too complex (12 > 10)
"""Return correct class for power station from model."""

if model is Models.C300:
return C300
elif model is Models.C300DC:

Check failure on line 40 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (RET505)

custom_components/solix_ble/__init__.py:40:5: RET505 Unnecessary `elif` after `return` statement help: Remove unnecessary `elif`

Check failure on line 40 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (RET505)

custom_components/solix_ble/__init__.py:40:5: RET505 Unnecessary `elif` after `return` statement help: Remove unnecessary `elif`
return C300DC
elif model is Models.C800:
return C800
Expand All @@ -52,16 +53,18 @@
return PrimeCharger160w
elif model is Models.PRIME_CHARGER_250:
return PrimeCharger250w
elif model is Models.SOLARBANK_2:
return Solarbank2
elif model is Models.UNKNOWN:
return Generic
else:
raise NotImplementedError(f"Unexpected model. Got: '{type(model)}'!")

Check failure on line 61 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (EM102)

custom_components/solix_ble/__init__.py:61:35: EM102 Exception must not use an f-string literal, assign to variable first help: Assign to variable; remove f-string literal

Check failure on line 61 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (EM102)

custom_components/solix_ble/__init__.py:61:35: EM102 Exception must not use an f-string literal, assign to variable first help: Assign to variable; remove f-string literal


async def async_setup_entry(hass: HomeAssistant, entry: SolixBLEConfigEntry) -> bool:
"""Set up the integration from a config entry."""

assert entry.unique_id is not None

Check failure on line 67 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (S101)

custom_components/solix_ble/__init__.py:67:5: S101 Use of `assert` detected

Check failure on line 67 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (S101)

custom_components/solix_ble/__init__.py:67:5: S101 Use of `assert` detected
address = entry.unique_id.upper()
model = Models(entry.data["model"])

Expand All @@ -72,10 +75,10 @@
_LOGGER.debug("Count of BLE scanners: %i", count_scanners)

if count_scanners < 1:
raise ConfigEntryNotReady(
"No Bluetooth scanners are available to search for the device."

Check failure on line 79 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (COM812)

custom_components/solix_ble/__init__.py:79:80: COM812 Trailing comma missing help: Add trailing comma

Check failure on line 79 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (EM101)

custom_components/solix_ble/__init__.py:79:17: EM101 Exception must not use a string literal, assign to variable first help: Assign to variable; remove string literal

Check failure on line 79 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (COM812)

custom_components/solix_ble/__init__.py:79:80: COM812 Trailing comma missing help: Add trailing comma

Check failure on line 79 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (EM101)

custom_components/solix_ble/__init__.py:79:17: EM101 Exception must not use a string literal, assign to variable first help: Assign to variable; remove string literal
)

Check failure on line 80 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (TRY003)

custom_components/solix_ble/__init__.py:78:19: TRY003 Avoid specifying long messages outside the exception class

Check failure on line 80 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (TRY003)

custom_components/solix_ble/__init__.py:78:19: TRY003 Avoid specifying long messages outside the exception class
raise ConfigEntryNotReady("The device was not found.")

Check failure on line 81 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (EM101)

custom_components/solix_ble/__init__.py:81:35: EM101 Exception must not use a string literal, assign to variable first help: Assign to variable; remove string literal

Check failure on line 81 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (TRY003)

custom_components/solix_ble/__init__.py:81:15: TRY003 Avoid specifying long messages outside the exception class

Check failure on line 81 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (EM101)

custom_components/solix_ble/__init__.py:81:35: EM101 Exception must not use a string literal, assign to variable first help: Assign to variable; remove string literal

Check failure on line 81 in custom_components/solix_ble/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (TRY003)

custom_components/solix_ble/__init__.py:81:15: TRY003 Avoid specifying long messages outside the exception class

DeviceClass = get_power_station_class(model)
if model is Models.UNKNOWN:
Expand Down
65 changes: 65 additions & 0 deletions custom_components/solix_ble/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@

DOMAIN = "solix_ble"


###############
# Port status #
###############

PORT_STATUS_STRINGS = ["Unknown", "Not connected", "Output", "Input"]


###################
# Charging status #
###################

CHARGING_STATUS_C300_STRINGS = ["Unknown", "Idle", "Discharging", "Charging"]

CHARGING_STATUS_F3800_STRINGS = [
Expand All @@ -16,11 +26,65 @@
"Charging (Both)",
]


################
# Light status #
################

LIGHT_STATUS_STRINGS = ["Unknown", "Off", "Low", "Medium", "High"]

LIGHT_STATUS_SB2_STRINGS = ["Unknown", "Normal", "Mood"]


###################
# Overload status #
###################

OVERLOAD_STATUS_C300DC_STRINGS = ["Unknown", "None", "USB C1", "USB C2", "USB C3"]


###################
# Max load status #
###################

MAX_LOAD_SB2_STRINGS = ["Unknown", "350w", "600w", "800w", "1000w"]


###############
# Grid status #
###############

GRID_STATUS_STRINGS = ["Unknown", "Ok", "Ok?", "Connecting", "No grid"]


##############
# Usage mode #
##############

USAGE_MODE_SB2_STRINGS = [
"Unknown",
"Manual",
"Smart meter",
"Smart plugs",
"Backup",
"Use Time",
"Smart",
"Time slot",
]


##################
# Battery cutoff #
##################

CUT_OFF_SB2_STRINGS = ["Unknown", "5%", "10%"]


####################
# Supported models #
####################


class Models(Enum):
C300 = "C300(X)"
C300DC = "C300(X) DC"
Expand All @@ -31,4 +95,5 @@ class Models(Enum):
F3800 = "F3800"
PRIME_CHARGER_160 = "Prime Charger (160w)"
PRIME_CHARGER_250 = "Prime Charger (250w)"
SOLARBANK_2 = "Solarbank 2"
UNKNOWN = "Unknown"
Loading
Loading