Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rust checks #26

Merged
merged 24 commits into from
Sep 19, 2023
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
2 changes: 1 addition & 1 deletion .devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "flip555/seplos_bms_ha",
"name": "flip555/bms_connector",
"image": "mcr.microsoft.com/vscode/devcontainers/python:0-3.10-bullseye",
"postCreateCommand": "scripts/setup",
"forwardPorts": [
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/lint-next-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Lint"

on:
push:
branches:
- "next-branch"
pull_request:
branches:
- "next-branch"

jobs:
ruff:
name: "Ruff"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/checkout@v1.0.0"
with:
ref: "refs/heads/next-branch"

- name: "Set up Python"
uses: actions/setup-python@v4.6.1
with:
python-version: "3.10"
cache: "pip"

- name: "Install requirements"
run: python3 -m pip install -r requirements.txt

- name: "Run"
run: python3 -m ruff check . --fix
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/checkout@v4.0.0"
uses: "actions/checkout@v1.0.0"

- name: "Set up Python"
uses: actions/setup-python@v4.6.1
Expand All @@ -26,4 +26,4 @@ jobs:
run: python3 -m pip install -r requirements.txt

- name: "Run"
run: python3 -m ruff check .
run: python3 -m ruff check . --fix
8 changes: 4 additions & 4 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ on:
- cron: "0 0 * * *"
push:
branches:
- "main"
- "next-branch"
pull_request:
branches:
- "main"
- "next-branch"

jobs:
hassfest: # https://developers.home-assistant.io/blog/2020/04/16/hassfest
name: "Hassfest Validation"
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/checkout@v4.0.0"
uses: "actions/checkout@v1.0.0"

- name: "Run hassfest validation"
uses: "home-assistant/actions/hassfest@master"
Expand All @@ -27,7 +27,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout the repository"
uses: "actions/checkout@v4.0.0"
uses: "actions/checkout@v1.0.0"

- name: "Run HACS validation"
uses: "hacs/action@main"
Expand Down
16 changes: 15 additions & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ select = [
]

ignore = [
"C901",
"D100", # Missing docstring in public module
"D100", # Missing docstring in public module
"D101", # Missing docstring in public class
"D102", # Missing docstring in public method
"D103", # Missing docstring in public function
"D104", # Missing docstring in public package
"D105", # Missing docstring in magic method
"D107", # Missing docstring in __init__
"D202", # No blank lines allowed after function docstring
"D203", # 1 blank line required before class docstring
"D213", # Multi-line docstring summary should start at the second line
Expand All @@ -38,11 +47,16 @@ ignore = [
"E731", # do not assign a lambda expression, use a def
]

exclude = [
"assets/",
]

[flake8-pytest-style]
fixture-parentheses = false

[pyupgrade]
keep-runtime-typing = true

[mccabe]
max-complexity = 25
max-complexity = 25

2 changes: 1 addition & 1 deletion config/configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ default_config:
logger:
default: info
logs:
custom_components.integration_blueprint: debug
custom_components.bms_connector: debug
1 change: 1 addition & 0 deletions custom_components/bms_connector/bms/seplos/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Holding File."""
Original file line number Diff line number Diff line change
Expand Up @@ -369,98 +369,5 @@ def decode_fourseven(hex_string):
result.compensation_point_4_position = datai_values[90]
result.compensation_point_4_impedance = datai_values[91]

# Print the calculated values
print("Monomer High Voltage Alarm:", result.monomer_high_voltage_alarm, "V")
print("Monomer High Pressure Recovery:", result.monomer_high_pressure_recovery, "V")
print("Monomer Low Pressure Alarm:", result.monomer_low_pressure_alarm, "V")
print("Monomer Low Pressure Recovery:", result.monomer_low_pressure_recovery, "V")
print("Monomer Overvoltage Protection:", result.monomer_overvoltage_protection, "V")
print("Monomer Overvoltage Recovery:", result.monomer_overvoltage_recovery, "V")
print("Monomer Undervoltage Protection:", result.monomer_undervoltage_protection, "V")
print("Monomer Undervoltage Recovery:", result.monomer_undervoltage_recovery, "V")
print("Equalization Opening Voltage:", result.equalization_opening_voltage, "V")
print("Battery Low Voltage Forbidden Charging:", result.battery_low_voltage_forbidden_charging, "V")
print("Total Pressure High Pressure Alarm:", result.total_pressure_high_pressure_alarm, "V")
print("Total Pressure High Pressure Recovery:", result.total_pressure_high_pressure_recovery, "V")
print("Total Pressure Low Pressure Alarm:", result.total_pressure_low_pressure_alarm, "V")
print("Total Pressure Low Pressure Recovery:", result.total_pressure_low_pressure_recovery, "V")
print("Total Voltage Overvoltage Protection:", result.total_voltage_overvoltage_protection, "V")
print("Total Pressure Overpressure Recovery:", result.total_pressure_overpressure_recovery, "V")
print("Total Voltage Undervoltage Protection:", result.total_voltage_undervoltage_protection, "V")
print("Total Pressure Undervoltage Recovery:", result.total_pressure_undervoltage_recovery, "V")
print("Charging Overvoltage Protection:", result.charging_overvoltage_protection, "V")
print("Charging Overvoltage Recovery:", result.charging_overvoltage_recovery, "V")
print("Charging High Temperature Warning:", result.charging_high_temperature_warning, "°C")
print("Charging High Temperature Recovery:", result.charging_high_temperature_recovery, "°C")
print("Charging Low Temperature Warning:", result.charging_low_temperature_warning, "°C")
print("Charging Low Temperature Recovery:", result.charging_low_temperature_recovery, "°C")
print("Charging Over Temperature Protection:", result.charging_over_temperature_protection, "°C")
print("Charging Over Temperature Recovery:", result.charging_over_temperature_recovery, "°C")
print("Charging Under Temperature Protection:", result.charging_under_temperature_protection, "°C")
print("Charging Under Temperature Recovery:", result.charging_under_temperature_recovery, "°C")
print("Discharge High Temperature Warning:", result.discharge_high_temperature_warning, "°C")
print("Discharge High Temperature Recovery:", result.discharge_high_temperature_recovery, "°C")
print("Discharge Low Temperature Warning:", result.discharge_low_temperature_warning, "°C")
print("Discharge Low Temperature Recovery:", result.discharge_low_temperature_recovery, "°C")
print("Discharge Over Temperature Protection:", result.discharge_over_temperature_protection, "°C")
print("Discharge Over Temperature Recovery:", result.discharge_over_temperature_recovery, "°C")
print("Discharge Under Temperature Protection:", result.discharge_under_temperature_protection, "°C")
print("Discharge Under Temperature Recovery:", result.discharge_under_temperature_recovery, "°C")
print("Cell Low Temperature Heating:", result.cell_low_temperature_heating, "°C")
print("Cell Heating Recovery:", result.cell_heating_recovery, "°C")
print("Ambient High Temperature Alarm:", result.ambient_high_temperature_alarm, "°C")
print("Ambient High Temperature Recovery:", result.ambient_high_temperature_recovery, "°C")
print("Ambient Low Temperature Warning:", result.ambient_low_temperature_warning, "°C")
print("Ambient Low Temperature Recovery:", result.ambient_low_temperature_recovery, "°C")
print("Fan Fault:", result.fan_fault, "times")
print("Fan Fault Recovery:", result.fan_fault_recovery, "times")
print("CAN Communication Fault:", result.can_communication_fault, "times")
print("CAN Communication Fault Recovery:", result.can_communication_fault_recovery, "times")
print("MOS Short Circuit Protection:", result.mos_short_circuit_protection, "times")
print("MOS Short Circuit Protection Recovery:", result.mos_short_circuit_protection_recovery, "times")
print("Power High Temperature Recovery:", result.power_high_temperature_recovery, "°C")
print("Power Over Temperature Protection:", result.power_over_temperature_protection, "°C")
print("Power Over Temperature Recovery:", result.power_over_temperature_recovery, "°C")
print("Charging Overcurrent Warning:", result.charging_overcurrent_warning, "A")
print("Charging Overcurrent Recovery:", result.charging_overcurrent_recovery, "A")
print("Discharge Overcurrent Warning:", result.discharge_overcurrent_warning, "A")
print("Discharge Overcurrent Recovery:", result.discharge_overcurrent_recovery, "A")
print("Charge Overcurrent Protection:", result.charge_overcurrent_protection, "A")
print("Discharge Overcurrent Protection:", result.discharge_overcurrent_protection, "A")
print("Transient Overcurrent Protection:", result.transient_overcurrent_protection, "A")
print("Output Soft Start Delay:", result.output_soft_start_delay, "ms")
print("Battery Rated Capacity:", result.battery_rated_capacity, "Ah")
print("SOC:", result.soc, "Ah")
print("Cell Invalidation Differential Pressure:", result.cell_invalidation_differential_pressure, "V")
print("Cell Invalidation Recovery:", result.cell_invalidation_recovery, "V")
print("Equalization Opening Pressure Difference:", result.equalization_opening_pressure_difference, "V")
print("Equalization Closing Pressure Difference:", result.equalization_closing_pressure_difference, "V")
print("Static Equilibrium Time:", result.static_equilibrium_time, "times")
print("Battery Number in Series:", result.battery_number_in_series, "strings")
print("Charge Overcurrent Delay:", result.charge_overcurrent_delay, "s")
print("Discharge Overcurrent Delay:", result.discharge_overcurrent_delay, "s")
print("Transient Overcurrent Delay:", result.transient_overcurrent_delay, "s")
print("Overcurrent Delay Recovery:", result.overcurrent_delay_recovery, "s")
print("Overcurrent Recovery Times:", result.overcurrent_recovery_times, "times")
print("Charge Current Limit Delay:", result.charge_current_limit_delay, "min")
print("Charge Activation Delay:", result.charge_activation_delay, "min")
print("Charge Activation Interval:", result.charge_activation_interval, "times")
print("Charge Activation Times:", result.charge_activation_times, "times")
print("Work Record Interval:", result.work_record_interval, "min")
print("Standby Recording Interval:", result.standby_recording_interval, "min")
print("Standby Shutdown Delay:", result.standby_shutdown_delay, "times")
print("Remaining Capacity Alarm:", result.remaining_capacity_alarm, "%")
print("Remaining Capacity Protection:", result.remaining_capacity_protection, "%")
print("Interval Charge Capacity:", result.interval_charge_capacity, "%")
print("Cycle Cumulative Capacity:", result.cycle_cumulative_capacity, "%")
print("Connection Fault Impedance:", result.connection_fault_impedance, "mΩ")
print("Compensation Point 1 Position:", result.compensation_point_1_position, "strings")
print("Compensation Point 1 Impedance:", result.compensation_point_1_impedance, "mΩ")
print("Compensation Point 2 Position:", result.compensation_point_2_position, "strings")
print("Compensation Point 2 Impedance:", result.compensation_point_2_impedance, "mΩ")
print("Compensation Point 3 Position:", result.compensation_point_3_position, "strings")
print("Compensation Point 3 Impedance:", result.compensation_point_3_impedance, "mΩ")
print("Compensation Point 4 Position:", result.compensation_point_4_position, "strings")
print("Compensation Point 4 Impedance:", result.compensation_point_4_impedance, "mΩ")

return result
3 changes: 1 addition & 2 deletions custom_components/bms_connector/bms/seplos/v3/data_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def decode_pib_table(response):
# Function to retrieve PIC data
# PIC DOESNT WORK AT THE MOMENT!
def retrieve_pic_data(pack_address):
data_fields = send_receive_command(pack_address, 0x12) # Function code for PIC
data_fields = 0 # Function code for PIC
if data_fields:
data_fields = data_fields[6:]
# Parse and display PIC data (if there's enough data)
Expand All @@ -179,7 +179,6 @@ def retrieve_pic_data(pack_address):
}
return pic_data
else:
print("Warning: Not enough data in PIC response. The response may be incomplete.")
return None
else:
return None
Expand Down
14 changes: 10 additions & 4 deletions custom_components/bms_connector/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
{
"domain": "bms_connector",
"name": "BMS Connector",
"documentation": "https://github.com/flip555/bms_connector",
"codeowners": [ "@flip555" ],
"version": "1.1.0",
"codeowners": [
"@flip555"
],
"config_flow": true,
"iot_class": "local_polling"
"dependencies": [],
"documentation": "https://github.com/flip555/bms_connector",
"integration_type": "hub",
"iot_class": "local_polling",
"issue_tracker": "https://github.com/flip555/bms_connector/issues",
"requirements": [],
"version": "1.0.0"
}
Loading