Skip to content

Commit

Permalink
feat: Add set_hvac_mode action attempt (#1302)
Browse files Browse the repository at this point in the history
  • Loading branch information
seambot authored Nov 29, 2024
1 parent 10bd667 commit 001027c
Show file tree
Hide file tree
Showing 4 changed files with 678 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/seam/connect/models/action-attempts/action-attempt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { set_cool_action_attempt } from './set-cool.js'
import { set_fan_mode_action_attempt } from './set-fan-mode.js'
import { set_heat_action_attempt } from './set-heat.js'
import { set_heat_cool_action_attempt } from './set-heat-cool.js'
import { set_hvac_mode_action_attempt } from './set-hvac-mode.js'
import { set_thermostat_off_action_attempt } from './set-thermostat-off.js'
import { unlock_door_action_attempt } from './unlock-door.js'

Expand All @@ -24,6 +25,7 @@ export const action_attempt = z.union([
...set_heat_cool_action_attempt.options,
...set_fan_mode_action_attempt.options,
...set_thermostat_off_action_attempt.options,
...set_hvac_mode_action_attempt.options,
...activate_climate_preset_action_attempt.options,
...deprecated_action_attempts,
])
Expand Down
33 changes: 33 additions & 0 deletions src/lib/seam/connect/models/action-attempts/set-hvac-mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { z } from 'zod'

import {
common_failed_action_attempt,
common_pending_action_attempt,
common_succeeded_action_attempt,
} from './common.js'

const action_type = z.literal('SET_HVAC_MODE')

const error = z.object({
type: z.string(),
message: z.string(),
})

const result = z.object({})

export const set_hvac_mode_action_attempt = z.discriminatedUnion('status', [
common_pending_action_attempt
.extend({
action_type,
})
.describe('Setting HVAC mode.'),
common_succeeded_action_attempt
.extend({
action_type,
result,
})
.describe('Setting HVAC mode succeeded.'),
common_failed_action_attempt
.extend({ action_type, error })
.describe('Setting HVAC mode failed.'),
])
76 changes: 76 additions & 0 deletions src/lib/seam/connect/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3488,6 +3488,82 @@ export default {
],
type: 'object',
},
{
description: 'Setting HVAC mode.',
properties: {
action_attempt_id: {
description: 'The ID of the action attempt.',
format: 'uuid',
type: 'string',
'x-title': 'Action Attempt ID',
},
action_type: { enum: ['SET_HVAC_MODE'], type: 'string' },
error: { nullable: true },
result: { nullable: true },
status: { enum: ['pending'], type: 'string' },
},
required: [
'action_attempt_id',
'status',
'result',
'error',
'action_type',
],
type: 'object',
},
{
description: 'Setting HVAC mode succeeded.',
properties: {
action_attempt_id: {
description: 'The ID of the action attempt.',
format: 'uuid',
type: 'string',
'x-title': 'Action Attempt ID',
},
action_type: { enum: ['SET_HVAC_MODE'], type: 'string' },
error: { nullable: true },
result: { properties: {}, type: 'object' },
status: { enum: ['success'], type: 'string' },
},
required: [
'action_attempt_id',
'status',
'error',
'action_type',
'result',
],
type: 'object',
},
{
description: 'Setting HVAC mode failed.',
properties: {
action_attempt_id: {
description: 'The ID of the action attempt.',
format: 'uuid',
type: 'string',
'x-title': 'Action Attempt ID',
},
action_type: { enum: ['SET_HVAC_MODE'], type: 'string' },
error: {
properties: {
message: { type: 'string' },
type: { type: 'string' },
},
required: ['type', 'message'],
type: 'object',
},
result: { nullable: true },
status: { enum: ['error'], type: 'string' },
},
required: [
'action_attempt_id',
'status',
'result',
'action_type',
'error',
],
type: 'object',
},
{
description: 'Activating climate preset.',
properties: {
Expand Down
Loading

0 comments on commit 001027c

Please sign in to comment.