deploy: change method to get status from device

This commit is contained in:
2025-10-21 12:43:14 +07:00
parent c167f4ec43
commit a0687d26cc
3 changed files with 37 additions and 3 deletions
+35
View File
@@ -143,3 +143,38 @@ export function verify(data: unknown, signature: string, secretKey?: string): bo
return false return false
} }
} }
// console.table([
// { act: 'command', signature: sign(
// {
// merchantName: 'SAVY',
// floorName: 'L2',
// unitNumber: '01',
// deviceName: 'AC',
// roomName: 'LV',
// deviceType: 'S',
// commandType: 'C',
// towerNumber: 'T1',
// timestamp: '2025-10-21T04:00:10.673Z',
// nonce: '50ce476cd1c355ae552ae18be55af72c',
// payload: {
// action: 'AC=On',
// },
// }, 'e3faa00e170884b3adc6c37253ec97e9') },
// {
// act: 'state',
// signature: sign({
// merchantName: 'SAVY',
// floorName: 'L2',
// unitNumber: '01',
// deviceName: 'AC',
// roomName: 'LV',
// deviceType: 'S',
// commandType: 'S',
// towerNumber: 'T1',
// timestamp: '2025-10-21T04:00:10.673Z',
// nonce: '50ce476cd1c355ae552ae18be55af72c',
// }, 'e3faa00e170884b3adc6c37253ec97e9'),
// },
// ],
// ['act', 'signature'])
+1 -2
View File
@@ -13,8 +13,7 @@ export const deviceCommandBody = z.object({
timestamp: z.string().datetime(), // ISO8601 timestamp: z.string().datetime(), // ISO8601
nonce: z.string(), nonce: z.string(),
payload: z.object({ payload: z.object({
action: z.enum(['on', 'off', 'set']), action: z.string(),
temp: z.number().optional(),
}), }),
signature: z.string(), signature: z.string(),
}) })
+1 -1
View File
@@ -7,7 +7,7 @@ type OpenApiDocumentation = Omit<Partial<OpenAPIV3.Document<OpenApiDocWithTagGro
export const swaggerPlugin = openapi({ export const swaggerPlugin = openapi({
path: '/swagger', path: '/swagger',
provider: 'swagger-ui', provider: 'scalar',
mapJsonSchema: { mapJsonSchema: {
zod: z.toJSONSchema, zod: z.toJSONSchema,
}, },