@seamapi/react 2.3.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/elements.js +2775 -2687
- package/dist/elements.js.map +1 -1
- package/dist/index.css +0 -8
- package/dist/index.css.map +1 -1
- package/dist/index.min.css +1 -1
- package/dist/index.min.css.map +1 -1
- package/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.js +28 -14
- package/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.js.map +1 -1
- package/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.js +0 -5
- package/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.js.map +1 -1
- package/lib/seam/thermostats/use-cool-thermostat.d.ts +6 -0
- package/lib/seam/thermostats/use-cool-thermostat.js +50 -0
- package/lib/seam/thermostats/use-cool-thermostat.js.map +1 -0
- package/lib/seam/thermostats/use-heat-cool-thermostat.d.ts +6 -0
- package/lib/seam/thermostats/use-heat-cool-thermostat.js +45 -0
- package/lib/seam/thermostats/use-heat-cool-thermostat.js.map +1 -0
- package/lib/seam/thermostats/use-heat-thermostat.d.ts +6 -0
- package/lib/seam/thermostats/use-heat-thermostat.js +50 -0
- package/lib/seam/thermostats/use-heat-thermostat.js.map +1 -0
- package/lib/seam/thermostats/use-set-thermostat-off.d.ts +6 -0
- package/lib/seam/thermostats/use-set-thermostat-off.js +48 -0
- package/lib/seam/thermostats/use-set-thermostat-off.js.map +1 -0
- package/lib/seam/thermostats/use-update-thermostat.js +2 -2
- package/lib/seam/thermostats/use-update-thermostat.js.map +1 -1
- package/lib/ui/Switch/Switch.d.ts +1 -2
- package/lib/ui/Switch/Switch.js +1 -2
- package/lib/ui/Switch/Switch.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +3 -3
- package/src/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.tsx +70 -24
- package/src/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.tsx +0 -16
- package/src/lib/seam/thermostats/use-cool-thermostat.ts +90 -0
- package/src/lib/seam/thermostats/use-heat-cool-thermostat.ts +83 -0
- package/src/lib/seam/thermostats/use-heat-thermostat.ts +90 -0
- package/src/lib/seam/thermostats/use-set-thermostat-off.ts +83 -0
- package/src/lib/seam/thermostats/use-update-thermostat.ts +2 -2
- package/src/lib/ui/Switch/Switch.tsx +1 -3
- package/src/lib/version.ts +1 -1
- package/src/styles/_supported-device-table.scss +0 -12
- package/lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterResultRow.d.ts +0 -8
- package/lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterResultRow.js +0 -10
- package/lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterResultRow.js.map +0 -1
- package/src/lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterResultRow.tsx +0 -47
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
-
import { SupportedDeviceFilterResultRow } from '../../../../lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterResultRow.js';
|
|
4
3
|
import { SupportedDeviceManufacturerSection } from '../../../../lib/seam/components/SupportedDeviceTable/SupportedDeviceManufacturerSection.js';
|
|
5
4
|
import { useFilteredDeviceModels, } from '../../../../lib/seam/components/SupportedDeviceTable/use-filtered-device-models.js';
|
|
6
5
|
import { Button } from '../../../../lib/ui/Button.js';
|
|
@@ -27,10 +26,6 @@ export function SupportedDeviceContent({ resetFilterValue, filterValue, filters,
|
|
|
27
26
|
if (isEmpty) {
|
|
28
27
|
return (_jsx("div", { className: 'seam-supported-device-table-content', children: _jsx(EmptyResult, { filterValue: filterValue, resetFilterValue: resetFilterValue }) }));
|
|
29
28
|
}
|
|
30
|
-
const hasFilters = filterValue.trim() !== '' || filters.manufacturer !== null;
|
|
31
|
-
if (hasFilters) {
|
|
32
|
-
return (_jsx("div", { className: 'seam-supported-device-table-content', children: deviceModels.map((deviceModel) => (_jsx(SupportedDeviceFilterResultRow, { deviceModel: deviceModel }, deviceModel.device_model_id))) }));
|
|
33
|
-
}
|
|
34
29
|
return (_jsx(_Fragment, { children: Object.entries(groupedDeviceModels)
|
|
35
30
|
.sort((e1, e2) => e1[1][0]?.manufacturer.display_name.localeCompare(e2[1][0]?.manufacturer.display_name ?? '') ?? 0)
|
|
36
31
|
.map(([manufacturerId, models]) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SupportedDeviceContent.js","sourceRoot":"","sources":["../../../../src/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"SupportedDeviceContent.js","sourceRoot":"","sources":["../../../../src/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAE/B,OAAO,EAAE,kCAAkC,EAAE,MAAM,gFAAgF,CAAA;AAEnI,OAAO,EAEL,uBAAuB,GACxB,MAAM,wEAAwE,CAAA;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AAUzC,MAAM,UAAU,sBAAsB,CAAC,EACrC,gBAAgB,EAChB,WAAW,EACX,OAAO,EACP,aAAa,EACb,qBAAqB,GACO;IAC5B,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,uBAAuB,CAC3E;QACE,WAAW;QACX,OAAO;QACP,aAAa;QACb,qBAAqB;KACtB,CACF,CAAA;IAED,MAAM,mBAAmB,GAAG,OAAO,CACjC,GAAG,EAAE,CAAC,+BAA+B,CAAC,YAAY,IAAI,EAAE,CAAC,EACzD,CAAC,YAAY,CAAC,CACf,CAAA;IAED,IAA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AAW,CAAC,EACnB,WAAW,EACX,gBAAgB,GAIjB;IACC,MAAM,cAAc,GAAG,CACrB,8BACE,sBAAI,CAAC,CAAC,OAAO,GAAK,EAClB,KAAC,MAAM,IACL,OAAO,EAAC,SAAS,EACjB,IAAI,EAAC,OAAO,EACZ,OAAO,EAAE,gBAAgB,EACzB,SAAS,EAAC,0DAA0D,YAEnE,CAAC,CAAC,KAAK,GACD,IACR,CACJ,CAAA;IAED,OAAO,CACL,cAAK,SAAS,EAAC,iDAAiD,YAC9D,wBACE,cAAK,SAAS,EAAC,6CAA6C,YACzD,WAAW,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,sBAAI,CAAC,CAAC,SAAS,GAAK,CAAC,CAAC,CAAC,cAAc,GAC7D,GACF,GACF,CACP,CAAA;AACH,CAAC;AAED,MAAM,+BAA+B,GAAG,CACtC,YAAiC,EACA,EAAE;IACnC,MAAM,MAAM,GAAoC,EAAE,CAAA;IAElD,KAAK,MAAM,KAAK,IAAI,YAAY,EAAE;QAChC,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,CAAA;QAC9B,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,IAAI,EAAE,CAAA;QACvD,MAAM,CAAC,YAAY,CAAC,eAAe,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,CAAA;KACxD;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,CAAC,GAAG;IACR,OAAO,EAAE,0BAA0B;IACnC,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,4CAA4C;IACnD,SAAS,EAAE,yBAAyB;IACpC,OAAO,EAAE,uCAAuC;IAChD,KAAK,EAAE,oBAAoB;CAC5B,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import type { SeamError, ThermostatCoolRequest } from 'seamapi';
|
|
3
|
+
type UseCoolThermostatData = Record<string, unknown>;
|
|
4
|
+
type UseCoolThermostatMutationParams = ThermostatCoolRequest;
|
|
5
|
+
export declare function useCoolThermostat(): UseMutationResult<UseCoolThermostatData, SeamError, UseCoolThermostatMutationParams>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useMutation, useQueryClient, } from '@tanstack/react-query';
|
|
2
|
+
import { NullSeamClientError, useSeamClient } from '../../../lib/seam/use-seam-client.js';
|
|
3
|
+
export function useCoolThermostat() {
|
|
4
|
+
const { client } = useSeamClient();
|
|
5
|
+
const queryClient = useQueryClient();
|
|
6
|
+
return useMutation({
|
|
7
|
+
mutationFn: async (mutationParams) => {
|
|
8
|
+
if (client === null)
|
|
9
|
+
throw new NullSeamClientError();
|
|
10
|
+
return await client.thermostats.cool(mutationParams);
|
|
11
|
+
},
|
|
12
|
+
onSuccess: (_data, variables) => {
|
|
13
|
+
queryClient.setQueryData(['devices', 'get', { device_id: variables.device_id }], (thermostat) => {
|
|
14
|
+
if (thermostat == null) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
return getUpdatedThermostat(thermostat, variables);
|
|
18
|
+
});
|
|
19
|
+
queryClient.setQueryData(['devices', 'list', { device_id: variables.device_id }], (thermostats) => {
|
|
20
|
+
if (thermostats == null) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return thermostats.map((thermostat) => {
|
|
24
|
+
if (thermostat.device_id === variables.device_id) {
|
|
25
|
+
return getUpdatedThermostat(thermostat, variables);
|
|
26
|
+
}
|
|
27
|
+
return thermostat;
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function getUpdatedThermostat(thermostat, variables) {
|
|
34
|
+
return {
|
|
35
|
+
...thermostat,
|
|
36
|
+
properties: {
|
|
37
|
+
...thermostat.properties,
|
|
38
|
+
current_climate_setting: {
|
|
39
|
+
...thermostat.properties.current_climate_setting,
|
|
40
|
+
cooling_set_point_fahrenheit: variables.cooling_set_point_fahrenheit ??
|
|
41
|
+
thermostat.properties.current_climate_setting
|
|
42
|
+
.cooling_set_point_fahrenheit,
|
|
43
|
+
cooling_set_point_celsius: variables.cooling_set_point_celsius ??
|
|
44
|
+
thermostat.properties.current_climate_setting
|
|
45
|
+
.cooling_set_point_celsius,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=use-cool-thermostat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-cool-thermostat.js","sourceRoot":"","sources":["../../../src/lib/seam/thermostats/use-cool-thermostat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,cAAc,GACf,MAAM,uBAAuB,CAAA;AAQ9B,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAMhF,MAAM,UAAU,iBAAiB;IAK/B,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IAEpC,OAAO,WAAW,CAIhB;QACA,UAAU,EAAE,KAAK,EAAE,cAA+C,EAAE,EAAE;YACpE,IAAI,MAAM,KAAK,IAAI;gBAAE,MAAM,IAAI,mBAAmB,EAAE,CAAA;YAEpD,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAA;QACtD,CAAC;QACD,SAAS,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;YAC9B,WAAW,CAAC,YAAY,CACtB,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,EACtD,CAAC,UAAU,EAAE,EAAE;gBACb,IAAI,UAAU,IAAI,IAAI,EAAE;oBACtB,OAAM;iBACP;gBAED,OAAO,oBAAoB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;YACpD,CAAC,CACF,CAAA;YAED,WAAW,CAAC,YAAY,CACtB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,EACvD,CAAC,WAAW,EAAsB,EAAE;gBAClC,IAAI,WAAW,IAAI,IAAI,EAAE;oBACvB,OAAO,EAAE,CAAA;iBACV;gBAED,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;oBACpC,IAAI,UAAU,CAAC,SAAS,KAAK,SAAS,CAAC,SAAS,EAAE;wBAChD,OAAO,oBAAoB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;qBACnD;oBAED,OAAO,UAAU,CAAA;gBACnB,CAAC,CAAC,CAAA;YACJ,CAAC,CACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,oBAAoB,CAC3B,UAA4B,EAC5B,SAA0C;IAE1C,OAAO;QACL,GAAG,UAAU;QACb,UAAU,EAAE;YACV,GAAG,UAAU,CAAC,UAAU;YACxB,uBAAuB,EAAE;gBACvB,GAAG,UAAU,CAAC,UAAU,CAAC,uBAAuB;gBAChD,4BAA4B,EAC1B,SAAS,CAAC,4BAA4B;oBACtC,UAAU,CAAC,UAAU,CAAC,uBAAuB;yBAC1C,4BAA4B;gBACjC,yBAAyB,EACvB,SAAS,CAAC,yBAAyB;oBACnC,UAAU,CAAC,UAAU,CAAC,uBAAuB;yBAC1C,yBAAyB;aAC/B;SACF;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import type { SeamError, ThermostatHeatCoolRequest } from 'seamapi';
|
|
3
|
+
type UseHeatCoolThermostatData = Record<string, unknown>;
|
|
4
|
+
type UseHeatCoolThermostatMutationParams = ThermostatHeatCoolRequest;
|
|
5
|
+
export declare function useHeatCoolThermostat(): UseMutationResult<UseHeatCoolThermostatData, SeamError, UseHeatCoolThermostatMutationParams>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { useMutation, useQueryClient, } from '@tanstack/react-query';
|
|
2
|
+
import { NullSeamClientError, useSeamClient } from '../../../lib/seam/use-seam-client.js';
|
|
3
|
+
export function useHeatCoolThermostat() {
|
|
4
|
+
const { client } = useSeamClient();
|
|
5
|
+
const queryClient = useQueryClient();
|
|
6
|
+
return useMutation({
|
|
7
|
+
mutationFn: async (mutationParams) => {
|
|
8
|
+
if (client === null)
|
|
9
|
+
throw new NullSeamClientError();
|
|
10
|
+
return await client.thermostats.heatCool(mutationParams);
|
|
11
|
+
},
|
|
12
|
+
onSuccess: (_data, variables) => {
|
|
13
|
+
queryClient.setQueryData(['devices', 'get', { device_id: variables.device_id }], (thermostat) => {
|
|
14
|
+
if (thermostat == null) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
return getUpdatedThermostat(thermostat, variables);
|
|
18
|
+
});
|
|
19
|
+
queryClient.setQueryData(['devices', 'list', { device_id: variables.device_id }], (thermostats) => {
|
|
20
|
+
if (thermostats == null) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return thermostats.map((thermostat) => {
|
|
24
|
+
if (thermostat.device_id === variables.device_id) {
|
|
25
|
+
return getUpdatedThermostat(thermostat, variables);
|
|
26
|
+
}
|
|
27
|
+
return thermostat;
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function getUpdatedThermostat(thermostat, variables) {
|
|
34
|
+
return {
|
|
35
|
+
...thermostat,
|
|
36
|
+
properties: {
|
|
37
|
+
...thermostat.properties,
|
|
38
|
+
current_climate_setting: {
|
|
39
|
+
...thermostat.properties.current_climate_setting,
|
|
40
|
+
...variables,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=use-heat-cool-thermostat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-heat-cool-thermostat.js","sourceRoot":"","sources":["../../../src/lib/seam/thermostats/use-heat-cool-thermostat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,cAAc,GACf,MAAM,uBAAuB,CAAA;AAQ9B,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAMhF,MAAM,UAAU,qBAAqB;IAKnC,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IAEpC,OAAO,WAAW,CAIhB;QACA,UAAU,EAAE,KAAK,EAAE,cAAmD,EAAE,EAAE;YACxE,IAAI,MAAM,KAAK,IAAI;gBAAE,MAAM,IAAI,mBAAmB,EAAE,CAAA;YAEpD,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAA;QAC1D,CAAC;QACD,SAAS,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;YAC9B,WAAW,CAAC,YAAY,CACtB,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,EACtD,CAAC,UAAU,EAAE,EAAE;gBACb,IAAI,UAAU,IAAI,IAAI,EAAE;oBACtB,OAAM;iBACP;gBAED,OAAO,oBAAoB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;YACpD,CAAC,CACF,CAAA;YAED,WAAW,CAAC,YAAY,CACtB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,CAAC,SAAS,EAAE,CAAC,EACvD,CAAC,WAAW,EAAsB,EAAE;gBAClC,IAAI,WAAW,IAAI,IAAI,EAAE;oBACvB,OAAO,EAAE,CAAA;iBACV;gBAED,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE;oBACpC,IAAI,UAAU,CAAC,SAAS,KAAK,SAAS,CAAC,SAAS,EAAE;wBAChD,OAAO,oBAAoB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAA;qBACnD;oBAED,OAAO,UAAU,CAAA;gBACnB,CAAC,CAAC,CAAA;YACJ,CAAC,CACF,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,oBAAoB,CAC3B,UAA4B,EAC5B,SAA8C;IAE9C,OAAO;QACL,GAAG,UAAU;QACb,UAAU,EAAE;YACV,GAAG,UAAU,CAAC,UAAU;YACxB,uBAAuB,EAAE;gBACvB,GAAG,UAAU,CAAC,UAAU,CAAC,uBAAuB;gBAChD,GAAG,SAAS;aACb;SACF;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import type { SeamError, ThermostatHeatRequest } from 'seamapi';
|
|
3
|
+
type UseHeatThermostatData = Record<string, unknown>;
|
|
4
|
+
type UseHeatThermostatMutationParams = ThermostatHeatRequest;
|
|
5
|
+
export declare function useHeatThermostat(): UseMutationResult<UseHeatThermostatData, SeamError, UseHeatThermostatMutationParams>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useMutation, useQueryClient, } from '@tanstack/react-query';
|
|
2
|
+
import { NullSeamClientError, useSeamClient } from '../../../lib/seam/use-seam-client.js';
|
|
3
|
+
export function useHeatThermostat() {
|
|
4
|
+
const { client } = useSeamClient();
|
|
5
|
+
const queryClient = useQueryClient();
|
|
6
|
+
return useMutation({
|
|
7
|
+
mutationFn: async (mutationParams) => {
|
|
8
|
+
if (client === null)
|
|
9
|
+
throw new NullSeamClientError();
|
|
10
|
+
return await client.thermostats.heat(mutationParams);
|
|
11
|
+
},
|
|
12
|
+
onSuccess: (_data, variables) => {
|
|
13
|
+
queryClient.setQueryData(['devices', 'get', { device_id: variables.device_id }], (thermostat) => {
|
|
14
|
+
if (thermostat == null) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
return getUpdatedThermostat(thermostat, variables);
|
|
18
|
+
});
|
|
19
|
+
queryClient.setQueryData(['devices', 'list', { device_id: variables.device_id }], (thermostats) => {
|
|
20
|
+
if (thermostats == null) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return thermostats.map((thermostat) => {
|
|
24
|
+
if (thermostat.device_id === variables.device_id) {
|
|
25
|
+
return getUpdatedThermostat(thermostat, variables);
|
|
26
|
+
}
|
|
27
|
+
return thermostat;
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function getUpdatedThermostat(thermostat, variables) {
|
|
34
|
+
return {
|
|
35
|
+
...thermostat,
|
|
36
|
+
properties: {
|
|
37
|
+
...thermostat.properties,
|
|
38
|
+
current_climate_setting: {
|
|
39
|
+
...thermostat.properties.current_climate_setting,
|
|
40
|
+
heating_set_point_fahrenheit: variables.heating_set_point_fahrenheit ??
|
|
41
|
+
thermostat.properties.current_climate_setting
|
|
42
|
+
.heating_set_point_fahrenheit,
|
|
43
|
+
heating_set_point_celsius: variables.heating_set_point_celsius ??
|
|
44
|
+
thermostat.properties.current_climate_setting
|
|
45
|
+
.heating_set_point_celsius,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=use-heat-thermostat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-heat-thermostat.js","sourceRoot":"","sources":["../../../src/lib/seam/thermostats/use-heat-thermostat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,cAAc,GACf,MAAM,uBAAuB,CAAA;AAQ9B,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAMhF,MAAM,UAAU,iBAAiB;IAK/B,MAAM,EAAE,MAAM,EAAE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AG,UAAU,CAAC,UAAU;YACxB,uBAAuB,EAAE;gBACvB,GAAG,UAAU,CAAC,UAAU,CAAC,uBAAuB;gBAChD,4BAA4B,EAC1B,SAAS,CAAC,4BAA4B;oBACtC,UAAU,CAAC,UAAU,CAAC,uBAAuB;yBAC1C,4BAA4B;gBACjC,yBAAyB,EACvB,SAAS,CAAC,yBAAyB;oBACnC,UAAU,CAAC,UAAU,CAAC,uBAAuB;yBAC1C,yBAAyB;aAC/B;SACF;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type UseMutationResult } from '@tanstack/react-query';
|
|
2
|
+
import type { SeamError, ThermostatOffRequest } from 'seamapi';
|
|
3
|
+
type UseSetThermostatOffData = Record<string, unknown>;
|
|
4
|
+
type UseSetThermostatOffMutationParams = ThermostatOffRequest;
|
|
5
|
+
export declare function useSetThermostatOff(): UseMutationResult<UseSetThermostatOffData, SeamError, UseSetThermostatOffMutationParams>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useMutation, useQueryClient, } from '@tanstack/react-query';
|
|
2
|
+
import { NullSeamClientError, useSeamClient } from '../../../lib/seam/use-seam-client.js';
|
|
3
|
+
export function useSetThermostatOff() {
|
|
4
|
+
const { client } = useSeamClient();
|
|
5
|
+
const queryClient = useQueryClient();
|
|
6
|
+
return useMutation({
|
|
7
|
+
mutationFn: async (mutationParams) => {
|
|
8
|
+
if (client === null)
|
|
9
|
+
throw new NullSeamClientError();
|
|
10
|
+
return await client.thermostats.off(mutationParams);
|
|
11
|
+
},
|
|
12
|
+
onSuccess: (_data, variables) => {
|
|
13
|
+
queryClient.setQueryData(['devices', 'get', { device_id: variables.device_id }], (thermostat) => {
|
|
14
|
+
if (thermostat == null) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
return getUpdatedThermostat(thermostat);
|
|
18
|
+
});
|
|
19
|
+
queryClient.setQueryData(['devices', 'list', { device_id: variables.device_id }], (thermostats) => {
|
|
20
|
+
if (thermostats == null) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
return thermostats.map((thermostat) => {
|
|
24
|
+
if (thermostat.device_id === variables.device_id) {
|
|
25
|
+
return getUpdatedThermostat(thermostat);
|
|
26
|
+
}
|
|
27
|
+
return thermostat;
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function getUpdatedThermostat(thermostat) {
|
|
34
|
+
return {
|
|
35
|
+
...thermostat,
|
|
36
|
+
properties: {
|
|
37
|
+
...thermostat.properties,
|
|
38
|
+
is_fan_running: false,
|
|
39
|
+
current_climate_setting: {
|
|
40
|
+
...thermostat.properties.current_climate_setting,
|
|
41
|
+
automatic_cooling_enabled: false,
|
|
42
|
+
automatic_heating_enabled: false,
|
|
43
|
+
hvac_mode_setting: 'off',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=use-set-thermostat-off.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-set-thermostat-off.js","sourceRoot":"","sources":["../../../src/lib/seam/thermostats/use-set-thermostat-off.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,cAAc,GACf,MAAM,uBAAuB,CAAA;AAQ9B,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAMhF,MAAM,UAAU,mBAAmB;IAKjC,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IAEpC,OAAO,WAAW,CAIhB;QACA,UAAU,EAAE,KAAK,EAAE,cAAiD,EAAE,EAAE;YACtE,IAAI,MAAM,KAAK,IAAI;gBAAE,MAAM,IAAI,mBAAmB,EAAE,CAAA;YAEpD,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC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.update(mutationParams);
|
|
11
11
|
},
|
|
12
12
|
onSuccess: (_data, variables) => {
|
|
13
|
-
queryClient.setQueryData(['
|
|
13
|
+
queryClient.setQueryData(['devices', 'get', { device_id: variables.device_id }], (thermostat) => {
|
|
14
14
|
if (thermostat == null) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
return getUpdatedThermostat(thermostat, variables);
|
|
18
18
|
});
|
|
19
|
-
queryClient.setQueryData(['
|
|
19
|
+
queryClient.setQueryData(['devices', 'list', { device_id: variables.device_id }], (thermostats) => {
|
|
20
20
|
if (thermostats == null) {
|
|
21
21
|
return [];
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-update-thermostat.js","sourceRoot":"","sources":["../../../src/lib/seam/thermostats/use-update-thermostat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,cAAc,GACf,MAAM,uBAAuB,CAAA;AAQ9B,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAMhF,MAAM,UAAU,mBAAmB;IAKjC,MAAM,EAAE,MAAM,EAAE,GAAG,aAAa,EAAE,CAAA;IAClC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IAEpC,OAAO,WAAW,CAIhB;QACA,UAAU,EAAE,KAAK,EAAE,cAAiD,EAAE,EAAE;YACtE,IAAI,MAAM,KAAK,IAAI;gBAAE,MAAM,IAAI,mBAAmB,EAAE,CAAA;YAEpD,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;QACxD,CAAC;QACD,SAAS,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;YAC9B,WAAW,CAAC,YAAY,CACtB,CAAC,
|
|
1
|
+
{"version":3,"file":"use-update-thermostat.js","sourceRoot":"","sources":["../../../src/lib/seam/thermostats/use-update-thermostat.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,cAAc,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F,CAAA;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,oBAAoB,CAC3B,UAA4B,EAC5B,SAA4C;IAE5C,OAAO;QACL,GAAG,UAAU;QAEb,UAAU,EAAE;YACV,GAAG,UAAU,CAAC,UAAU;YAExB,uBAAuB,EAAE;gBACvB,GAAG,UAAU,CAAC,UAAU,CAAC,uBAAuB;gBAChD,uBAAuB,EACrB,UAAU,CAAC,UAAU,EAAE,uBAAuB;oBAC5C,EAAE,uBAAuB,IAAI,IAAI;oBACjC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,uBAAuB;yBAC1C,uBAAuB;oBAC5B,CAAC,CAAC,IAAI;gBAEV,GAAG,SAAS,CAAC,uBAAuB;aACrC;SACF;KACF,CAAA;AACH,CAAC"}
|
|
@@ -4,5 +4,4 @@ export interface SwitchProps {
|
|
|
4
4
|
onChange: (checked: boolean) => void;
|
|
5
5
|
enableLabel?: boolean;
|
|
6
6
|
}
|
|
7
|
-
declare function Switch({ checked, onChange, enableLabel, }: SwitchProps): JSX.Element;
|
|
8
|
-
export default Switch;
|
|
7
|
+
export declare function Switch({ checked, onChange, enableLabel, }: SwitchProps): JSX.Element;
|
package/lib/ui/Switch/Switch.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
function Switch({ checked, onChange, enableLabel = false, }) {
|
|
3
|
+
export function Switch({ checked, onChange, enableLabel = false, }) {
|
|
4
4
|
return (_jsxs("div", { className: 'seam-switch-container', children: [enableLabel && (_jsx("label", { className: 'seam-switch-label', children: checked ? t.on : t.off })), _jsx("div", { className: classNames('seam-switch', {
|
|
5
5
|
'seam-switch-checked': checked,
|
|
6
6
|
}), onClick: () => {
|
|
@@ -11,5 +11,4 @@ const t = {
|
|
|
11
11
|
on: 'On',
|
|
12
12
|
off: 'Off',
|
|
13
13
|
};
|
|
14
|
-
export default Switch;
|
|
15
14
|
//# sourceMappingURL=Switch.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../../src/lib/ui/Switch/Switch.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AAQnC,
|
|
1
|
+
{"version":3,"file":"Switch.js","sourceRoot":"","sources":["../../../src/lib/ui/Switch/Switch.tsx"],"names":[],"mappings":";AAAA,OAAO,UAAU,MAAM,YAAY,CAAA;AAQnC,MAAM,UAAU,MAAM,CAAC,EACrB,OAAO,EACP,QAAQ,EACR,WAAW,GAAG,KAAK,GACP;IACZ,OAAO,CACL,eAAK,SAAS,EAAC,uBAAuB,aACnC,WAAW,IAAI,CACd,gBAAO,SAAS,EAAC,mBAAmB,YAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAS,CACtE,EACD,cACE,SAAS,EAAE,UAAU,CAAC,aAAa,EAAE;oBACnC,qBAAqB,EAAE,OAAO;iBAC/B,CAAC,EACF,OAAO,EAAE,GAAG,EAAE;oBACZ,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAA;gBACpB,CAAC,YAED,cAAK,SAAS,EAAC,oBAAoB,GAAG,GAClC,IACF,CACP,CAAA;AACH,CAAC;AAED,MAAM,CAAC,GAAG;IACR,EAAE,EAAE,IAAI;IACR,GAAG,EAAE,KAAK;CACX,CAAA"}
|
package/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const seamapiReactVersion = "2.
|
|
1
|
+
declare const seamapiReactVersion = "2.5.0";
|
|
2
2
|
export default seamapiReactVersion;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seamapi/react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Seam Components.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"luxon": "^3.3.0",
|
|
133
133
|
"queue": "^7.0.0",
|
|
134
134
|
"react-hook-form": "^7.46.1",
|
|
135
|
-
"seamapi": "^8.
|
|
135
|
+
"seamapi": "^8.19.0",
|
|
136
136
|
"uuid": "^9.0.0"
|
|
137
137
|
},
|
|
138
138
|
"devDependencies": {
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"@mui/material": "^5.12.2",
|
|
142
142
|
"@rxfork/r2wc-react-to-web-component": "^2.4.0",
|
|
143
143
|
"@seamapi/fake-devicedb": "^1.2.0",
|
|
144
|
-
"@seamapi/fake-seam-connect": "^1.
|
|
144
|
+
"@seamapi/fake-seam-connect": "^1.42.0",
|
|
145
145
|
"@seamapi/http": "^0.2.1",
|
|
146
146
|
"@seamapi/types": "^1.32.0",
|
|
147
147
|
"@storybook/addon-designs": "^7.0.1",
|
|
@@ -9,11 +9,13 @@ import type { CommonProps } from 'lib/seam/components/common-props.js'
|
|
|
9
9
|
import { useConnectedAccount } from 'lib/seam/connected-accounts/use-connected-account.js'
|
|
10
10
|
import { useClimateSettingSchedules } from 'lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedules.js'
|
|
11
11
|
import { useUpdateFanMode } from 'lib/seam/thermostats/use-update-fan-mode.js'
|
|
12
|
+
import { useUpdateThermostat } from 'lib/seam/thermostats/use-update-thermostat.js'
|
|
12
13
|
import { ContentHeader } from 'lib/ui/layout/ContentHeader.js'
|
|
13
14
|
import { DetailRow } from 'lib/ui/layout/DetailRow.js'
|
|
14
15
|
import { DetailSection } from 'lib/ui/layout/DetailSection.js'
|
|
15
16
|
import { DetailSectionGroup } from 'lib/ui/layout/DetailSectionGroup.js'
|
|
16
17
|
import { Snackbar } from 'lib/ui/Snackbar/Snackbar.js'
|
|
18
|
+
import { Switch } from 'lib/ui/Switch/Switch.js'
|
|
17
19
|
import { ClimateSettingStatus } from 'lib/ui/thermostat/ClimateSettingStatus.js'
|
|
18
20
|
import { FanModeMenu } from 'lib/ui/thermostat/FanModeMenu.js'
|
|
19
21
|
import { ThermostatCard } from 'lib/ui/thermostat/ThermostatCard.js'
|
|
@@ -42,8 +44,6 @@ export function ThermostatDeviceDetails({
|
|
|
42
44
|
device_id: device.device_id,
|
|
43
45
|
})
|
|
44
46
|
|
|
45
|
-
const { mutate: updateFanMode, isSuccess, isError } = useUpdateFanMode()
|
|
46
|
-
|
|
47
47
|
if (climateSettingsOpen) {
|
|
48
48
|
return (
|
|
49
49
|
<NestedClimateSettingScheduleTable
|
|
@@ -111,17 +111,7 @@ export function ThermostatDeviceDetails({
|
|
|
111
111
|
temperatureUnit='fahrenheit'
|
|
112
112
|
/>
|
|
113
113
|
</DetailRow>
|
|
114
|
-
<
|
|
115
|
-
<FanModeMenu
|
|
116
|
-
mode={device.properties.fan_mode_setting}
|
|
117
|
-
onChange={(fanMode) => {
|
|
118
|
-
updateFanMode({
|
|
119
|
-
device_id: device.device_id,
|
|
120
|
-
fan_mode_setting: fanMode,
|
|
121
|
-
})
|
|
122
|
-
}}
|
|
123
|
-
/>
|
|
124
|
-
</DetailRow>
|
|
114
|
+
<FanModeRow device={device} />
|
|
125
115
|
</DetailSection>
|
|
126
116
|
|
|
127
117
|
<DetailSection
|
|
@@ -138,14 +128,8 @@ export function ThermostatDeviceDetails({
|
|
|
138
128
|
<p>{t.none}</p>
|
|
139
129
|
)}
|
|
140
130
|
</DetailRow>
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
{device.properties.current_climate_setting
|
|
144
|
-
.manual_override_allowed
|
|
145
|
-
? t.yes
|
|
146
|
-
: t.no}
|
|
147
|
-
</p>
|
|
148
|
-
</DetailRow>
|
|
131
|
+
|
|
132
|
+
<ManualOverrideRow device={device} />
|
|
149
133
|
</DetailSection>
|
|
150
134
|
|
|
151
135
|
<DetailSection label={t.deviceDetails}>
|
|
@@ -169,6 +153,68 @@ export function ThermostatDeviceDetails({
|
|
|
169
153
|
</DetailSectionGroup>
|
|
170
154
|
</div>
|
|
171
155
|
</div>
|
|
156
|
+
</div>
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function ManualOverrideRow({
|
|
161
|
+
device,
|
|
162
|
+
}: {
|
|
163
|
+
device: ThermostatDevice
|
|
164
|
+
}): JSX.Element {
|
|
165
|
+
const { mutate, isSuccess, isError } = useUpdateThermostat()
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<>
|
|
169
|
+
<DetailRow label={t.allowManualOverride}>
|
|
170
|
+
<Switch
|
|
171
|
+
checked={
|
|
172
|
+
device.properties.default_climate_setting
|
|
173
|
+
?.manual_override_allowed ?? true
|
|
174
|
+
}
|
|
175
|
+
onChange={(checked) => {
|
|
176
|
+
mutate({
|
|
177
|
+
device_id: device.device_id,
|
|
178
|
+
default_climate_setting: {
|
|
179
|
+
manual_override_allowed: checked,
|
|
180
|
+
},
|
|
181
|
+
})
|
|
182
|
+
}}
|
|
183
|
+
/>
|
|
184
|
+
</DetailRow>
|
|
185
|
+
<Snackbar
|
|
186
|
+
message={t.manualOverrideSuccess}
|
|
187
|
+
variant='success'
|
|
188
|
+
visible={isSuccess}
|
|
189
|
+
automaticVisibility
|
|
190
|
+
/>
|
|
191
|
+
|
|
192
|
+
<Snackbar
|
|
193
|
+
message={t.manualOverrideError}
|
|
194
|
+
variant='error'
|
|
195
|
+
visible={isError}
|
|
196
|
+
automaticVisibility
|
|
197
|
+
/>
|
|
198
|
+
</>
|
|
199
|
+
)
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function FanModeRow({ device }: { device: ThermostatDevice }): JSX.Element {
|
|
203
|
+
const { mutate, isSuccess, isError } = useUpdateFanMode()
|
|
204
|
+
|
|
205
|
+
return (
|
|
206
|
+
<>
|
|
207
|
+
<DetailRow label={t.fanMode}>
|
|
208
|
+
<FanModeMenu
|
|
209
|
+
mode={device.properties.fan_mode_setting}
|
|
210
|
+
onChange={(fanMode) => {
|
|
211
|
+
mutate({
|
|
212
|
+
device_id: device.device_id,
|
|
213
|
+
fan_mode_setting: fanMode,
|
|
214
|
+
})
|
|
215
|
+
}}
|
|
216
|
+
/>
|
|
217
|
+
</DetailRow>
|
|
172
218
|
|
|
173
219
|
<Snackbar
|
|
174
220
|
message={t.fanModeSuccess}
|
|
@@ -184,7 +230,7 @@ export function ThermostatDeviceDetails({
|
|
|
184
230
|
visible={isError}
|
|
185
231
|
automaticVisibility
|
|
186
232
|
/>
|
|
187
|
-
|
|
233
|
+
</>
|
|
188
234
|
)
|
|
189
235
|
}
|
|
190
236
|
|
|
@@ -211,8 +257,8 @@ const t = {
|
|
|
211
257
|
linkedAccount: 'Linked account',
|
|
212
258
|
deviceId: 'Device ID',
|
|
213
259
|
none: 'None',
|
|
214
|
-
yes: 'Yes',
|
|
215
|
-
no: 'No',
|
|
216
260
|
fanModeSuccess: 'Successfully updated fan mode!',
|
|
217
261
|
fanModeError: 'Error updating fan mode. Please try again.',
|
|
262
|
+
manualOverrideSuccess: 'Successfully updated manual override!',
|
|
263
|
+
manualOverrideError: 'Error updating manual override. Please try again.',
|
|
218
264
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { DeviceModelV1 } from '@seamapi/types/devicedb'
|
|
2
2
|
import { useMemo } from 'react'
|
|
3
3
|
|
|
4
|
-
import { SupportedDeviceFilterResultRow } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceFilterResultRow.js'
|
|
5
4
|
import { SupportedDeviceManufacturerSection } from 'lib/seam/components/SupportedDeviceTable/SupportedDeviceManufacturerSection.js'
|
|
6
5
|
import type { UseDeviceModelsData } from 'lib/seam/components/SupportedDeviceTable/use-device-models.js'
|
|
7
6
|
import {
|
|
@@ -80,21 +79,6 @@ export function SupportedDeviceContent({
|
|
|
80
79
|
)
|
|
81
80
|
}
|
|
82
81
|
|
|
83
|
-
const hasFilters = filterValue.trim() !== '' || filters.manufacturer !== null
|
|
84
|
-
|
|
85
|
-
if (hasFilters) {
|
|
86
|
-
return (
|
|
87
|
-
<div className='seam-supported-device-table-content'>
|
|
88
|
-
{deviceModels.map((deviceModel) => (
|
|
89
|
-
<SupportedDeviceFilterResultRow
|
|
90
|
-
key={deviceModel.device_model_id}
|
|
91
|
-
deviceModel={deviceModel}
|
|
92
|
-
/>
|
|
93
|
-
))}
|
|
94
|
-
</div>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
82
|
return (
|
|
99
83
|
<>
|
|
100
84
|
{Object.entries(groupedDeviceModels)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useMutation,
|
|
3
|
+
type UseMutationResult,
|
|
4
|
+
useQueryClient,
|
|
5
|
+
} from '@tanstack/react-query'
|
|
6
|
+
import type {
|
|
7
|
+
SeamError,
|
|
8
|
+
ThermostatCoolRequest,
|
|
9
|
+
ThermostatDevice,
|
|
10
|
+
ThermostatsListResponse,
|
|
11
|
+
} from 'seamapi'
|
|
12
|
+
|
|
13
|
+
import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
|
|
14
|
+
|
|
15
|
+
// UPSTREAM: Missing ThermostatCoolResponse in seamapi.
|
|
16
|
+
type UseCoolThermostatData = Record<string, unknown>
|
|
17
|
+
type UseCoolThermostatMutationParams = ThermostatCoolRequest
|
|
18
|
+
|
|
19
|
+
export function useCoolThermostat(): UseMutationResult<
|
|
20
|
+
UseCoolThermostatData,
|
|
21
|
+
SeamError,
|
|
22
|
+
UseCoolThermostatMutationParams
|
|
23
|
+
> {
|
|
24
|
+
const { client } = useSeamClient()
|
|
25
|
+
const queryClient = useQueryClient()
|
|
26
|
+
|
|
27
|
+
return useMutation<
|
|
28
|
+
UseCoolThermostatData,
|
|
29
|
+
SeamError,
|
|
30
|
+
UseCoolThermostatMutationParams
|
|
31
|
+
>({
|
|
32
|
+
mutationFn: async (mutationParams: UseCoolThermostatMutationParams) => {
|
|
33
|
+
if (client === null) throw new NullSeamClientError()
|
|
34
|
+
|
|
35
|
+
return await client.thermostats.cool(mutationParams)
|
|
36
|
+
},
|
|
37
|
+
onSuccess: (_data, variables) => {
|
|
38
|
+
queryClient.setQueryData<ThermostatDevice | null>(
|
|
39
|
+
['devices', 'get', { device_id: variables.device_id }],
|
|
40
|
+
(thermostat) => {
|
|
41
|
+
if (thermostat == null) {
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return getUpdatedThermostat(thermostat, variables)
|
|
46
|
+
}
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
queryClient.setQueryData<ThermostatsListResponse['thermostats']>(
|
|
50
|
+
['devices', 'list', { device_id: variables.device_id }],
|
|
51
|
+
(thermostats): ThermostatDevice[] => {
|
|
52
|
+
if (thermostats == null) {
|
|
53
|
+
return []
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return thermostats.map((thermostat) => {
|
|
57
|
+
if (thermostat.device_id === variables.device_id) {
|
|
58
|
+
return getUpdatedThermostat(thermostat, variables)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return thermostat
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
},
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function getUpdatedThermostat(
|
|
70
|
+
thermostat: ThermostatDevice,
|
|
71
|
+
variables: UseCoolThermostatMutationParams
|
|
72
|
+
): ThermostatDevice {
|
|
73
|
+
return {
|
|
74
|
+
...thermostat,
|
|
75
|
+
properties: {
|
|
76
|
+
...thermostat.properties,
|
|
77
|
+
current_climate_setting: {
|
|
78
|
+
...thermostat.properties.current_climate_setting,
|
|
79
|
+
cooling_set_point_fahrenheit:
|
|
80
|
+
variables.cooling_set_point_fahrenheit ??
|
|
81
|
+
thermostat.properties.current_climate_setting
|
|
82
|
+
.cooling_set_point_fahrenheit,
|
|
83
|
+
cooling_set_point_celsius:
|
|
84
|
+
variables.cooling_set_point_celsius ??
|
|
85
|
+
thermostat.properties.current_climate_setting
|
|
86
|
+
.cooling_set_point_celsius,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
}
|
|
90
|
+
}
|