Skip to content

Commit

Permalink
add schema for STATUS13 (StatusSHT)
Browse files Browse the repository at this point in the history
  • Loading branch information
jziolkowski committed Sep 16, 2024
1 parent b7bc865 commit 21b1929
Show file tree
Hide file tree
Showing 2 changed files with 222 additions and 1 deletion.
27 changes: 26 additions & 1 deletion tdmgr/schemas/status.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -280,6 +300,10 @@ class Status12ResponseSchema(StatusBaseModel):
StatusSTK: StatusSTKSchema


class Status13ResponseSchema(StatusBaseModel):
StatusSHT: StatusSHTSchema


class Status0ResponseSchema(StatusResponseSchema):
# StatusSTS: Optional[Json]
StatusFWR: StatusFWRSchema
Expand All @@ -306,6 +330,7 @@ class Status0ResponseSchema(StatusResponseSchema):
'STATUS10': Status10ResponseSchema,
'STATUS11': Status11ResponseSchema,
'STATUS12': Status12ResponseSchema,
'STATUS13': Status13ResponseSchema,
}

StatusSchemaType = STATUS_SCHEMA_MAP.values()
196 changes: 196 additions & 0 deletions tests/status_parsing/jsonfiles/13.0.0.1/STATUS13.json
Original file line number Diff line number Diff line change
@@ -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
]
}
}
}

0 comments on commit 21b1929

Please sign in to comment.