mirror of
https://github.com/Andre0512/hon.git
synced 2024-12-22 18:55:31 +00:00
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).
|
I moved the api related stuff into the package [pyhOn](https://github.com/Andre0512/pyhOn).
|
||||||
|
|
||||||
## Appliance Features
|
## Appliance Features
|
||||||
|
|
||||||
### Dish washer
|
### Dish washer
|
||||||
#### Controls
|
#### Controls
|
||||||
| Name | Icon | Entity | Key |
|
| Name | Icon | Entity | Key |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| Dish Washer | `mdi:dishwasher` | `switch` | `active` |
|
| Dish Washer | `mdi:dishwasher` | `switch` | `startProgram` / `stopProgram` |
|
||||||
#### Configs
|
#### Configs
|
||||||
| Name | Icon | Entity | Key |
|
| 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` |
|
| Remaining Time | `mdi:timer` | `sensor` | `remainingTimeMM` |
|
||||||
| Rinse Aid | `mdi:spray-bottle` | `binary_sensor` | `rinseAidStatus` |
|
| Rinse Aid | `mdi:spray-bottle` | `binary_sensor` | `rinseAidStatus` |
|
||||||
| Salt | `mdi:shaker-outline` | `binary_sensor` | `saltStatus` |
|
| Salt | `mdi:shaker-outline` | `binary_sensor` | `saltStatus` |
|
||||||
|
|
||||||
### Hob
|
### Hob
|
||||||
#### Controls
|
#### Controls
|
||||||
| Name | Icon | Entity | Key |
|
| 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` |
|
| Remaining Time | `mdi:timer` | `sensor` | `remainingTimeMM` |
|
||||||
| Remote Control | `mdi:remote` | `binary_sensor` | `attributes.parameters.remoteCtrValid` |
|
| Remote Control | `mdi:remote` | `binary_sensor` | `attributes.parameters.remoteCtrValid` |
|
||||||
| Temperature | `mdi:thermometer` | `sensor` | `temp` |
|
| Temperature | `mdi:thermometer` | `sensor` | `temp` |
|
||||||
|
|
||||||
### Oven
|
### Oven
|
||||||
#### Controls
|
#### Controls
|
||||||
| Name | Icon | Entity | Key |
|
| 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` |
|
| Start Time | `mdi:clock-start` | `sensor` | `delayTime` |
|
||||||
| Temperature | `mdi:thermometer` | `sensor` | `temp` |
|
| Temperature | `mdi:thermometer` | `sensor` | `temp` |
|
||||||
| Temperature Selected | `mdi:thermometer` | `sensor` | `tempSel` |
|
| Temperature Selected | `mdi:thermometer` | `sensor` | `tempSel` |
|
||||||
|
|
||||||
### Tumble dryer
|
### Tumble dryer
|
||||||
#### Controls
|
#### Controls
|
||||||
| Name | Icon | Entity | Key |
|
| Name | Icon | Entity | Key |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| Pause Tumble Dryer | `mdi:pause` | `switch` | `pause` |
|
| Pause Tumble Dryer | `mdi:pause` | `switch` | `pauseProgram` / `resumeProgram` |
|
||||||
| Tumble Dryer | `mdi:tumble-dryer` | `switch` | `active` |
|
| Tumble Dryer | `mdi:tumble-dryer` | `switch` | `startProgram` / `stopProgram` |
|
||||||
#### Configs
|
#### Configs
|
||||||
| Name | Icon | Entity | Key |
|
| 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` |
|
| Remaining Time | `mdi:timer` | `sensor` | `remainingTimeMM` |
|
||||||
| Start Time | `mdi:clock-start` | `sensor` | `delayTime` |
|
| Start Time | `mdi:clock-start` | `sensor` | `delayTime` |
|
||||||
| Temperature level | `mdi:thermometer` | `sensor` | `tempLevel` |
|
| Temperature level | `mdi:thermometer` | `sensor` | `tempLevel` |
|
||||||
|
|
||||||
### Washer dryer
|
### Washer dryer
|
||||||
#### Controls
|
#### Controls
|
||||||
| Name | Icon | Entity | Key |
|
| Name | Icon | Entity | Key |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| Pause Washing Machine | `mdi:pause` | `switch` | `pause` |
|
| Pause Washing Machine | `mdi:pause` | `switch` | `pauseProgram` / `resumeProgram` |
|
||||||
| Washing Machine | `mdi:washing-machine` | `switch` | `active` |
|
| Washing Machine | `mdi:washing-machine` | `switch` | `startProgram` / `stopProgram` |
|
||||||
#### Configs
|
#### Configs
|
||||||
| Name | Icon | Entity | Key |
|
| 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` |
|
| Remote Control | `mdi:remote` | `binary_sensor` | `attributes.lastConnEvent.category` |
|
||||||
| Spin Speed | `mdi:fast-forward-outline` | `sensor` | `spinSpeed` |
|
| Spin Speed | `mdi:fast-forward-outline` | `sensor` | `spinSpeed` |
|
||||||
| Steam level | `mdi:smoke` | `sensor` | `steamLevel` |
|
| Steam level | `mdi:smoke` | `sensor` | `steamLevel` |
|
||||||
|
|
||||||
### Washing machine
|
### Washing machine
|
||||||
#### Controls
|
#### Controls
|
||||||
| Name | Icon | Entity | Key |
|
| Name | Icon | Entity | Key |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| Pause Washing Machine | `mdi:pause` | `switch` | `pause` |
|
| Pause Washing Machine | `mdi:pause` | `switch` | `pauseProgram` / `resumeProgram` |
|
||||||
| Washing Machine | `mdi:washing-machine` | `switch` | `active` |
|
| Washing Machine | `mdi:washing-machine` | `switch` | `startProgram` / `stopProgram` |
|
||||||
#### Configs
|
#### Configs
|
||||||
| Name | Icon | Entity | Key |
|
| Name | Icon | Entity | Key |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
|
|
37
scripts/sensor_docs.py
Normal file → Executable file
37
scripts/sensor_docs.py
Normal file → Executable file
|
@ -1,9 +1,12 @@
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from custom_components.hon.binary_sensor import BINARY_SENSORS
|
from custom_components.hon.binary_sensor import BINARY_SENSORS
|
||||||
from custom_components.hon.button import BUTTONS
|
from custom_components.hon.button import BUTTONS
|
||||||
from custom_components.hon.number import NUMBERS
|
from custom_components.hon.number import NUMBERS
|
||||||
from custom_components.hon.select import SELECTS
|
from custom_components.hon.select import SELECTS
|
||||||
from custom_components.hon.sensor import SENSORS
|
from custom_components.hon.sensor import SENSORS
|
||||||
from custom_components.hon.switch import SWITCHES
|
from custom_components.hon.switch import SWITCHES, HonSwitchEntityDescription
|
||||||
|
|
||||||
APPLIANCES = {
|
APPLIANCES = {
|
||||||
"AC": "Air conditioner",
|
"AC": "Air conditioner",
|
||||||
|
@ -38,19 +41,37 @@ result = {}
|
||||||
for entity_type, appliances in entities.items():
|
for entity_type, appliances in entities.items():
|
||||||
for appliance, data in appliances.items():
|
for appliance, data in appliances.items():
|
||||||
for entity in data:
|
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"
|
category = "control" if entity_type in ["switch", "button"] else "sensor"
|
||||||
result.setdefault(appliance, {}).setdefault(
|
result.setdefault(appliance, {}).setdefault(
|
||||||
entity.entity_category or category, []
|
entity.entity_category or category, []
|
||||||
).append(attributes)
|
).append(attributes)
|
||||||
|
text = ""
|
||||||
for appliance, categories in sorted(result.items()):
|
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}
|
categories = {k: categories[k] for k in ENTITY_CATEGORY_SORT if k in categories}
|
||||||
for category, data in categories.items():
|
for category, data in categories.items():
|
||||||
print(f"#### {str(category).capitalize()}s")
|
text += f"#### {str(category).capitalize()}s\n"
|
||||||
print("| Name | Icon | Entity | Key |")
|
text += "| Name | Icon | Entity | Key |\n"
|
||||||
print("| --- | --- | --- | --- |")
|
text += "| --- | --- | --- | --- |\n"
|
||||||
for key, name, icon, entity_type in sorted(data, key=lambda d: d[1]):
|
for key, name, icon, entity_type in sorted(data, key=lambda d: d[1]):
|
||||||
icon = f"`{icon}`" if icon else ""
|
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 a new issue