diff --git a/.storybook/seed-fake.js b/.storybook/seed-fake.js index 40873e84a..c0828746c 100644 --- a/.storybook/seed-fake.js +++ b/.storybook/seed-fake.js @@ -352,6 +352,8 @@ export const seedFake = (db) => { online: true, is_cooling: false, is_heating: false, + is_heating_available: true, + is_cooling_available: true, manufacturer: 'ecobee', is_fan_running: false, model: { @@ -371,16 +373,20 @@ export const seedFake = (db) => { manual_override_allowed: false, automatic_cooling_enabled: true, automatic_heating_enabled: true, - cooling_set_point_celsius: 23.88888888888889, - heating_set_point_celsius: 18.333333333333336, + cooling_set_point_fahrenheit: 75, + heating_set_point_fahrenheit: 65, + }, + default_climate_setting: { + hvac_mode_setting: 'heat_cool', + manual_override_allowed: false, + automatic_cooling_enabled: true, + automatic_heating_enabled: true, cooling_set_point_fahrenheit: 75, heating_set_point_fahrenheit: 65, }, available_hvac_mode_settings: ['off', 'cool', 'heat', 'heat_cool'], can_enable_automatic_cooling: true, can_enable_automatic_heating: true, - is_cooling_available: true, - is_heating_available: true, min_heating_cooling_delta_fahrenheit: 5, max_cooling_set_point_fahrenheit: 92, min_cooling_set_point_fahrenheit: 65, diff --git a/package-lock.json b/package-lock.json index 7dd342856..5d9473d06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "@mui/material": "^5.12.2", "@rxfork/r2wc-react-to-web-component": "^2.4.0", "@seamapi/fake-devicedb": "^1.2.0", - "@seamapi/fake-seam-connect": "^1.41.0", + "@seamapi/fake-seam-connect": "^1.42.0", "@seamapi/http": "^0.2.1", "@seamapi/types": "^1.32.0", "@storybook/addon-designs": "^7.0.1", @@ -4662,9 +4662,9 @@ } }, "node_modules/@seamapi/fake-seam-connect": { - "version": "1.41.0", - "resolved": "https://registry.npmjs.org/@seamapi/fake-seam-connect/-/fake-seam-connect-1.41.0.tgz", - "integrity": "sha512-fJ7HWLzdrt4KuRd8QjxQ7kRA126QhZIvyuhL6EP/iL8kgeG74nivHldtyOT3LpLUbRZOD0KBnfFwVBtvxdB4xw==", + "version": "1.42.0", + "resolved": "https://registry.npmjs.org/@seamapi/fake-seam-connect/-/fake-seam-connect-1.42.0.tgz", + "integrity": "sha512-xoPp2NaVRunED2+CI6w5xATHfjSQoxV6oG7EJbt7v6LW9yzZk1X7wCW/VZmG5fNEBzVG/Yn8A5rFaK2PNuiA4g==", "dev": true, "bin": { "fake-seam-connect": "dist/server.js" diff --git a/package.json b/package.json index 14ff6c8de..34241138e 100644 --- a/package.json +++ b/package.json @@ -141,7 +141,7 @@ "@mui/material": "^5.12.2", "@rxfork/r2wc-react-to-web-component": "^2.4.0", "@seamapi/fake-devicedb": "^1.2.0", - "@seamapi/fake-seam-connect": "^1.41.0", + "@seamapi/fake-seam-connect": "^1.42.0", "@seamapi/http": "^0.2.1", "@seamapi/types": "^1.32.0", "@storybook/addon-designs": "^7.0.1", diff --git a/src/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.tsx b/src/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.tsx index 850a6a363..00c4a56f3 100644 --- a/src/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.tsx +++ b/src/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.tsx @@ -9,11 +9,13 @@ import type { CommonProps } from 'lib/seam/components/common-props.js' import { useConnectedAccount } from 'lib/seam/connected-accounts/use-connected-account.js' import { useClimateSettingSchedules } from 'lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedules.js' import { useUpdateFanMode } from 'lib/seam/thermostats/use-update-fan-mode.js' +import { useUpdateThermostat } from 'lib/seam/thermostats/use-update-thermostat.js' import { ContentHeader } from 'lib/ui/layout/ContentHeader.js' import { DetailRow } from 'lib/ui/layout/DetailRow.js' import { DetailSection } from 'lib/ui/layout/DetailSection.js' import { DetailSectionGroup } from 'lib/ui/layout/DetailSectionGroup.js' import { Snackbar } from 'lib/ui/Snackbar/Snackbar.js' +import { Switch } from 'lib/ui/Switch/Switch.js' import { ClimateSettingStatus } from 'lib/ui/thermostat/ClimateSettingStatus.js' import { FanModeMenu } from 'lib/ui/thermostat/FanModeMenu.js' import { ThermostatCard } from 'lib/ui/thermostat/ThermostatCard.js' @@ -42,7 +44,17 @@ export function ThermostatDeviceDetails({ device_id: device.device_id, }) - const { mutate: updateFanMode, isSuccess, isError } = useUpdateFanMode() + const { + mutate: updateFanMode, + isError: isFanModeError, + isSuccess: isFanModeSuccess, + } = useUpdateFanMode() + + const { + mutate: updateThermostat, + isSuccess: isThermostatUpdateSuccess, + isError: isThermostatUpdateError, + } = useUpdateThermostat() if (climateSettingsOpen) { return ( @@ -139,12 +151,20 @@ export function ThermostatDeviceDetails({ )} -

- {device.properties.current_climate_setting - .manual_override_allowed - ? t.yes - : t.no} -

+ { + updateThermostat({ + device_id: device.device_id, + default_climate_setting: { + manual_override_allowed: checked, + }, + }) + }} + />
@@ -170,10 +190,24 @@ export function ThermostatDeviceDetails({ + + + + @@ -181,7 +215,7 @@ export function ThermostatDeviceDetails({ @@ -211,8 +245,8 @@ const t = { linkedAccount: 'Linked account', deviceId: 'Device ID', none: 'None', - yes: 'Yes', - no: 'No', fanModeSuccess: 'Successfully updated fan mode!', fanModeError: 'Error updating fan mode. Please try again.', + manualOverrideSuccess: 'Successfully updated manual override!', + manualOverrideError: 'Error updating manual override. Please try again.', }