diff --git a/tdmgr/schemas/status.py b/tdmgr/schemas/status.py index 1f4d565..46085e1 100644 --- a/tdmgr/schemas/status.py +++ b/tdmgr/schemas/status.py @@ -1,7 +1,7 @@ import logging from typing import List, Optional, Union -from pydantic import BaseModel, ConfigDict, create_model, model_validator +from pydantic import BaseModel, ConfigDict, Field, create_model, model_validator log = logging.getLogger(__name__) @@ -232,6 +232,26 @@ class StateBaseSchema(StateSTSBaseSchema): ) +class ShutterSchema(StatusBaseModel): + Relay1: int + Relay2: int + Open: int + Close: int + Perc50: int = Field(alias="50perc") + Delay: int + Opt: str + Calib: List[int] + Mode: str + TiltConfig: List[int] + + +StatusSHTSchema = create_model( + 'StatusSHTSchema', + __base__=StatusBaseModel, + **{f"SHT{idx}": (Optional[ShutterSchema], None) for idx in range(8)}, +) + + class StatusResponseSchema(StatusBaseModel): Status: StatusSchema @@ -280,6 +300,10 @@ class Status12ResponseSchema(StatusBaseModel): StatusSTK: StatusSTKSchema +class Status13ResponseSchema(StatusBaseModel): + StatusSHT: StatusSHTSchema + + class Status0ResponseSchema(StatusResponseSchema): # StatusSTS: Optional[Json] StatusFWR: StatusFWRSchema @@ -306,6 +330,7 @@ class Status0ResponseSchema(StatusResponseSchema): 'STATUS10': Status10ResponseSchema, 'STATUS11': Status11ResponseSchema, 'STATUS12': Status12ResponseSchema, + 'STATUS13': Status13ResponseSchema, } StatusSchemaType = STATUS_SCHEMA_MAP.values() diff --git a/tests/status_parsing/jsonfiles/13.0.0.1/STATUS13.json b/tests/status_parsing/jsonfiles/13.0.0.1/STATUS13.json new file mode 100644 index 0000000..d216da7 --- /dev/null +++ b/tests/status_parsing/jsonfiles/13.0.0.1/STATUS13.json @@ -0,0 +1,196 @@ +{ + "StatusSHT": { + "SHT0": { + "Relay1": 1, + "Relay2": 2, + "Open": 100, + "Close": 100, + "50perc": 50, + "Delay": 0, + "Opt": "0001", + "Calib": [ + 300, + 500, + 700, + 900, + 1000 + ], + "Mode": "1", + "TiltConfig": [ + 0, + 0, + 0, + 0, + 0 + ] + }, + "SHT1": { + "Relay1": 3, + "Relay2": 4, + "Open": 100, + "Close": 100, + "50perc": 50, + "Delay": 0, + "Opt": "0001", + "Calib": [ + 300, + 500, + 700, + 900, + 1000 + ], + "Mode": "1", + "TiltConfig": [ + 0, + 0, + 0, + 0, + 0 + ] + }, + "SHT2": { + "Relay1": 5, + "Relay2": 6, + "Open": 100, + "Close": 100, + "50perc": 50, + "Delay": 0, + "Opt": "0001", + "Calib": [ + 300, + 500, + 700, + 900, + 1000 + ], + "Mode": "1", + "TiltConfig": [ + 0, + 0, + 0, + 0, + 0 + ] + }, + "SHT3": { + "Relay1": 7, + "Relay2": 8, + "Open": 100, + "Close": 100, + "50perc": 50, + "Delay": 0, + "Opt": "0001", + "Calib": [ + 300, + 500, + 700, + 900, + 1000 + ], + "Mode": "1", + "TiltConfig": [ + 0, + 0, + 0, + 0, + 0 + ] + }, + "SHT4": { + "Relay1": 9, + "Relay2": 10, + "Open": 100, + "Close": 100, + "50perc": 50, + "Delay": 0, + "Opt": "0001", + "Calib": [ + 300, + 500, + 700, + 900, + 1000 + ], + "Mode": "1", + "TiltConfig": [ + 0, + 0, + 0, + 0, + 0 + ] + }, + "SHT5": { + "Relay1": 11, + "Relay2": 12, + "Open": 100, + "Close": 100, + "50perc": 50, + "Delay": 0, + "Opt": "0001", + "Calib": [ + 300, + 500, + 700, + 900, + 1000 + ], + "Mode": "1", + "TiltConfig": [ + 0, + 0, + 0, + 0, + 0 + ] + }, + "SHT6": { + "Relay1": 13, + "Relay2": 14, + "Open": 100, + "Close": 100, + "50perc": 50, + "Delay": 0, + "Opt": "0001", + "Calib": [ + 300, + 500, + 700, + 900, + 1000 + ], + "Mode": "1", + "TiltConfig": [ + 0, + 0, + 0, + 0, + 0 + ] + }, + "SHT7": { + "Relay1": 15, + "Relay2": 16, + "Open": 100, + "Close": 100, + "50perc": 50, + "Delay": 0, + "Opt": "0001", + "Calib": [ + 300, + 500, + 700, + 900, + 1000 + ], + "Mode": "1", + "TiltConfig": [ + 0, + 0, + 0, + 0, + 0 + ] + } + } +} \ No newline at end of file