Skip to content

Commit

Permalink
Add some more manufacturers and cleaned some code
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexwijn committed Jan 25, 2025
1 parent 71e9963 commit 6dcede0
Show file tree
Hide file tree
Showing 20 changed files with 141 additions and 26 deletions.
52 changes: 29 additions & 23 deletions custom_components/sat/manufacturer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@
from typing import List, Optional

MANUFACTURERS = {
"ATAG": {"module": "atag", "class": "ATAG", "id": 4},
"Baxi": {"module": "baxi", "class": "Baxi", "id": 4},
"Brotge": {"module": "brotge", "class": "Brotge", "id": 4},
"Geminox": {"module": "geminox", "class": "Geminox", "id": 4},
"Ideal": {"module": "ideal", "class": "Ideal", "id": 6},
"Ferroli": {"module": "ferroli", "class": "Ferroli", "id": 9},
"DeDietrich": {"module": "dedietrich", "class": "DeDietrich", "id": 11},
"Vaillant": {"module": "vaillant", "class": "Vaillant", "id": 24},
"Immergas": {"module": "immergas", "class": "Immergas", "id": 27},
"Sime": {"module": "sime", "class": "Sime", "id": 27},
"Viessmann": {"module": "viessmann", "class": "Viessmann", "id": 33},
"Radiant": {"module": "radiant", "class": "Radiant", "id": 41},
"Nefit": {"module": "nefit", "class": "Nefit", "id": 131},
"Intergas": {"module": "intergas", "class": "Intergas", "id": 173},
"Other": {"module": "other", "class": "Other", "id": -1},
"ATAG": "atag",
"Baxi": "baxi",
"Brotge": "brotge",
"DeDietrich": "dedietrich",
"Ferroli": "ferroli",
"Geminox": "geminox",
"Ideal": "ideal",
"Immergas": "immergas",
"Intergas": "intergas",
"Itho": "itho",
"Nefit": "nefit",
"Radiant": "radiant",
"Remeha": "remeha",
"Sime": "sime",
"Vaillant": "vaillant",
"Viessmann": "viessmann",
"Worcester": "worcester",
"Other": "other",
}


class Manufacturer:
@property
@abstractmethod
def identifier(self) -> int:
pass

@property
@abstractmethod
def name(self) -> str:
Expand All @@ -32,23 +40,21 @@ class ManufacturerFactory:
@staticmethod
def resolve_by_name(name: str) -> Optional[Manufacturer]:
"""Resolve a Manufacturer instance by its name."""
manufacturer = MANUFACTURERS.get(name)
if not manufacturer:
if not (module := MANUFACTURERS.get(name)):
return None

return ManufacturerFactory._import_class(manufacturer["module"], manufacturer["class"])()
return ManufacturerFactory._import_class(module, name)()

@staticmethod
def resolve_by_member_id(member_id: int) -> List[Manufacturer]:
"""Resolve a list of Manufacturer instances by member ID."""
return [
ManufacturerFactory._import_class(info["module"], info["class"])()
for name, info in MANUFACTURERS.items()
if info["id"] == member_id
manufacturer
for name, module in MANUFACTURERS.items()
if (manufacturer := ManufacturerFactory._import_class(module, name)()).identifier == member_id
]

@staticmethod
def _import_class(module_name: str, class_name: str):
"""Dynamically import and return a Manufacturer class."""
module = __import__(f"custom_components.sat.manufacturers.{module_name}", fromlist=[class_name])
return getattr(module, class_name)
return getattr(__import__(f"custom_components.sat.manufacturers.{module_name}", fromlist=[class_name]), class_name)
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/atag.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class ATAG(Manufacturer):
@property
def identifier(self) -> int:
return 4

@property
def name(self) -> str:
return 'ATAG'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/baxi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class Baxi(Manufacturer):
@property
def identifier(self) -> int:
return 4

@property
def name(self) -> str:
return 'Baxi'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/brotge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class Brotge(Manufacturer):
@property
def identifier(self) -> int:
return 4

@property
def name(self) -> str:
return 'BRÖTGE'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/dedietrich.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class DeDietrich(Manufacturer):
@property
def identifier(self) -> int:
return 4

@property
def name(self) -> str:
return 'De Dietrich'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/ferroli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class Ferroli(Manufacturer):
@property
def identifier(self) -> int:
return 9

@property
def name(self) -> str:
return 'Ferroli'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/geminox.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class Geminox(Manufacturer):
@property
def identifier(self) -> int:
return 4

@property
def name(self) -> str:
return 'Geminox'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class Ideal(Manufacturer):
@property
def identifier(self) -> int:
return 6

@property
def name(self) -> str:
return 'Ideal'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/immergas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class Immergas(Manufacturer):
@property
def identifier(self) -> int:
return 27

@property
def name(self) -> str:
return 'Immergas'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/intergas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class Intergas(Manufacturer):
@property
def identifier(self) -> int:
return 173

@property
def name(self) -> str:
return 'Intergas'
11 changes: 11 additions & 0 deletions custom_components/sat/manufacturers/itho.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from ..manufacturer import Manufacturer


class Itho(Manufacturer):
@property
def identifier(self) -> int:
return 29

@property
def name(self) -> str:
return 'Itho'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/nefit.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class Nefit(Manufacturer):
@property
def identifier(self) -> int:
return 131

@property
def name(self) -> str:
return 'Nefit'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class Other(Manufacturer):
@property
def identifier(self) -> int:
return -1

@property
def name(self) -> str:
return 'Other'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/radiant.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class Radiant(Manufacturer):
@property
def identifier(self) -> int:
return 41

@property
def name(self) -> str:
return 'Radiant'
11 changes: 11 additions & 0 deletions custom_components/sat/manufacturers/remeha.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from ..manufacturer import Manufacturer


class Remeha(Manufacturer):
@property
def identifier(self) -> int:
return 11

@property
def name(self) -> str:
return 'Remeha'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/sime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class Sime(Manufacturer):
@property
def identifier(self) -> int:
return 27

@property
def name(self) -> str:
return 'Sime'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/vaillant.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class Vaillant(Manufacturer):
@property
def identifier(self) -> int:
return 24

@property
def name(self) -> str:
return 'Vaillant'
4 changes: 4 additions & 0 deletions custom_components/sat/manufacturers/viessmann.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@


class Viessmann(Manufacturer):
@property
def identifier(self) -> int:
return 33

@property
def name(self) -> str:
return 'Viessmann'
11 changes: 11 additions & 0 deletions custom_components/sat/manufacturers/worcester.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from ..manufacturer import Manufacturer


class Worcester(Manufacturer):
@property
def identifier(self) -> int:
return 4

@property
def name(self) -> str:
return 'Worcester Bosch'
22 changes: 19 additions & 3 deletions custom_components/sat/services.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
clear_integral:
name: Clear Integral
description: "This service clears the integrating part of the PID controller for the specified climate entity. This may be useful if the integral value has become too large or if the PID controller's performance has degraded."
reset_integral:
name: Reset Integral
description: "This service reset the integrating part of the PID controller for the specified climate entity. This may be useful if the integral value has become too large or if the PID controller's performance has degraded."
target:
entity:
domain: climate
integration: "sat"

pulse_width_modulation:
name: Pulse Width Modulation
description: "Force enable or disable the Pulse Width Modulation, do note that it may be turned on or off automatically right after again."
target:
entity:
domain: climate
integration: "sat"
fields:
enabled:
required: true
example: true

0 comments on commit 6dcede0

Please sign in to comment.