mirror of https://github.com/Andre0512/hon.git
Improve entity documentation
This commit is contained in:
parent
891ae51832
commit
75859543aa
20
README.md
20
README.md
|
@ -105,11 +105,12 @@ I tried to create a pull request, but in the structures of these existing repos,
|
|||
I moved the api related stuff into the package [pyhOn](https://github.com/Andre0512/pyhOn).
|
||||
|
||||
## Appliance Features
|
||||
|
||||
### Dish washer
|
||||
#### Controls
|
||||
| Name | Icon | Entity | Key |
|
||||
| --- | --- | --- | --- |
|
||||
| Dish Washer | `mdi:dishwasher` | `switch` | `active` |
|
||||
| Dish Washer | `mdi:dishwasher` | `switch` | `startProgram` / `stopProgram` |
|
||||
#### Configs
|
||||
| Name | Icon | Entity | Key |
|
||||
| --- | --- | --- | --- |
|
||||
|
@ -138,6 +139,7 @@ I moved the api related stuff into the package [pyhOn](https://github.com/Andre0
|
|||
| Remaining Time | `mdi:timer` | `sensor` | `remainingTimeMM` |
|
||||
| Rinse Aid | `mdi:spray-bottle` | `binary_sensor` | `rinseAidStatus` |
|
||||
| Salt | `mdi:shaker-outline` | `binary_sensor` | `saltStatus` |
|
||||
|
||||
### Hob
|
||||
#### Controls
|
||||
| Name | Icon | Entity | Key |
|
||||
|
@ -160,6 +162,7 @@ I moved the api related stuff into the package [pyhOn](https://github.com/Andre0
|
|||
| Remaining Time | `mdi:timer` | `sensor` | `remainingTimeMM` |
|
||||
| Remote Control | `mdi:remote` | `binary_sensor` | `attributes.parameters.remoteCtrValid` |
|
||||
| Temperature | `mdi:thermometer` | `sensor` | `temp` |
|
||||
|
||||
### Oven
|
||||
#### Controls
|
||||
| Name | Icon | Entity | Key |
|
||||
|
@ -184,12 +187,13 @@ I moved the api related stuff into the package [pyhOn](https://github.com/Andre0
|
|||
| Start Time | `mdi:clock-start` | `sensor` | `delayTime` |
|
||||
| Temperature | `mdi:thermometer` | `sensor` | `temp` |
|
||||
| Temperature Selected | `mdi:thermometer` | `sensor` | `tempSel` |
|
||||
|
||||
### Tumble dryer
|
||||
#### Controls
|
||||
| Name | Icon | Entity | Key |
|
||||
| --- | --- | --- | --- |
|
||||
| Pause Tumble Dryer | `mdi:pause` | `switch` | `pause` |
|
||||
| Tumble Dryer | `mdi:tumble-dryer` | `switch` | `active` |
|
||||
| Pause Tumble Dryer | `mdi:pause` | `switch` | `pauseProgram` / `resumeProgram` |
|
||||
| Tumble Dryer | `mdi:tumble-dryer` | `switch` | `startProgram` / `stopProgram` |
|
||||
#### Configs
|
||||
| Name | Icon | Entity | Key |
|
||||
| --- | --- | --- | --- |
|
||||
|
@ -213,12 +217,13 @@ I moved the api related stuff into the package [pyhOn](https://github.com/Andre0
|
|||
| Remaining Time | `mdi:timer` | `sensor` | `remainingTimeMM` |
|
||||
| Start Time | `mdi:clock-start` | `sensor` | `delayTime` |
|
||||
| Temperature level | `mdi:thermometer` | `sensor` | `tempLevel` |
|
||||
|
||||
### Washer dryer
|
||||
#### Controls
|
||||
| Name | Icon | Entity | Key |
|
||||
| --- | --- | --- | --- |
|
||||
| Pause Washing Machine | `mdi:pause` | `switch` | `pause` |
|
||||
| Washing Machine | `mdi:washing-machine` | `switch` | `active` |
|
||||
| Pause Washing Machine | `mdi:pause` | `switch` | `pauseProgram` / `resumeProgram` |
|
||||
| Washing Machine | `mdi:washing-machine` | `switch` | `startProgram` / `stopProgram` |
|
||||
#### Configs
|
||||
| Name | Icon | Entity | Key |
|
||||
| --- | --- | --- | --- |
|
||||
|
@ -244,12 +249,13 @@ I moved the api related stuff into the package [pyhOn](https://github.com/Andre0
|
|||
| Remote Control | `mdi:remote` | `binary_sensor` | `attributes.lastConnEvent.category` |
|
||||
| Spin Speed | `mdi:fast-forward-outline` | `sensor` | `spinSpeed` |
|
||||
| Steam level | `mdi:smoke` | `sensor` | `steamLevel` |
|
||||
|
||||
### Washing machine
|
||||
#### Controls
|
||||
| Name | Icon | Entity | Key |
|
||||
| --- | --- | --- | --- |
|
||||
| Pause Washing Machine | `mdi:pause` | `switch` | `pause` |
|
||||
| Washing Machine | `mdi:washing-machine` | `switch` | `active` |
|
||||
| Pause Washing Machine | `mdi:pause` | `switch` | `pauseProgram` / `resumeProgram` |
|
||||
| Washing Machine | `mdi:washing-machine` | `switch` | `startProgram` / `stopProgram` |
|
||||
#### Configs
|
||||
| Name | Icon | Entity | Key |
|
||||
| --- | --- | --- | --- |
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from custom_components.hon.binary_sensor import BINARY_SENSORS
|
||||
from custom_components.hon.button import BUTTONS
|
||||
from custom_components.hon.number import NUMBERS
|
||||
from custom_components.hon.select import SELECTS
|
||||
from custom_components.hon.sensor import SENSORS
|
||||
from custom_components.hon.switch import SWITCHES
|
||||
from custom_components.hon.switch import SWITCHES, HonSwitchEntityDescription
|
||||
|
||||
APPLIANCES = {
|
||||
"AC": "Air conditioner",
|
||||
|
@ -38,19 +41,37 @@ result = {}
|
|||
for entity_type, appliances in entities.items():
|
||||
for appliance, data in appliances.items():
|
||||
for entity in data:
|
||||
attributes = (entity.key, entity.name, entity.icon, entity_type)
|
||||
if (
|
||||
isinstance(entity, HonSwitchEntityDescription)
|
||||
and entity.entity_category != "config"
|
||||
):
|
||||
key = f"{entity.turn_on_key}` / `{entity.turn_off_key}"
|
||||
else:
|
||||
key = entity.key
|
||||
attributes = (key, entity.name, entity.icon, entity_type)
|
||||
category = "control" if entity_type in ["switch", "button"] else "sensor"
|
||||
result.setdefault(appliance, {}).setdefault(
|
||||
entity.entity_category or category, []
|
||||
).append(attributes)
|
||||
|
||||
text = ""
|
||||
for appliance, categories in sorted(result.items()):
|
||||
print(f"### {APPLIANCES[appliance]}")
|
||||
text += f"\n### {APPLIANCES[appliance]}\n"
|
||||
categories = {k: categories[k] for k in ENTITY_CATEGORY_SORT if k in categories}
|
||||
for category, data in categories.items():
|
||||
print(f"#### {str(category).capitalize()}s")
|
||||
print("| Name | Icon | Entity | Key |")
|
||||
print("| --- | --- | --- | --- |")
|
||||
text += f"#### {str(category).capitalize()}s\n"
|
||||
text += "| Name | Icon | Entity | Key |\n"
|
||||
text += "| --- | --- | --- | --- |\n"
|
||||
for key, name, icon, entity_type in sorted(data, key=lambda d: d[1]):
|
||||
icon = f"`{icon}`" if icon else ""
|
||||
print(f"| {name} | {icon} | `{entity_type}` | `{key}` |")
|
||||
text += f"| {name} | {icon} | `{entity_type}` | `{key}` |\n"
|
||||
|
||||
with open(Path(__file__).parent.parent / "README.md", "r") as file:
|
||||
readme = file.read()
|
||||
readme = re.sub(
|
||||
"(## Appliance Features\n)(?:.|\\s)+?([^#]## |\\Z)",
|
||||
f"\\1{text}\\2",
|
||||
readme,
|
||||
re.DOTALL,
|
||||
)
|
||||
with open(Path(__file__).parent.parent / "README.md", "w") as file:
|
||||
file.write(readme)
|
||||
|
|
Loading…
Reference in New Issue