Skip to content

Commit

Permalink
rename pellets to biomass and fix pylint findings
Browse files Browse the repository at this point in the history
  • Loading branch information
LavermanJJ committed Aug 26, 2023
1 parent 0e90657 commit 4c628da
Show file tree
Hide file tree
Showing 23 changed files with 417 additions and 381 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
python-version: [ "3.9", "3.10", "3.11" ]
python-version: [ "3.11" ]
steps:
- name: Check out ${{ github.sha }} from repository ${{ github.repository }}
uses: actions/checkout@v3
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
check: check-pylint check-black

check-pylint:
@poetry run pylint pysolarfocus/*.py
@poetry run pylint pysolarfocus/*

check-black:
@poetry run black --check pysolarfocus/*.py
@poetry run black --check pysolarfocus/*

codefix:
@poetry run isort pysolarfocus/*.py
@poetry run black pysolarfocus/*.py
@poetry run isort pysolarfocus/*
@poetry run black pysolarfocus/*

test:
@poetry run pytest
Expand Down
15 changes: 7 additions & 8 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from pysolarfocus import SolarfocusAPI,Systems,ApiVersions
from pysolarfocus import SolarfocusAPI, Systems, ApiVersions

# Create the Solarfocus API client
solarfocus = SolarfocusAPI(
ip="solarfocus", # adapt IP-Address
system=Systems.Vampair, # change to Systems.Therminator
api_version=ApiVersions.V_23_020) # select Solarfocus version
ip="solarfocus", system=Systems.VAMPAIR, api_version=ApiVersions.V_23_020 # adapt IP-Address # change to Systems.Therminator
) # select Solarfocus version

solarfocus.connect()
# Fetch the values
Expand All @@ -18,12 +17,12 @@
print("\n")
print(solarfocus.buffers[0])
print("\n")
if solarfocus.system is Systems.Therminator:
print(solarfocus.pelletsboiler)
if solarfocus.system is Systems.Vampair:
if solarfocus.system is Systems.THERMINATOR:
print(solarfocus.biomassboiler)
if solarfocus.system is Systems.VAMPAIR:
print(solarfocus.heatpump)
print("\n")
print(solarfocus.photovoltaic)
print("\n")
print(solarfocus.solar)
print("\n")
print("\n")
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pysolarfocus"
version = "3.7.0.1"
version = "4.0.0"
description = "Unofficial, local Solarfocus client"
authors = ["Jeroen Laverman <[email protected]>"]
license = "Apache-2.0"
Expand Down Expand Up @@ -77,6 +77,9 @@ disable = [
"too-many-boolean-expressions",
"unused-argument",
"wrong-import-order",
"missing-class-docstring",
"missing-function-docstring",
"logging-fstring-interpolation"
]
enable = [
#"useless-suppression", # temporarily every now and then to clean them up
Expand Down
33 changes: 17 additions & 16 deletions pysolarfocus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class Systems(str, Enum):
Supported systems by this library
"""

Vampair = "Vampair"
Therminator = "Therminator"
Ecotop = "Ecotop"
VAMPAIR = "Vampair"
THERMINATOR = "Therminator"
ECOTOP = "Ecotop"


class ApiVersions(str, Enum):
Expand All @@ -31,6 +31,7 @@ class ApiVersions(str, Enum):
V_23_020 = "23.020"

def greater_or_equal(self, api_version) -> bool:
"""Compare given version with own version."""
return version.parse(self.value) >= version.parse(api_version)


Expand All @@ -57,7 +58,7 @@ def __init__(
buffer_count: int = 1,
boiler_count: int = 1,
fresh_water_module_count: int = 1,
system: Systems = Systems.Vampair,
system: Systems = Systems.VAMPAIR,
port: int = PORT,
slave_id: int = SLAVE_ID,
api_version: ApiVersions = ApiVersions.V_21_140,
Expand All @@ -84,7 +85,7 @@ def __init__(
# Single components
self.heatpump = self.__factory.heatpump(system)
self.photovoltaic = self.__factory.photovoltaic(system)
self.pelletsboiler = self.__factory.pelletsboiler(system, api_version)
self.biomassboiler = self.__factory.pelletsboiler(system, api_version)
self.solar = self.__factory.solar(system)

def connect(self):
Expand All @@ -104,7 +105,7 @@ def update(self) -> bool:
and self.update_boiler()
and self.update_heatpump()
and self.update_photovoltaic()
and self.update_pelletsboiler()
and self.update_biomassboiler()
and self.update_solar()
and self.update_fresh_water_modules()
):
Expand Down Expand Up @@ -148,19 +149,19 @@ def update_photovoltaic(self) -> bool:
"""Read values from Heating System"""
return self.photovoltaic.update()

def update_pelletsboiler(self) -> bool:
"""Read values from Pellets boiler"""
return self.pelletsboiler.update()
def update_biomassboiler(self) -> bool:
"""Read values from biomass boiler"""
return self.biomassboiler.update()

def update_solar(self) -> bool:
"""Read values from Solar"""
return self.solar.update()

def __repr__(self) -> str:
s = ["-" * 50]
s.append(f"{self.__class__.__name__}, v{__version__}")
s.append("-" * 50)
s.append(f"+ System: {self.system.name}")
s.append(f"+ Version: {self._api_version}")
s.append("-" * 50)
return "\n".join(s)
message = ["-" * 50]
message.append(f"{self.__class__.__name__}, v{__version__}")
message.append("-" * 50)
message.append(f"+ System: {self.system.value}")
message.append(f"+ Version: {self._api_version.value}")
message.append("-" * 50)
return "\n".join(message)
43 changes: 22 additions & 21 deletions pysolarfocus/component_factory.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""Solarfocus component factory"""
from . import ApiVersions, Systems
from .components.boiler import *
from .components.buffer import *
from .components.fresh_water_module import *
from .components.heat_pump import *
from .components.heating_circuit import *
from .components.pellets_boiler import *
from .components.photovoltaic import *
from .components.solar import *
from .components.boiler import Boiler
from .components.buffer import Buffer, TherminatorBuffer
from .components.fresh_water_module import FreshWaterModule
from .components.heat_pump import HeatPump
from .components.heating_circuit import HeatingCircuit, TherminatorHeatingCircuit
from .components.biomass_boiler import BiomassBoiler
from .components.photovoltaic import Photovoltaic
from .components.solar import Solar
from .modbus_wrapper import ModbusConnector


Expand All @@ -20,10 +21,10 @@ def heating_circuit(self, system: Systems, count: int) -> list[HeatingCircuit]:
heating_circuits = []
for i in range(count):
input, holding = input_addresses[i], holding_addresses[i]
if system == Systems.Therminator or system == Systems.Ecotop:
heating_circuit = TherminatorHeatingCircuit(input, holding)._initialize(self.__modbus_connector)
if system in [Systems.THERMINATOR, Systems.ECOTOP]:
heating_circuit = TherminatorHeatingCircuit(input, holding).initialize(self.__modbus_connector)
else:
heating_circuit = HeatingCircuit(input, holding)._initialize(self.__modbus_connector)
heating_circuit = HeatingCircuit(input, holding).initialize(self.__modbus_connector)
heating_circuits.append(heating_circuit)
return heating_circuits

Expand All @@ -33,7 +34,7 @@ def boiler(self, system: Systems, count: int) -> list[Boiler]:
boilers = []
for i in range(count):
input, holding = input_addresses[i], holding_addresses[i]
boilers.append(Boiler(input, holding)._initialize(self.__modbus_connector))
boilers.append(Boiler(input, holding).initialize(self.__modbus_connector))
return boilers

def buffer(self, system: Systems, count: int, api_version: ApiVersions) -> list[Buffer]:
Expand All @@ -48,10 +49,10 @@ def buffer(self, system: Systems, count: int, api_version: ApiVersions) -> list[
holding = holding_addresses[i]
else:
holding = -1
if system == Systems.Therminator or system == Systems.Ecotop:
buffer = TherminatorBuffer(input)._initialize(self.__modbus_connector)
if system in [Systems.THERMINATOR, Systems.ECOTOP]:
buffer = TherminatorBuffer(input).initialize(self.__modbus_connector)
else:
buffer = Buffer(input, holding, api_version=api_version)._initialize(self.__modbus_connector)
buffer = Buffer(input, holding, api_version=api_version).initialize(self.__modbus_connector)
buffers.append(buffer)
return buffers

Expand All @@ -60,17 +61,17 @@ def fresh_water_modules(self, system: Systems, count: int) -> list[FreshWaterMod
fresh_water_modules = []
for i in range(count):
input = input_addresses[i]
fresh_water_modules.append(FreshWaterModule(input)._initialize(self.__modbus_connector))
fresh_water_modules.append(FreshWaterModule(input).initialize(self.__modbus_connector))
return fresh_water_modules

def heatpump(self, system: Systems) -> HeatPump:
return HeatPump()._initialize(self.__modbus_connector)
return HeatPump().initialize(self.__modbus_connector)

def photovoltaic(self, system: Systems) -> Photovoltaic:
return Photovoltaic()._initialize(self.__modbus_connector)
return Photovoltaic().initialize(self.__modbus_connector)

def pelletsboiler(self, system: Systems, api_version: ApiVersions) -> PelletsBoiler:
return PelletsBoiler(api_version=api_version, system=system)._initialize(self.__modbus_connector)
def pelletsboiler(self, system: Systems, api_version: ApiVersions) -> BiomassBoiler:
return BiomassBoiler(api_version=api_version, system=system).initialize(self.__modbus_connector)

def solar(self, system: Systems) -> Solar:
return Solar()._initialize(self.__modbus_connector)
return Solar().initialize(self.__modbus_connector)
Loading

0 comments on commit 4c628da

Please sign in to comment.