Once a user has onboarded, you can set and get user preferences for their devices.

Previewing Schedules

Before saving user preferences, you can preview the suggested set-point schedules.

const userPreferences = {
  tempUnits: "F",
  defaultMode: "AUTO",
  defaultMaxTemp: "75",
  defaultMinTemp: "65",
  scheduleBlocks: [
    {
      daysOfWeek: [1, 2, 3, 4, 5],
      startTimeMinutes: "0",
      endTimeMinutes: "1439",
      targetTemp: "70",
    },
    {
      daysOfWeek: [0, 6],
      startTimeMinutes: "0",
      endTimeMinutes: "1439",
      targetTemp: "68",
    },
  ],
};

// Preview the data.
const { blocks } = await wattshiftApiCall(
  `/devices/hvac/${hvac.id}/preview`,
  userPreferences
);
const tempData = blocks.map((b) => ({
  startTime: b.startTime,
  endTime: b.endTime,
  targetTemp: b.targetTemp,
}));

Saving Preferences

If all looks good, you can save the user preferences.

await wattshiftApiCall(
  `/devices/hvac/${hvac.id}/user_preferences/set`,
  userPreferences
);