mirror of
https://github.com/esphome/esphome.git
synced 2024-11-10 01:07:45 +01:00
Synchronise Device Classes from Home Assistant (#4633)
* Synchronise Device Classes from Home Assistant * Remove count do the `DEVICE_CLASSES` list is also updated * Format file --------- Co-authored-by: esphomebot <esphome@nabucasa.com> Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
parent
c4ddf7697d
commit
a014d853a4
4 changed files with 14 additions and 4 deletions
|
@ -31,6 +31,7 @@ from esphome.const import (
|
|||
DEVICE_CLASS_DISTANCE,
|
||||
DEVICE_CLASS_EMPTY,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_ENERGY_STORAGE,
|
||||
DEVICE_CLASS_FREQUENCY,
|
||||
DEVICE_CLASS_GAS,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
|
@ -59,6 +60,7 @@ from esphome.const import (
|
|||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
||||
DEVICE_CLASS_VOLTAGE,
|
||||
DEVICE_CLASS_VOLUME,
|
||||
DEVICE_CLASS_VOLUME_STORAGE,
|
||||
DEVICE_CLASS_WATER,
|
||||
DEVICE_CLASS_WEIGHT,
|
||||
DEVICE_CLASS_WIND_SPEED,
|
||||
|
@ -81,6 +83,7 @@ DEVICE_CLASSES = [
|
|||
DEVICE_CLASS_DISTANCE,
|
||||
DEVICE_CLASS_EMPTY,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_ENERGY_STORAGE,
|
||||
DEVICE_CLASS_FREQUENCY,
|
||||
DEVICE_CLASS_GAS,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
|
@ -109,6 +112,7 @@ DEVICE_CLASSES = [
|
|||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
||||
DEVICE_CLASS_VOLTAGE,
|
||||
DEVICE_CLASS_VOLUME,
|
||||
DEVICE_CLASS_VOLUME_STORAGE,
|
||||
DEVICE_CLASS_WATER,
|
||||
DEVICE_CLASS_WEIGHT,
|
||||
DEVICE_CLASS_WIND_SPEED,
|
||||
|
|
|
@ -43,6 +43,7 @@ from esphome.const import (
|
|||
DEVICE_CLASS_DURATION,
|
||||
DEVICE_CLASS_EMPTY,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_ENERGY_STORAGE,
|
||||
DEVICE_CLASS_FREQUENCY,
|
||||
DEVICE_CLASS_GAS,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
|
@ -72,6 +73,7 @@ from esphome.const import (
|
|||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
||||
DEVICE_CLASS_VOLTAGE,
|
||||
DEVICE_CLASS_VOLUME,
|
||||
DEVICE_CLASS_VOLUME_STORAGE,
|
||||
DEVICE_CLASS_WATER,
|
||||
DEVICE_CLASS_WEIGHT,
|
||||
DEVICE_CLASS_WIND_SPEED,
|
||||
|
@ -97,6 +99,7 @@ DEVICE_CLASSES = [
|
|||
DEVICE_CLASS_DURATION,
|
||||
DEVICE_CLASS_EMPTY,
|
||||
DEVICE_CLASS_ENERGY,
|
||||
DEVICE_CLASS_ENERGY_STORAGE,
|
||||
DEVICE_CLASS_FREQUENCY,
|
||||
DEVICE_CLASS_GAS,
|
||||
DEVICE_CLASS_HUMIDITY,
|
||||
|
@ -126,6 +129,7 @@ DEVICE_CLASSES = [
|
|||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS,
|
||||
DEVICE_CLASS_VOLTAGE,
|
||||
DEVICE_CLASS_VOLUME,
|
||||
DEVICE_CLASS_VOLUME_STORAGE,
|
||||
DEVICE_CLASS_WATER,
|
||||
DEVICE_CLASS_WEIGHT,
|
||||
DEVICE_CLASS_WIND_SPEED,
|
||||
|
|
|
@ -946,6 +946,7 @@ DEVICE_CLASS_DOOR = "door"
|
|||
DEVICE_CLASS_DURATION = "duration"
|
||||
DEVICE_CLASS_EMPTY = ""
|
||||
DEVICE_CLASS_ENERGY = "energy"
|
||||
DEVICE_CLASS_ENERGY_STORAGE = "energy_storage"
|
||||
DEVICE_CLASS_FREQUENCY = "frequency"
|
||||
DEVICE_CLASS_GARAGE = "garage"
|
||||
DEVICE_CLASS_GARAGE_DOOR = "garage_door"
|
||||
|
@ -1000,6 +1001,7 @@ DEVICE_CLASS_VIBRATION = "vibration"
|
|||
DEVICE_CLASS_VOLATILE_ORGANIC_COMPOUNDS = "volatile_organic_compounds"
|
||||
DEVICE_CLASS_VOLTAGE = "voltage"
|
||||
DEVICE_CLASS_VOLUME = "volume"
|
||||
DEVICE_CLASS_VOLUME_STORAGE = "volume_storage"
|
||||
DEVICE_CLASS_WATER = "water"
|
||||
DEVICE_CLASS_WEIGHT = "weight"
|
||||
DEVICE_CLASS_WINDOW = "window"
|
||||
|
|
|
@ -25,9 +25,9 @@ DOMAINS = {
|
|||
|
||||
|
||||
def sub(path, pattern, repl):
|
||||
with open(path, "r") as handle:
|
||||
with open(path) as handle:
|
||||
content = handle.read()
|
||||
content = re.sub(pattern, repl, content, flags=re.MULTILINE, count=1)
|
||||
content = re.sub(pattern, repl, content, flags=re.MULTILINE)
|
||||
with open(path, "w") as handle:
|
||||
handle.write(content)
|
||||
|
||||
|
@ -48,7 +48,7 @@ def main():
|
|||
out = ""
|
||||
for cls in sorted(classes):
|
||||
out += f'DEVICE_CLASS_{cls.upper()} = "{classes[cls]}"\n'
|
||||
sub("esphome/const.py", '(DEVICE_CLASS_\w+ = "\w*"\r?\n)+', out)
|
||||
sub("esphome/const.py", '(DEVICE_CLASS_\\w+ = "\\w*"\r?\n)+', out)
|
||||
|
||||
for domain in sorted(allowed):
|
||||
# replace imports
|
||||
|
@ -58,7 +58,7 @@ def main():
|
|||
|
||||
sub(
|
||||
f"esphome/components/{domain}/__init__.py",
|
||||
"( DEVICE_CLASS_\w+,\r?\n)+",
|
||||
"( DEVICE_CLASS_\\w+,\r?\n)+",
|
||||
out,
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue