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
15 changes: 13 additions & 2 deletions .github/scripts/profile_library/update-library.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,20 @@ def get_manufacturer_json(manufacturer: str) -> dict:
json_path = os.path.join(DATA_DIR, manufacturer, "manufacturer.json")
try:
with open(json_path) as json_file:
return json.load(json_file)
manufacturer_data = json.load(json_file)
return {
"aliases": manufacturer_data.get("aliases", []),
"name": manufacturer,
"full_name": manufacturer_data.get("name"),
"dir_name": manufacturer
}
except FileNotFoundError:
default_json = {"name": manufacturer, "aliases": []}
default_json = {
"name": manufacturer,
"full_name": manufacturer,
"dir_name": manufacturer,
"aliases": []
}
with open(json_path, "w", encoding="utf-8") as json_file:
json.dump(default_json, json_file, ensure_ascii=False, indent=4)
git.Repo(PROJECT_ROOT).git.add(json_path)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/powercalc/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ async def _create_schema() -> vol.Schema:
library = await ProfileLibrary.factory(self.hass)
device_types = DOMAIN_DEVICE_TYPE_MAPPING.get(self.source_entity.domain, set()) if self.source_entity else None
manufacturers = [
selector.SelectOptionDict(value=manufacturer, label=manufacturer)
selector.SelectOptionDict(value=manufacturer[0], label=manufacturer[1])
for manufacturer in await library.get_manufacturer_listing(device_types)
]
return vol.Schema(
Expand Down
2 changes: 1 addition & 1 deletion custom_components/powercalc/power_profile/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def create_loader(hass: HomeAssistant) -> Loader:

return CompositeLoader(loaders)

async def get_manufacturer_listing(self, device_types: set[DeviceType] | None = None) -> list[str]:
async def get_manufacturer_listing(self, device_types: set[DeviceType] | None = None) -> list[tuple[str, str]]:
"""Get listing of available manufacturers."""
manufacturers = await self._loader.get_manufacturer_listing(device_types)
return sorted(manufacturers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, loaders: list[Loader]) -> None:
async def initialize(self) -> None:
[await loader.initialize() for loader in self.loaders] # type: ignore[func-returns-value]

async def get_manufacturer_listing(self, device_types: set[DeviceType] | None) -> set[str]:
async def get_manufacturer_listing(self, device_types: set[DeviceType] | None) -> set[tuple[str, str]]:
"""Get listing of available manufacturers."""

return {manufacturer for loader in self.loaders for manufacturer in await loader.get_manufacturer_listing(device_types)}
Expand Down
8 changes: 4 additions & 4 deletions custom_components/powercalc/power_profile/loader/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ async def initialize(self) -> None:
if not self._is_custom_directory:
await self._hass.async_add_executor_job(self._load_custom_library)

async def get_manufacturer_listing(self, device_types: set[DeviceType] | None) -> set[str]:
async def get_manufacturer_listing(self, device_types: set[DeviceType] | None) -> set[tuple[str, str]]:
"""Get listing of all available manufacturers or filtered by model device_type."""
if device_types is None:
return set(self._manufacturer_model_listing.keys())
return {(manufacturer, manufacturer) for manufacturer in self._manufacturer_model_listing}

manufacturers: set[str] = set()
manufacturers: set[tuple[str, str]] = set()
for manufacturer in self._manufacturer_model_listing:
models = await self.get_model_listing(manufacturer, device_types)
if not models:
continue
manufacturers.add(manufacturer)
manufacturers.add((manufacturer, manufacturer))

return manufacturers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Loader(Protocol):
async def initialize(self) -> None:
"""Initialize the loader."""

async def get_manufacturer_listing(self, device_types: set[DeviceType] | None) -> set[str]:
async def get_manufacturer_listing(self, device_types: set[DeviceType] | None) -> set[tuple[str, str]]:
"""Get listing of possible manufacturers."""

async def find_manufacturers(self, search: str) -> set[str]:
Expand Down
6 changes: 3 additions & 3 deletions custom_components/powercalc/power_profile/loader/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async def initialize(self) -> None:
manufacturers: list[LibraryManufacturer] = self.library_contents.get("manufacturers", [])

for manufacturer in manufacturers:
manufacturer_name = str(manufacturer.get("name"))
manufacturer_name = str(manufacturer.get("dir_name"))
models = manufacturer.get("models", [])

# Store model info and group models by manufacturer
Expand Down Expand Up @@ -126,11 +126,11 @@ def _save_to_local_storage(data: bytes) -> None:
return await self.hass.async_add_executor_job(_load_local_library_json)

@async_cache
async def get_manufacturer_listing(self, device_types: set[DeviceType] | None) -> set[str]:
async def get_manufacturer_listing(self, device_types: set[DeviceType] | None) -> set[tuple[str, str]]:
"""Get listing of available manufacturers."""

return {
manufacturer["name"]
(manufacturer["dir_name"], manufacturer["full_name"])
for manufacturer in self.library_contents.get("manufacturers", [])
if not device_types or any(device_type in manufacturer.get("device_types", []) for device_type in device_types)
}
Expand Down
3 changes: 2 additions & 1 deletion profile_library/3a smarthome/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "3a smarthome",
"name": "3A Smart Home",
"aliases": [
"3a smarthome",
"3A Smart Home DE",
"3a Smarthome"
]
Expand Down
2 changes: 1 addition & 1 deletion profile_library/ajax online/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "ajax online",
"name": "Ajax Online",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/amazon/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "amazon",
"name": "Amazon",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/anko/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "anko",
"name": "Anko",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/apple/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "apple",
"name": "Apple",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/aqara/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "aqara",
"name": "Aqara",
"aliases": [
"Xiaomi",
"LUMI"
Expand Down
2 changes: 1 addition & 1 deletion profile_library/arlec/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "arlec",
"name": "Arlec",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/athom/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "athom",
"name": "Athom",
"aliases": [
"Athom_Technology"
]
Expand Down
2 changes: 1 addition & 1 deletion profile_library/avm/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "avm",
"name": "AVM",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/belkin/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "belkin",
"name": "Belkin",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/blitzwolf/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "blitzwolf",
"name": "BlitzWolf",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/bosch/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "bosch",
"name": "Bosch",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/bose/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "bose",
"name": "Bose",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/casalux/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "casalux",
"name": "Casalux",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/cree/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "cree",
"name": "Cree",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/denon/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "denon",
"name": "Denon",
"aliases": [
"HEOS"
]
Expand Down
2 changes: 1 addition & 1 deletion profile_library/dygsm/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "dygsm",
"name": "DYGSM",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/elgato/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "elgato",
"name": "Elgato",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/elgin/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "elgin",
"name": "Elgin",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/emos/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "emos",
"name": "Emos",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/epson/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "epson",
"name": "Epson",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/eq-3/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "eq-3",
"name": "eQ-3",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/eufy/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "eufy",
"name": "Eufy",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/eve/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "eve",
"name": "Eve",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/everspring/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "everspring",
"name": "Everspring",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/ewelight/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "ewelight",
"name": "eWeLight",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/ewelink/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "ewelink",
"name": "eWeLink",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/fibaro/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "fibaro",
"name": "Fibaro",
"aliases": [
"Fibargroup"
]
Expand Down
2 changes: 1 addition & 1 deletion profile_library/ge/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ge",
"name": "GE",
"aliases": [
"GE Appliances"
]
Expand Down
2 changes: 1 addition & 1 deletion profile_library/genio/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "genio",
"name": "Genio",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/gledopto/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "gledopto",
"name": "Gledopto",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/google/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "google",
"name": "Google",
"aliases": [
"Google Inc."
]
Expand Down
2 changes: 1 addition & 1 deletion profile_library/govee/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "govee",
"name": "Govee",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/greenwave/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "greenwave",
"name": "GreenWave",
"aliases": [
"GreenWave Reality Inc."
]
Expand Down
2 changes: 1 addition & 1 deletion profile_library/hampton bay/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "hampton bay",
"name": "Hampton Bay",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/harman kardon/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "harman kardon",
"name": "Harman Kardon",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/ikea/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "ikea",
"name": "IKEA",
"aliases": [
"IKEA of Sweden"
]
Expand Down
2 changes: 1 addition & 1 deletion profile_library/innr/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "innr",
"name": "Innr",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/jbl/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "jbl",
"name": "JBL",
"aliases": [
"HARMAN International Industries"
]
Expand Down
2 changes: 1 addition & 1 deletion profile_library/kauf/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "kauf",
"name": "Kauf",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/ledvance/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "ledvance",
"name": "LEDVANCE",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/ledworks/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "ledworks",
"name": "Ledworks",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/lenovo/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "lenovo",
"name": "Lenovo",
"aliases": []
}
2 changes: 1 addition & 1 deletion profile_library/lexman/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "lexman",
"name": "Lexman",
"aliases": [
"ADEO"
]
Expand Down
2 changes: 1 addition & 1 deletion profile_library/library.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion profile_library/lidl/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "lidl",
"name": "Lidl",
"aliases": [
"_TZ3000_riwp3k79",
"_TZ3210_hxtfthp5",
Expand Down
2 changes: 1 addition & 1 deletion profile_library/lifx/manufacturer.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "lifx",
"name": "LIFX",
"aliases": []
}
Loading
Loading