@seamapi/react 2.20.0 → 3.0.1

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.
Files changed (402) hide show
  1. package/README.md +4 -4
  2. package/dist/elements.js +19676 -25734
  3. package/dist/elements.js.map +1 -1
  4. package/lib/object.d.ts +5 -0
  5. package/lib/object.js +14 -0
  6. package/lib/object.js.map +1 -0
  7. package/lib/seam/SeamProvider.d.ts +5 -4
  8. package/lib/seam/SeamProvider.js.map +1 -1
  9. package/lib/seam/access-codes/use-access-code.d.ts +3 -2
  10. package/lib/seam/access-codes/use-access-code.js +2 -3
  11. package/lib/seam/access-codes/use-access-code.js.map +1 -1
  12. package/lib/seam/access-codes/use-access-codes.d.ts +3 -2
  13. package/lib/seam/access-codes/use-access-codes.js +3 -5
  14. package/lib/seam/access-codes/use-access-codes.js.map +1 -1
  15. package/lib/seam/access-codes/use-create-access-code.d.ts +4 -3
  16. package/lib/seam/access-codes/use-create-access-code.js +5 -4
  17. package/lib/seam/access-codes/use-create-access-code.js.map +1 -1
  18. package/lib/seam/access-codes/use-delete-access-code.d.ts +4 -6
  19. package/lib/seam/access-codes/use-delete-access-code.js +10 -8
  20. package/lib/seam/access-codes/use-delete-access-code.js.map +1 -1
  21. package/lib/seam/access-codes/use-generate-access-code-code.d.ts +4 -4
  22. package/lib/seam/access-codes/use-generate-access-code-code.js +3 -2
  23. package/lib/seam/access-codes/use-generate-access-code-code.js.map +1 -1
  24. package/lib/seam/access-codes/use-update-access-code.d.ts +4 -4
  25. package/lib/seam/access-codes/use-update-access-code.js +9 -7
  26. package/lib/seam/access-codes/use-update-access-code.js.map +1 -1
  27. package/lib/seam/client-sessions/use-client-session.d.ts +1 -1
  28. package/lib/seam/client-sessions/use-client-session.js +1 -1
  29. package/lib/seam/client-sessions/use-client-session.js.map +1 -1
  30. package/lib/seam/components/AccessCodeDetails/AccessCodeDetails.d.ts +1 -1
  31. package/lib/seam/components/AccessCodeDetails/AccessCodeDetails.js +14 -6
  32. package/lib/seam/components/AccessCodeDetails/AccessCodeDetails.js.map +1 -1
  33. package/lib/seam/components/AccessCodeDetails/AccessCodeDevice.d.ts +1 -1
  34. package/lib/seam/components/AccessCodeDetails/AccessCodeDevice.js +9 -6
  35. package/lib/seam/components/AccessCodeDetails/AccessCodeDevice.js.map +1 -1
  36. package/lib/seam/components/AccessCodeTable/AccessCodeHealthBar.d.ts +3 -4
  37. package/lib/seam/components/AccessCodeTable/AccessCodeHealthBar.js.map +1 -1
  38. package/lib/seam/components/AccessCodeTable/AccessCodeMainIcon.d.ts +3 -3
  39. package/lib/seam/components/AccessCodeTable/AccessCodeMainIcon.js.map +1 -1
  40. package/lib/seam/components/AccessCodeTable/AccessCodeMenu.d.ts +3 -3
  41. package/lib/seam/components/AccessCodeTable/AccessCodeMenu.js +1 -1
  42. package/lib/seam/components/AccessCodeTable/AccessCodeMenu.js.map +1 -1
  43. package/lib/seam/components/AccessCodeTable/AccessCodeRow.d.ts +3 -3
  44. package/lib/seam/components/AccessCodeTable/AccessCodeRow.js.map +1 -1
  45. package/lib/seam/components/AccessCodeTable/AccessCodeTable.d.ts +2 -4
  46. package/lib/seam/components/AccessCodeTable/AccessCodeTable.js +1 -1
  47. package/lib/seam/components/AccessCodeTable/AccessCodeTable.js.map +1 -1
  48. package/lib/seam/components/AccessCodeTable/CodeDetails.d.ts +2 -2
  49. package/lib/seam/components/AccessCodeTable/CodeDetails.js +5 -2
  50. package/lib/seam/components/AccessCodeTable/CodeDetails.js.map +1 -1
  51. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleCard.d.ts +1 -1
  52. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleCard.js +3 -1
  53. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleCard.js.map +1 -1
  54. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDetails.d.ts +1 -1
  55. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDetails.js +3 -1
  56. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDetails.js.map +1 -1
  57. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDeviceBar.d.ts +1 -1
  58. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDeviceBar.js +3 -3
  59. package/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDeviceBar.js.map +1 -1
  60. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRow.d.ts +3 -3
  61. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRow.js.map +1 -1
  62. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRowDetails.d.ts +2 -2
  63. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRowDetails.js.map +1 -1
  64. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleTable.d.ts +2 -2
  65. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleTable.js +1 -1
  66. package/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleTable.js.map +1 -1
  67. package/lib/seam/components/ConnectAccountButton/ConnectAccountButton.d.ts +1 -1
  68. package/lib/seam/components/ConnectAccountButton/ConnectAccountButton.js +2 -2
  69. package/lib/seam/components/CreateAccessCodeForm/CreateAccessCodeForm.d.ts +3 -3
  70. package/lib/seam/components/CreateAccessCodeForm/CreateAccessCodeForm.js +12 -9
  71. package/lib/seam/components/CreateAccessCodeForm/CreateAccessCodeForm.js.map +1 -1
  72. package/lib/seam/components/CreateClimateSettingScheduleForm/CreateClimateSettingScheduleForm.d.ts +1 -1
  73. package/lib/seam/components/CreateClimateSettingScheduleForm/CreateClimateSettingScheduleForm.js +1 -1
  74. package/lib/seam/components/DeviceDetails/DeviceDetails.d.ts +1 -1
  75. package/lib/seam/components/DeviceDetails/DeviceDetails.js +3 -1
  76. package/lib/seam/components/DeviceDetails/DeviceDetails.js.map +1 -1
  77. package/lib/seam/components/DeviceDetails/DeviceInfo.d.ts +3 -3
  78. package/lib/seam/components/DeviceDetails/DeviceInfo.js +3 -1
  79. package/lib/seam/components/DeviceDetails/DeviceInfo.js.map +1 -1
  80. package/lib/seam/components/DeviceDetails/DeviceModel.d.ts +3 -3
  81. package/lib/seam/components/DeviceDetails/LockDeviceDetails.d.ts +2 -2
  82. package/lib/seam/components/DeviceDetails/LockDeviceDetails.js +5 -5
  83. package/lib/seam/components/DeviceDetails/LockDeviceDetails.js.map +1 -1
  84. package/lib/seam/components/DeviceDetails/NoiseSensorDeviceDetails.d.ts +2 -2
  85. package/lib/seam/components/DeviceDetails/NoiseSensorDeviceDetails.js.map +1 -1
  86. package/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.d.ts +2 -2
  87. package/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.js +3 -3
  88. package/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.js.map +1 -1
  89. package/lib/seam/components/DeviceTable/DeviceHealthBar.d.ts +3 -4
  90. package/lib/seam/components/DeviceTable/DeviceHealthBar.js.map +1 -1
  91. package/lib/seam/components/DeviceTable/DeviceRow.d.ts +4 -3
  92. package/lib/seam/components/DeviceTable/DeviceRow.js +2 -2
  93. package/lib/seam/components/DeviceTable/DeviceRow.js.map +1 -1
  94. package/lib/seam/components/DeviceTable/DeviceTable.d.ts +3 -6
  95. package/lib/seam/components/DeviceTable/DeviceTable.js +4 -2
  96. package/lib/seam/components/DeviceTable/DeviceTable.js.map +1 -1
  97. package/lib/seam/components/EditAccessCodeForm/EditAccessCodeForm.d.ts +1 -1
  98. package/lib/seam/components/EditAccessCodeForm/EditAccessCodeForm.js +2 -2
  99. package/lib/seam/components/EditAccessCodeForm/EditAccessCodeForm.js.map +1 -1
  100. package/lib/seam/components/SupportedDeviceTable/FilterCategoryMenu.d.ts +1 -1
  101. package/lib/seam/components/SupportedDeviceTable/HiddenDevicesOverlay.d.ts +1 -1
  102. package/lib/seam/components/SupportedDeviceTable/ShowAllDevicesButton.d.ts +1 -1
  103. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.d.ts +1 -1
  104. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.js +2 -2
  105. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.js.map +1 -1
  106. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceContentRows.d.ts +3 -3
  107. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceContentRows.js.map +1 -1
  108. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceManufacturerSection.d.ts +1 -1
  109. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceRow.d.ts +1 -1
  110. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceTable.d.ts +1 -1
  111. package/lib/seam/components/SupportedDeviceTable/SupportedDeviceTableManufacturerKeys.d.ts +1 -1
  112. package/lib/seam/components/SupportedDeviceTable/use-device-model.d.ts +2 -2
  113. package/lib/seam/components/SupportedDeviceTable/use-device-model.js +3 -4
  114. package/lib/seam/components/SupportedDeviceTable/use-device-model.js.map +1 -1
  115. package/lib/seam/components/SupportedDeviceTable/use-device-models.js +2 -4
  116. package/lib/seam/components/SupportedDeviceTable/use-device-models.js.map +1 -1
  117. package/lib/seam/components/SupportedDeviceTable/use-manufacturer.d.ts +2 -2
  118. package/lib/seam/components/SupportedDeviceTable/use-manufacturer.js +2 -3
  119. package/lib/seam/components/SupportedDeviceTable/use-manufacturer.js.map +1 -1
  120. package/lib/seam/components/SupportedDeviceTable/use-manufacturers.js +1 -3
  121. package/lib/seam/components/SupportedDeviceTable/use-manufacturers.js.map +1 -1
  122. package/lib/seam/components/common-props.d.ts +2 -2
  123. package/lib/seam/components/common-props.js.map +1 -1
  124. package/lib/seam/connect-webviews/use-create-connect-webview.d.ts +4 -3
  125. package/lib/seam/connect-webviews/use-create-connect-webview.js +3 -3
  126. package/lib/seam/connect-webviews/use-create-connect-webview.js.map +1 -1
  127. package/lib/seam/connected-accounts/use-connected-account.d.ts +3 -2
  128. package/lib/seam/connected-accounts/use-connected-account.js +2 -3
  129. package/lib/seam/connected-accounts/use-connected-account.js.map +1 -1
  130. package/lib/seam/devices/use-device-providers.d.ts +3 -2
  131. package/lib/seam/devices/use-device-providers.js.map +1 -1
  132. package/lib/seam/devices/use-device.d.ts +5 -4
  133. package/lib/seam/devices/use-device.js +2 -3
  134. package/lib/seam/devices/use-device.js.map +1 -1
  135. package/lib/seam/devices/use-devices.d.ts +4 -3
  136. package/lib/seam/devices/use-devices.js +2 -3
  137. package/lib/seam/devices/use-devices.js.map +1 -1
  138. package/lib/seam/events/use-events.d.ts +5 -4
  139. package/lib/seam/events/use-events.js +5 -5
  140. package/lib/seam/events/use-events.js.map +1 -1
  141. package/lib/seam/filters.d.ts +7 -7
  142. package/lib/seam/filters.js.map +1 -1
  143. package/lib/seam/locks/lock-device.d.ts +5 -0
  144. package/lib/seam/locks/lock-device.js +2 -0
  145. package/lib/seam/locks/lock-device.js.map +1 -0
  146. package/lib/seam/locks/use-toggle-lock.d.ts +16 -0
  147. package/lib/seam/locks/use-toggle-lock.js +59 -0
  148. package/lib/seam/locks/use-toggle-lock.js.map +1 -0
  149. package/lib/seam/noise-sensors/noise-sensor-device.d.ts +5 -0
  150. package/lib/seam/noise-sensors/noise-sensor-device.js +2 -0
  151. package/lib/seam/noise-sensors/noise-sensor-device.js.map +1 -0
  152. package/lib/seam/noise-sensors/use-noise-thresholds.d.ts +4 -3
  153. package/lib/seam/noise-sensors/use-noise-thresholds.js +2 -3
  154. package/lib/seam/noise-sensors/use-noise-thresholds.js.map +1 -1
  155. package/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedule.d.ts +3 -2
  156. package/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedule.js +2 -10
  157. package/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedule.js.map +1 -1
  158. package/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedules.d.ts +3 -2
  159. package/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedules.js +3 -4
  160. package/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedules.js.map +1 -1
  161. package/lib/seam/thermostats/climate-setting-schedules/use-create-climate-setting-schedule.d.ts +5 -3
  162. package/lib/seam/thermostats/climate-setting-schedules/use-create-climate-setting-schedule.js +10 -6
  163. package/lib/seam/thermostats/climate-setting-schedules/use-create-climate-setting-schedule.js.map +1 -1
  164. package/lib/seam/thermostats/climate-setting-schedules/use-delete-climate-setting-schedule.d.ts +5 -4
  165. package/lib/seam/thermostats/climate-setting-schedules/use-delete-climate-setting-schedule.js +13 -13
  166. package/lib/seam/thermostats/climate-setting-schedules/use-delete-climate-setting-schedule.js.map +1 -1
  167. package/lib/seam/thermostats/climate-setting-schedules/use-update-climate-setting-schedule.d.ts +5 -5
  168. package/lib/seam/thermostats/climate-setting-schedules/use-update-climate-setting-schedule.js +12 -17
  169. package/lib/seam/thermostats/climate-setting-schedules/use-update-climate-setting-schedule.js.map +1 -1
  170. package/lib/{temperature-bounds.d.ts → seam/thermostats/temperature-bounds.d.ts} +1 -1
  171. package/lib/{temperature-bounds.js → seam/thermostats/temperature-bounds.js} +4 -4
  172. package/lib/seam/thermostats/temperature-bounds.js.map +1 -0
  173. package/lib/seam/thermostats/thermostat-device.d.ts +17 -0
  174. package/lib/seam/thermostats/thermostat-device.js +2 -0
  175. package/lib/seam/thermostats/thermostat-device.js.map +1 -0
  176. package/lib/seam/thermostats/unit-conversion.d.ts +19 -0
  177. package/lib/seam/thermostats/unit-conversion.js +43 -0
  178. package/lib/seam/thermostats/unit-conversion.js.map +1 -0
  179. package/lib/seam/thermostats/use-cool-thermostat.d.ts +10 -4
  180. package/lib/seam/thermostats/use-cool-thermostat.js +34 -27
  181. package/lib/seam/thermostats/use-cool-thermostat.js.map +1 -1
  182. package/lib/seam/thermostats/use-heat-cool-thermostat.d.ts +10 -4
  183. package/lib/seam/thermostats/use-heat-cool-thermostat.js +34 -22
  184. package/lib/seam/thermostats/use-heat-cool-thermostat.js.map +1 -1
  185. package/lib/seam/thermostats/use-heat-thermostat.d.ts +10 -4
  186. package/lib/seam/thermostats/use-heat-thermostat.js +34 -27
  187. package/lib/seam/thermostats/use-heat-thermostat.js.map +1 -1
  188. package/lib/seam/thermostats/use-set-thermostat-fan-mode.d.ts +12 -0
  189. package/lib/seam/thermostats/use-set-thermostat-fan-mode.js +46 -0
  190. package/lib/seam/thermostats/use-set-thermostat-fan-mode.js.map +1 -0
  191. package/lib/seam/thermostats/use-set-thermostat-off.d.ts +10 -4
  192. package/lib/seam/thermostats/use-set-thermostat-off.js +36 -25
  193. package/lib/seam/thermostats/use-set-thermostat-off.js.map +1 -1
  194. package/lib/seam/thermostats/use-update-thermostat.d.ts +5 -5
  195. package/lib/seam/thermostats/use-update-thermostat.js +28 -27
  196. package/lib/seam/thermostats/use-update-thermostat.js.map +1 -1
  197. package/lib/seam/use-seam-client.d.ts +3 -3
  198. package/lib/seam/use-seam-client.js +5 -21
  199. package/lib/seam/use-seam-client.js.map +1 -1
  200. package/lib/seam/use-seam-query-result.d.ts +2 -2
  201. package/lib/ui/AccessCodeForm/AccessCodeForm.d.ts +5 -7
  202. package/lib/ui/AccessCodeForm/AccessCodeForm.js +9 -14
  203. package/lib/ui/AccessCodeForm/AccessCodeForm.js.map +1 -1
  204. package/lib/ui/AccessCodeForm/AccessCodeFormDatePicker.d.ts +1 -1
  205. package/lib/ui/AccessCodeForm/AccessCodeFormTimeZonePicker.d.ts +1 -1
  206. package/lib/ui/AccessCodeForm/AccessCodeFormTimes.d.ts +1 -1
  207. package/lib/ui/Checkbox.d.ts +1 -1
  208. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.d.ts +2 -2
  209. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.js +1 -1
  210. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.js.map +1 -1
  211. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormClimateSetting.d.ts +1 -1
  212. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormClimateSetting.js +3 -3
  213. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormClimateSetting.js.map +1 -1
  214. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDefaultClimateSetting.d.ts +1 -1
  215. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDefaultClimateSetting.js.map +1 -1
  216. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDeviceSelect.d.ts +1 -1
  217. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormNameAndSchedule.d.ts +1 -1
  218. package/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormTimeZonePicker.d.ts +1 -1
  219. package/lib/ui/ClimateSettingForm/set-point-bounds.d.ts +4 -0
  220. package/lib/ui/ClimateSettingForm/set-point-bounds.js +17 -0
  221. package/lib/ui/ClimateSettingForm/set-point-bounds.js.map +1 -0
  222. package/lib/ui/DateTimePicker/DateTimePicker.d.ts +1 -1
  223. package/lib/ui/FormField.d.ts +1 -1
  224. package/lib/ui/IconButton.d.ts +1 -1
  225. package/lib/ui/LoadingToast/LoadingToast.d.ts +1 -1
  226. package/lib/ui/RadioField/Radio.d.ts +1 -1
  227. package/lib/ui/RadioField/RadioField.d.ts +1 -1
  228. package/lib/ui/Snackbar/Snackbar.d.ts +1 -1
  229. package/lib/ui/Spinner/Spinner.d.ts +1 -1
  230. package/lib/ui/Switch/Switch.d.ts +1 -1
  231. package/lib/ui/TabSet.d.ts +1 -1
  232. package/lib/ui/Table/EmptyPlaceholder.d.ts +1 -1
  233. package/lib/ui/Table/TableCell.d.ts +1 -1
  234. package/lib/ui/Table/TableFilterBar/TableFilterBar.d.ts +1 -1
  235. package/lib/ui/Table/TableFilterBar/TableFilterItem.d.ts +1 -1
  236. package/lib/ui/Table/TableRow.d.ts +1 -1
  237. package/lib/ui/TextButton.d.ts +1 -1
  238. package/lib/ui/TextField/SearchTextField.d.ts +1 -1
  239. package/lib/ui/TimeZonePicker/TimeZonePicker.d.ts +1 -1
  240. package/lib/ui/clipboard.d.ts +1 -1
  241. package/lib/ui/clipboard.js +2 -2
  242. package/lib/ui/clipboard.js.map +1 -1
  243. package/lib/ui/device/BatteryStatusIndicator.d.ts +7 -0
  244. package/lib/ui/device/{BatteryStatus.js → BatteryStatusIndicator.js} +2 -2
  245. package/lib/ui/device/BatteryStatusIndicator.js.map +1 -0
  246. package/lib/ui/device/DeviceImage.d.ts +2 -2
  247. package/lib/ui/device/LockStatus.d.ts +3 -3
  248. package/lib/ui/device/LockStatus.js +1 -1
  249. package/lib/ui/device/LockStatus.js.map +1 -1
  250. package/lib/ui/device/NoiseLevelStatus.d.ts +2 -2
  251. package/lib/ui/device/NoiseLevelStatus.js +4 -4
  252. package/lib/ui/device/NoiseLevelStatus.js.map +1 -1
  253. package/lib/ui/device/OnlineStatus.d.ts +4 -4
  254. package/lib/ui/device/OnlineStatus.js.map +1 -1
  255. package/lib/ui/layout/ContentHeader.d.ts +1 -1
  256. package/lib/ui/layout/DotDivider.d.ts +1 -1
  257. package/lib/ui/noise-sensor/NoiseSensorActivityList.d.ts +2 -2
  258. package/lib/ui/noise-sensor/NoiseSensorActivityList.js +4 -2
  259. package/lib/ui/noise-sensor/NoiseSensorActivityList.js.map +1 -1
  260. package/lib/ui/noise-sensor/NoiseSensorEventItem.d.ts +6 -3
  261. package/lib/ui/noise-sensor/NoiseSensorEventItem.js +4 -7
  262. package/lib/ui/noise-sensor/NoiseSensorEventItem.js.map +1 -1
  263. package/lib/ui/noise-sensor/NoiseThresholdsList.d.ts +2 -2
  264. package/lib/ui/noise-sensor/NoiseThresholdsList.js.map +1 -1
  265. package/lib/ui/thermostat/ClimateModeMenu.d.ts +2 -2
  266. package/lib/ui/thermostat/ClimateModeMenu.js.map +1 -1
  267. package/lib/ui/thermostat/ClimateSettingControlGroup.d.ts +2 -2
  268. package/lib/ui/thermostat/ClimateSettingControlGroup.js.map +1 -1
  269. package/lib/ui/thermostat/ClimateSettingStatus.d.ts +2 -2
  270. package/lib/ui/thermostat/ClimateSettingStatus.js +2 -2
  271. package/lib/ui/thermostat/ClimateSettingStatus.js.map +1 -1
  272. package/lib/ui/thermostat/FanModeMenu.d.ts +2 -2
  273. package/lib/ui/thermostat/FanModeMenu.js.map +1 -1
  274. package/lib/ui/thermostat/Temperature.d.ts +1 -1
  275. package/lib/ui/thermostat/TemperatureControl.d.ts +1 -1
  276. package/lib/ui/thermostat/TemperatureControlGroup.d.ts +2 -2
  277. package/lib/ui/thermostat/TemperatureControlGroup.js +1 -1
  278. package/lib/ui/thermostat/TemperatureControlGroup.js.map +1 -1
  279. package/lib/ui/thermostat/ThermoModeMenuOption.d.ts +1 -1
  280. package/lib/ui/thermostat/ThermostatCard.d.ts +2 -2
  281. package/lib/ui/thermostat/ThermostatCard.js +5 -4
  282. package/lib/ui/thermostat/ThermostatCard.js.map +1 -1
  283. package/lib/ui/thermostat/ThermostatSelect.d.ts +1 -1
  284. package/lib/ui/thermostat/ThermostatSelect.js +2 -2
  285. package/lib/ui/thermostat/ThermostatSelect.js.map +1 -1
  286. package/lib/ui/typography/Title.d.ts +1 -1
  287. package/lib/version.d.ts +1 -1
  288. package/lib/version.js +1 -1
  289. package/lib/version.js.map +1 -1
  290. package/package.json +8 -9
  291. package/src/index.scss +1 -1
  292. package/src/lib/object.ts +13 -0
  293. package/src/lib/seam/SeamProvider.tsx +9 -4
  294. package/src/lib/seam/access-codes/use-access-code.ts +10 -16
  295. package/src/lib/seam/access-codes/use-access-codes.ts +11 -18
  296. package/src/lib/seam/access-codes/use-create-access-code.ts +21 -16
  297. package/src/lib/seam/access-codes/use-delete-access-code.ts +22 -22
  298. package/src/lib/seam/access-codes/use-generate-access-code-code.ts +17 -21
  299. package/src/lib/seam/access-codes/use-update-access-code.ts +33 -25
  300. package/src/lib/seam/client-sessions/use-client-session.ts +5 -10
  301. package/src/lib/seam/components/AccessCodeDetails/AccessCodeDetails.tsx +36 -23
  302. package/src/lib/seam/components/AccessCodeDetails/AccessCodeDevice.tsx +10 -7
  303. package/src/lib/seam/components/AccessCodeTable/AccessCodeHealthBar.tsx +2 -3
  304. package/src/lib/seam/components/AccessCodeTable/AccessCodeMainIcon.tsx +3 -2
  305. package/src/lib/seam/components/AccessCodeTable/AccessCodeMenu.tsx +5 -4
  306. package/src/lib/seam/components/AccessCodeTable/AccessCodeRow.tsx +3 -2
  307. package/src/lib/seam/components/AccessCodeTable/AccessCodeTable.tsx +3 -7
  308. package/src/lib/seam/components/AccessCodeTable/CodeDetails.tsx +12 -8
  309. package/src/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleCard.tsx +4 -4
  310. package/src/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDetails.tsx +3 -3
  311. package/src/lib/seam/components/ClimateSettingScheduleDetails/ClimateSettingScheduleDeviceBar.tsx +6 -4
  312. package/src/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRow.tsx +3 -2
  313. package/src/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleRowDetails.tsx +1 -1
  314. package/src/lib/seam/components/ClimateSettingScheduleTable/ClimateSettingScheduleTable.tsx +3 -6
  315. package/src/lib/seam/components/ConnectAccountButton/ConnectAccountButton.tsx +2 -2
  316. package/src/lib/seam/components/CreateAccessCodeForm/CreateAccessCodeForm.tsx +20 -16
  317. package/src/lib/seam/components/CreateClimateSettingScheduleForm/CreateClimateSettingScheduleForm.tsx +1 -1
  318. package/src/lib/seam/components/DeviceDetails/DeviceDetails.tsx +3 -2
  319. package/src/lib/seam/components/DeviceDetails/DeviceInfo.tsx +5 -3
  320. package/src/lib/seam/components/DeviceDetails/DeviceModel.tsx +2 -2
  321. package/src/lib/seam/components/DeviceDetails/LockDeviceDetails.tsx +6 -6
  322. package/src/lib/seam/components/DeviceDetails/NoiseSensorDeviceDetails.tsx +1 -1
  323. package/src/lib/seam/components/DeviceDetails/ThermostatDeviceDetails.tsx +7 -4
  324. package/src/lib/seam/components/DeviceTable/DeviceHealthBar.tsx +6 -3
  325. package/src/lib/seam/components/DeviceTable/DeviceRow.tsx +5 -7
  326. package/src/lib/seam/components/DeviceTable/DeviceTable.tsx +7 -14
  327. package/src/lib/seam/components/EditAccessCodeForm/EditAccessCodeForm.tsx +6 -7
  328. package/src/lib/seam/components/SupportedDeviceTable/SupportedDeviceContent.tsx +3 -4
  329. package/src/lib/seam/components/SupportedDeviceTable/SupportedDeviceContentRows.tsx +3 -2
  330. package/src/lib/seam/components/SupportedDeviceTable/use-device-model.ts +9 -14
  331. package/src/lib/seam/components/SupportedDeviceTable/use-device-models.ts +5 -9
  332. package/src/lib/seam/components/SupportedDeviceTable/use-manufacturer.ts +7 -12
  333. package/src/lib/seam/components/SupportedDeviceTable/use-manufacturers.ts +4 -8
  334. package/src/lib/seam/components/common-props.tsx +8 -4
  335. package/src/lib/seam/connect-webviews/use-create-connect-webview.ts +15 -17
  336. package/src/lib/seam/connected-accounts/use-connected-account.ts +17 -21
  337. package/src/lib/seam/devices/use-device-providers.ts +8 -11
  338. package/src/lib/seam/devices/use-device.ts +9 -18
  339. package/src/lib/seam/devices/use-devices.ts +20 -26
  340. package/src/lib/seam/events/use-events.ts +12 -14
  341. package/src/lib/seam/filters.ts +9 -8
  342. package/src/lib/seam/locks/lock-device.ts +9 -0
  343. package/src/lib/seam/locks/use-toggle-lock.ts +103 -0
  344. package/src/lib/seam/noise-sensors/noise-sensor-device.ts +10 -0
  345. package/src/lib/seam/noise-sensors/use-noise-thresholds.ts +12 -15
  346. package/src/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedule.ts +10 -23
  347. package/src/lib/seam/thermostats/climate-setting-schedules/use-climate-setting-schedules.ts +13 -13
  348. package/src/lib/seam/thermostats/climate-setting-schedules/use-create-climate-setting-schedule.ts +30 -25
  349. package/src/lib/seam/thermostats/climate-setting-schedules/use-delete-climate-setting-schedule.ts +26 -28
  350. package/src/lib/seam/thermostats/climate-setting-schedules/use-update-climate-setting-schedule.ts +32 -41
  351. package/src/lib/{temperature-bounds.ts → seam/thermostats/temperature-bounds.ts} +8 -5
  352. package/src/lib/seam/thermostats/thermostat-device.ts +43 -0
  353. package/src/lib/seam/thermostats/unit-conversion.ts +89 -0
  354. package/src/lib/seam/thermostats/use-cool-thermostat.ts +77 -47
  355. package/src/lib/seam/thermostats/use-heat-cool-thermostat.ts +89 -40
  356. package/src/lib/seam/thermostats/use-heat-thermostat.ts +77 -47
  357. package/src/lib/seam/thermostats/use-set-thermostat-fan-mode.ts +95 -0
  358. package/src/lib/seam/thermostats/use-set-thermostat-off.ts +64 -40
  359. package/src/lib/seam/thermostats/use-update-thermostat.ts +47 -49
  360. package/src/lib/seam/use-seam-client.ts +11 -22
  361. package/src/lib/seam/use-seam-query-result.ts +2 -2
  362. package/src/lib/ui/AccessCodeForm/AccessCodeForm.tsx +18 -24
  363. package/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleForm.tsx +4 -4
  364. package/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormClimateSetting.tsx +6 -3
  365. package/src/lib/ui/ClimateSettingForm/ClimateSettingScheduleFormDefaultClimateSetting.tsx +1 -1
  366. package/src/lib/ui/ClimateSettingForm/set-point-bounds.ts +31 -0
  367. package/src/lib/ui/clipboard.ts +1 -1
  368. package/src/lib/ui/device/{BatteryStatus.tsx → BatteryStatusIndicator.tsx} +10 -5
  369. package/src/lib/ui/device/DeviceImage.tsx +2 -2
  370. package/src/lib/ui/device/LockStatus.tsx +3 -2
  371. package/src/lib/ui/device/NoiseLevelStatus.tsx +3 -3
  372. package/src/lib/ui/device/OnlineStatus.tsx +3 -3
  373. package/src/lib/ui/noise-sensor/NoiseSensorActivityList.tsx +15 -6
  374. package/src/lib/ui/noise-sensor/NoiseSensorEventItem.tsx +13 -9
  375. package/src/lib/ui/noise-sensor/NoiseThresholdsList.tsx +4 -3
  376. package/src/lib/ui/thermostat/ClimateModeMenu.tsx +1 -2
  377. package/src/lib/ui/thermostat/ClimateSettingControlGroup.tsx +1 -2
  378. package/src/lib/ui/thermostat/ClimateSettingStatus.tsx +2 -3
  379. package/src/lib/ui/thermostat/FanModeMenu.tsx +1 -2
  380. package/src/lib/ui/thermostat/TemperatureControlGroup.tsx +2 -2
  381. package/src/lib/ui/thermostat/ThermostatCard.tsx +11 -8
  382. package/src/lib/ui/thermostat/ThermostatSelect.tsx +4 -10
  383. package/src/lib/version.ts +1 -1
  384. package/lib/seam/devices/use-toggle-lock.d.ts +0 -5
  385. package/lib/seam/devices/use-toggle-lock.js +0 -56
  386. package/lib/seam/devices/use-toggle-lock.js.map +0 -1
  387. package/lib/seam/error-handlers.d.ts +0 -5
  388. package/lib/seam/error-handlers.js +0 -12
  389. package/lib/seam/error-handlers.js.map +0 -1
  390. package/lib/seam/thermostats/use-update-fan-mode.d.ts +0 -6
  391. package/lib/seam/thermostats/use-update-fan-mode.js +0 -42
  392. package/lib/seam/thermostats/use-update-fan-mode.js.map +0 -1
  393. package/lib/set-point-bounds.d.ts +0 -4
  394. package/lib/set-point-bounds.js +0 -24
  395. package/lib/set-point-bounds.js.map +0 -1
  396. package/lib/temperature-bounds.js.map +0 -1
  397. package/lib/ui/device/BatteryStatus.d.ts +0 -7
  398. package/lib/ui/device/BatteryStatus.js.map +0 -1
  399. package/src/lib/seam/devices/use-toggle-lock.ts +0 -84
  400. package/src/lib/seam/error-handlers.ts +0 -19
  401. package/src/lib/seam/thermostats/use-update-fan-mode.ts +0 -81
  402. package/src/lib/set-point-bounds.ts +0 -39
@@ -1,48 +1,53 @@
1
+ import type {
2
+ SeamHttpApiError,
3
+ ThermostatsClimateSettingSchedulesCreateBody,
4
+ } from '@seamapi/http/connect'
5
+ import type { ClimateSettingSchedule } from '@seamapi/types/connect'
1
6
  import {
2
7
  useMutation,
3
8
  type UseMutationResult,
4
9
  useQueryClient,
5
10
  } from '@tanstack/react-query'
6
- import type {
7
- ClimateSettingSchedule,
8
- ClimateSettingScheduleCreateRequest,
9
- ClimateSettingScheduleCreateResponse,
10
- SeamError,
11
- } from 'seamapi'
12
11
 
13
12
  import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
14
13
 
14
+ export type UseCreateClimateSettingScheduleParams = never
15
+
15
16
  export type UseCreateClimateSettingScheduleData = ClimateSettingSchedule
16
- export type UseCreateClimateSettingScheduleMutationParams =
17
- ClimateSettingScheduleCreateRequest
17
+
18
+ export type UseCreateClimateSettingScheduleMutationVariables =
19
+ ThermostatsClimateSettingSchedulesCreateBody
18
20
 
19
21
  export function useCreateClimateSettingSchedule(): UseMutationResult<
20
22
  UseCreateClimateSettingScheduleData,
21
- SeamError,
22
- UseCreateClimateSettingScheduleMutationParams
23
+ SeamHttpApiError,
24
+ UseCreateClimateSettingScheduleMutationVariables
23
25
  > {
24
26
  const { client } = useSeamClient()
25
27
  const queryClient = useQueryClient()
26
28
 
27
29
  return useMutation<
28
- ClimateSettingScheduleCreateResponse['climate_setting_schedule'],
29
- SeamError,
30
- ClimateSettingScheduleCreateRequest
30
+ UseCreateClimateSettingScheduleData,
31
+ SeamHttpApiError,
32
+ UseCreateClimateSettingScheduleMutationVariables
31
33
  >({
32
- mutationFn: async (
33
- mutationParams: UseCreateClimateSettingScheduleMutationParams
34
- ) => {
34
+ mutationFn: async (variables) => {
35
35
  if (client === null) throw new NullSeamClientError()
36
- return await client.thermostats.climateSettingSchedules.create(
37
- mutationParams
38
- )
36
+ return await client.thermostats.climateSettingSchedules.create(variables)
39
37
  },
40
- onSuccess: () => {
41
- void queryClient.invalidateQueries([
42
- 'thermostats',
43
- 'climate_setting_schedules',
44
- 'list',
45
- ])
38
+ onSuccess: (data) => {
39
+ queryClient.setQueryData(
40
+ [
41
+ 'thermostats',
42
+ 'climate_setting_schedules',
43
+ 'get',
44
+ { climate_setting_schedules: data.climate_setting_schedule_id },
45
+ ],
46
+ data
47
+ )
48
+ void queryClient.invalidateQueries({
49
+ queryKey: ['thermostats', 'climate_setting_schedules', 'list'],
50
+ })
46
51
  },
47
52
  })
48
53
  }
@@ -1,53 +1,51 @@
1
+ import type {
2
+ SeamHttpApiError,
3
+ ThermostatsClimateSettingSchedulesDeleteParams,
4
+ } from '@seamapi/http/connect'
1
5
  import {
2
6
  useMutation,
3
7
  type UseMutationResult,
4
8
  useQueryClient,
5
9
  } from '@tanstack/react-query'
6
- import type {
7
- ClimateSettingScheduleDeleteRequest,
8
- ClimateSettingScheduleDeleteResponse,
9
- SeamError,
10
- } from 'seamapi'
11
10
 
12
11
  import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
13
12
 
14
- export type UseDeleteClimateSettingScheduleMutationParams =
15
- ClimateSettingScheduleDeleteRequest
13
+ export type UseDeleteClimateSettingScheduleParams = never
14
+
15
+ export type UseDeleteClimateSettingScheduleData = undefined
16
16
 
17
- export type UseDeleteClimateSettingScheduleData =
18
- ClimateSettingScheduleDeleteResponse
17
+ export type UseDeleteClimateSettingScheduleMutationVariables =
18
+ ThermostatsClimateSettingSchedulesDeleteParams
19
19
 
20
20
  export function useDeleteClimateSettingSchedule(): UseMutationResult<
21
21
  UseDeleteClimateSettingScheduleData,
22
- SeamError,
23
- UseDeleteClimateSettingScheduleMutationParams
22
+ SeamHttpApiError,
23
+ UseDeleteClimateSettingScheduleMutationVariables
24
24
  > {
25
25
  const { client } = useSeamClient()
26
26
  const queryClient = useQueryClient()
27
27
 
28
28
  return useMutation<
29
29
  UseDeleteClimateSettingScheduleData,
30
- SeamError,
31
- ClimateSettingScheduleDeleteRequest
30
+ SeamHttpApiError,
31
+ UseDeleteClimateSettingScheduleMutationVariables
32
32
  >({
33
- mutationFn: async (
34
- mutationParams: UseDeleteClimateSettingScheduleMutationParams
35
- ) => {
33
+ mutationFn: async (variables) => {
36
34
  if (client === null) throw new NullSeamClientError()
37
- await client.thermostats.climateSettingSchedules.delete(mutationParams)
35
+ await client.thermostats.climateSettingSchedules.delete(variables)
38
36
  },
39
37
  onSuccess: (_data, variables) => {
40
- void queryClient.invalidateQueries([
41
- 'thermostats',
42
- 'climate_setting_schedules',
43
- 'get',
44
- { climate_setting_schedule_id: variables.climate_setting_schedule_id },
45
- ])
46
- void queryClient.invalidateQueries([
47
- 'thermostats',
48
- 'climate_setting_schedules',
49
- 'list',
50
- ])
38
+ void queryClient.invalidateQueries({
39
+ queryKey: [
40
+ 'thermostats',
41
+ 'climate_setting_schedules',
42
+ 'get',
43
+ { climate_setting_schedules: variables.climate_setting_schedule_id },
44
+ ],
45
+ })
46
+ void queryClient.invalidateQueries({
47
+ queryKey: ['thermostats', 'climate_setting_schedules', 'list'],
48
+ })
51
49
  },
52
50
  })
53
51
  }
@@ -1,53 +1,48 @@
1
+ import type {
2
+ SeamHttpApiError,
3
+ ThermostatsClimateSettingSchedulesUpdateBody,
4
+ } from '@seamapi/http/connect'
5
+ import type { ClimateSettingSchedule } from '@seamapi/types/connect'
1
6
  import {
2
7
  useMutation,
3
8
  type UseMutationResult,
4
9
  useQueryClient,
5
10
  } from '@tanstack/react-query'
6
- import type {
7
- ClimateSettingSchedule,
8
- ClimateSettingSchedulesListResponse,
9
- ClimateSettingScheduleUpdateRequest,
10
- ClimateSettingScheduleUpdateResponse,
11
- SeamError,
12
- } from 'seamapi'
13
11
 
14
- import { NullSeamClientError, useSeamClient } from 'lib/index.js'
12
+ import { shake } from 'lib/object.js'
13
+ import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
14
+
15
+ export type UseUpdateClimateSettingScheduleParams = never
15
16
 
16
- type UseUpdateClimateSettingScheduleData =
17
- ClimateSettingScheduleUpdateResponse['climate_setting_schedule']
18
- type UseUpdateClimateSettingScheduleMutationParams =
19
- ClimateSettingScheduleUpdateRequest
17
+ export type UseUpdateClimateSettingScheduleData = undefined
18
+
19
+ export type UseUpdateClimateSettingScheduleMutationVariables =
20
+ ThermostatsClimateSettingSchedulesUpdateBody
20
21
 
21
22
  export function useUpdateClimateSettingSchedule(): UseMutationResult<
22
23
  UseUpdateClimateSettingScheduleData,
23
- SeamError,
24
- UseUpdateClimateSettingScheduleMutationParams
24
+ SeamHttpApiError,
25
+ UseUpdateClimateSettingScheduleMutationVariables
25
26
  > {
26
27
  const { client } = useSeamClient()
27
28
  const queryClient = useQueryClient()
28
29
 
29
30
  return useMutation<
30
31
  UseUpdateClimateSettingScheduleData,
31
- SeamError,
32
- UseUpdateClimateSettingScheduleMutationParams
32
+ SeamHttpApiError,
33
+ UseUpdateClimateSettingScheduleMutationVariables
33
34
  >({
34
- mutationFn: async (
35
- mutationPararms: UseUpdateClimateSettingScheduleMutationParams
36
- ) => {
35
+ mutationFn: async (variables) => {
37
36
  if (client === null) throw new NullSeamClientError()
38
- return await client.thermostats.climateSettingSchedules.update(
39
- mutationPararms
40
- )
37
+ await client.thermostats.climateSettingSchedules.update(variables)
41
38
  },
42
- onSuccess: (updated) => {
43
- queryClient.setQueryData<ClimateSettingSchedule>(
39
+ onSuccess: (_data, variables) => {
40
+ queryClient.setQueryData<ClimateSettingSchedule | null>(
44
41
  [
45
42
  'thermostats',
46
43
  'climate_setting_schedules',
47
44
  'get',
48
- {
49
- climate_setting_schedule_id: updated.climate_setting_schedule_id,
50
- },
45
+ { climate_setting_schedules: variables.climate_setting_schedule_id },
51
46
  ],
52
47
  (climateSettingSchedule) => {
53
48
  if (climateSettingSchedule == null) {
@@ -56,30 +51,26 @@ export function useUpdateClimateSettingSchedule(): UseMutationResult<
56
51
 
57
52
  return {
58
53
  ...climateSettingSchedule,
59
- ...updated,
54
+ ...shake(variables),
60
55
  }
61
56
  }
62
57
  )
63
58
 
64
- queryClient.setQueryData<
65
- ClimateSettingSchedulesListResponse['climate_setting_schedules']
66
- >(
67
- [
68
- 'thermostats',
69
- 'climate_setting_schedules',
70
- 'list',
71
- { device_id: updated.device_id },
72
- ],
73
- (climateSettingSchedules): ClimateSettingSchedule[] => {
59
+ queryClient.setQueryData<ClimateSettingSchedule[]>(
60
+ ['thermostats', 'climate_setting_schedules', 'list'],
61
+ (climateSettingSchedules) => {
74
62
  if (climateSettingSchedules == null) {
75
- return []
63
+ return climateSettingSchedules
76
64
  }
77
65
 
78
66
  return climateSettingSchedules.map((climateSettingSchedule) => {
79
- if (climateSettingSchedule.device_id === updated.device_id) {
67
+ if (
68
+ climateSettingSchedule.climate_setting_schedule_id ===
69
+ variables.climate_setting_schedule_id
70
+ ) {
80
71
  return {
81
72
  ...climateSettingSchedule,
82
- ...updated,
73
+ ...shake(variables),
83
74
  }
84
75
  }
85
76
 
@@ -1,4 +1,7 @@
1
- import type { HvacModeSetting, ThermostatDevice } from 'seamapi'
1
+ import type {
2
+ HvacModeSetting,
3
+ ThermostatDevice,
4
+ } from 'lib/seam/thermostats/thermostat-device.js'
2
5
 
3
6
  export interface ControlBounds {
4
7
  mode: Exclude<HvacModeSetting, 'off'>
@@ -60,13 +63,13 @@ export const getSupportedThermostatModes = (
60
63
  return allModes.filter((mode) => {
61
64
  switch (mode) {
62
65
  case 'cool':
63
- return device.properties.is_cooling_available
66
+ return device.properties.is_cooling_available ?? false
64
67
  case 'heat':
65
- return device.properties.is_heating_available
68
+ return device.properties.is_heating_available ?? false
66
69
  case 'heat_cool':
67
70
  return (
68
- device.properties.is_heating_available &&
69
- device.properties.is_cooling_available
71
+ (device.properties.is_heating_available ?? false) &&
72
+ (device.properties.is_cooling_available ?? false)
70
73
  )
71
74
  default:
72
75
  return true
@@ -0,0 +1,43 @@
1
+ import type { Device } from '@seamapi/types/connect'
2
+
3
+ export type ThermostatDevice = Omit<Device, 'properties'> & {
4
+ properties: Device['properties'] &
5
+ Required<
6
+ Pick<
7
+ Device['properties'],
8
+ | 'temperature_celsius'
9
+ | 'temperature_fahrenheit'
10
+ | 'is_heating'
11
+ | 'is_cooling'
12
+ | 'is_fan_running'
13
+ | 'is_cooling_available'
14
+ | 'is_heating_available'
15
+ | 'available_hvac_mode_settings'
16
+ | 'fan_mode_setting'
17
+ | 'current_climate_setting'
18
+ >
19
+ >
20
+ }
21
+
22
+ // UPSTREAM: FanModeSetting missing in @seamapi/types.
23
+ export type FanModeSetting = ThermostatDevice['properties']['fan_mode_setting']
24
+
25
+ // UPSTREAM: HvacModeSetting missing in @seamapi/types.
26
+ export type HvacModeSetting =
27
+ ThermostatDevice['properties']['available_hvac_mode_settings'][number]
28
+
29
+ // UPSTREAM: ClimateSetting missing in @seamapi/types.
30
+ export interface ClimateSetting {
31
+ automatic_heating_enabled?: boolean
32
+ automatic_cooling_enabled?: boolean
33
+ hvac_mode_setting?: HvacModeSetting
34
+ cooling_set_point_celsius?: number
35
+ heating_set_point_celsius?: number
36
+ cooling_set_point_fahrenheit?: number
37
+ heating_set_point_fahrenheit?: number
38
+ manual_override_allowed?: boolean
39
+ }
40
+
41
+ export const isThermostatDevice = (
42
+ device: Device
43
+ ): device is ThermostatDevice => 'is_fan_running' in device.properties
@@ -0,0 +1,89 @@
1
+ import type { Device } from '@seamapi/types/connect'
2
+
3
+ export const celsiusToFahrenheit = (t: number): number => (t * 9) / 5 + 32
4
+
5
+ export const fahrenheitToCelsius = (t: number): number => (t - 32) * (5 / 9)
6
+
7
+ export const getCoolingSetPointCelsius = (
8
+ variables: {
9
+ cooling_set_point_celsius?: number
10
+ cooling_set_point_fahrenheit?: number
11
+ },
12
+ device: Device
13
+ ): number | undefined => {
14
+ if (variables.cooling_set_point_celsius != null) {
15
+ return variables.cooling_set_point_celsius
16
+ }
17
+
18
+ if (variables.cooling_set_point_fahrenheit != null) {
19
+ return fahrenheitToCelsius(variables.cooling_set_point_fahrenheit)
20
+ }
21
+
22
+ return (
23
+ device.properties.current_climate_setting?.cooling_set_point_celsius ??
24
+ undefined
25
+ )
26
+ }
27
+
28
+ export const getCoolingSetPointFahrenheit = (
29
+ variables: {
30
+ cooling_set_point_celsius?: number
31
+ cooling_set_point_fahrenheit?: number
32
+ },
33
+ device: Device
34
+ ): number | undefined => {
35
+ if (variables.cooling_set_point_fahrenheit != null) {
36
+ return variables.cooling_set_point_fahrenheit
37
+ }
38
+
39
+ if (variables.cooling_set_point_celsius != null) {
40
+ return celsiusToFahrenheit(variables.cooling_set_point_celsius)
41
+ }
42
+
43
+ return (
44
+ device.properties.current_climate_setting?.cooling_set_point_fahrenheit ??
45
+ undefined
46
+ )
47
+ }
48
+
49
+ export const getHeatingSetPointCelsius = (
50
+ variables: {
51
+ heating_set_point_celsius?: number
52
+ heating_set_point_fahrenheit?: number
53
+ },
54
+ device: Device
55
+ ): number | undefined => {
56
+ if (variables.heating_set_point_celsius != null) {
57
+ return variables.heating_set_point_celsius
58
+ }
59
+
60
+ if (variables.heating_set_point_fahrenheit != null) {
61
+ return fahrenheitToCelsius(variables.heating_set_point_fahrenheit)
62
+ }
63
+
64
+ return (
65
+ device.properties.current_climate_setting?.heating_set_point_celsius ??
66
+ undefined
67
+ )
68
+ }
69
+
70
+ export const getHeatingSetPointFahrenheit = (
71
+ variables: {
72
+ heating_set_point_celsius?: number
73
+ heating_set_point_fahrenheit?: number
74
+ },
75
+ device: Device
76
+ ): number | undefined => {
77
+ if (variables.heating_set_point_fahrenheit != null) {
78
+ return variables.heating_set_point_fahrenheit
79
+ }
80
+
81
+ if (variables.heating_set_point_celsius != null) {
82
+ return celsiusToFahrenheit(variables.heating_set_point_celsius)
83
+ }
84
+
85
+ return (
86
+ device.properties.current_climate_setting?.heating_set_point_fahrenheit ??
87
+ undefined
88
+ )
89
+ }
@@ -1,64 +1,82 @@
1
+ import type {
2
+ SeamActionAttemptFailedError,
3
+ SeamActionAttemptTimeoutError,
4
+ SeamHttpApiError,
5
+ ThermostatsCoolBody,
6
+ } from '@seamapi/http/connect'
7
+ import type { ActionAttempt, Device } from '@seamapi/types/connect'
1
8
  import {
2
9
  useMutation,
3
10
  type UseMutationResult,
4
11
  useQueryClient,
5
12
  } from '@tanstack/react-query'
6
- import type {
7
- SeamError,
8
- ThermostatCoolRequest,
9
- ThermostatDevice,
10
- ThermostatsListResponse,
11
- } from 'seamapi'
12
13
 
14
+ import {
15
+ getCoolingSetPointCelsius,
16
+ getCoolingSetPointFahrenheit,
17
+ } from 'lib/seam/thermostats/unit-conversion.js'
13
18
  import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
14
19
 
15
- // UPSTREAM: Missing ThermostatCoolResponse in seamapi.
16
- type UseCoolThermostatData = Record<string, unknown>
17
- type UseCoolThermostatMutationParams = ThermostatCoolRequest
20
+ export type UseCoolThermostatParams = never
21
+
22
+ export type UseCoolThermostatData = undefined
23
+
24
+ export type UseCoolThermostatMutationVariables = Pick<
25
+ ThermostatsCoolBody,
26
+ 'device_id' | 'cooling_set_point_celsius' | 'cooling_set_point_fahrenheit'
27
+ >
28
+
29
+ type CoolThermostatActionAttempt = Extract<
30
+ ActionAttempt,
31
+ { action_type: 'SET_COOL' }
32
+ >
33
+
34
+ type MutationError =
35
+ | SeamHttpApiError
36
+ | SeamActionAttemptFailedError<CoolThermostatActionAttempt>
37
+ | SeamActionAttemptTimeoutError<CoolThermostatActionAttempt>
18
38
 
19
39
  export function useCoolThermostat(): UseMutationResult<
20
40
  UseCoolThermostatData,
21
- SeamError,
22
- UseCoolThermostatMutationParams
41
+ MutationError,
42
+ UseCoolThermostatMutationVariables
23
43
  > {
24
44
  const { client } = useSeamClient()
25
45
  const queryClient = useQueryClient()
26
46
 
27
47
  return useMutation<
28
48
  UseCoolThermostatData,
29
- SeamError,
30
- UseCoolThermostatMutationParams
49
+ MutationError,
50
+ UseCoolThermostatMutationVariables
31
51
  >({
32
- mutationFn: async (mutationParams: UseCoolThermostatMutationParams) => {
52
+ mutationFn: async (variables) => {
33
53
  if (client === null) throw new NullSeamClientError()
34
-
35
- return await client.thermostats.cool(mutationParams)
54
+ await client.thermostats.cool(variables)
36
55
  },
37
56
  onSuccess: (_data, variables) => {
38
- queryClient.setQueryData<ThermostatDevice | null>(
57
+ queryClient.setQueryData<Device | null>(
39
58
  ['devices', 'get', { device_id: variables.device_id }],
40
- (thermostat) => {
41
- if (thermostat == null) {
59
+ (device) => {
60
+ if (device == null) {
42
61
  return
43
62
  }
44
-
45
- return getUpdatedThermostat(thermostat, variables)
63
+ return getUpdatedDevice(device, variables)
46
64
  }
47
65
  )
48
66
 
49
- queryClient.setQueryData<ThermostatsListResponse['thermostats']>(
67
+ queryClient.setQueryData<Device[]>(
50
68
  ['devices', 'list', { device_id: variables.device_id }],
51
- (thermostats): ThermostatDevice[] => {
52
- if (thermostats == null) {
69
+ (devices): Device[] => {
70
+ if (devices == null) {
53
71
  return []
54
72
  }
55
73
 
56
- return thermostats.map((thermostat) => {
57
- if (thermostat.device_id === variables.device_id) {
58
- return getUpdatedThermostat(thermostat, variables)
74
+ return devices.map((device) => {
75
+ if (device.device_id === variables.device_id) {
76
+ return getUpdatedDevice(device, variables)
59
77
  }
60
78
 
61
- return thermostat
79
+ return device
62
80
  })
63
81
  }
64
82
  )
@@ -66,25 +84,37 @@ export function useCoolThermostat(): UseMutationResult<
66
84
  })
67
85
  }
68
86
 
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
+ const getUpdatedDevice = (
88
+ device: Device,
89
+ variables: UseCoolThermostatMutationVariables
90
+ ): Device => {
91
+ const { properties } = device
92
+ if (
93
+ 'current_climate_setting' in properties &&
94
+ properties.current_climate_setting != null
95
+ ) {
96
+ return {
97
+ ...device,
98
+ properties: {
99
+ ...properties,
100
+ current_climate_setting: {
101
+ ...properties.current_climate_setting,
102
+ hvac_mode_setting: 'cool',
103
+ automatic_heating_enabled: false,
104
+ automatic_cooling_enabled: true,
105
+ heating_set_point_celsius: undefined,
106
+ heating_set_point_fahrenheit: undefined,
107
+ cooling_set_point_celsius: getCoolingSetPointCelsius(
108
+ variables,
109
+ device
110
+ ),
111
+ cooling_set_point_fahrenheit: getCoolingSetPointFahrenheit(
112
+ variables,
113
+ device
114
+ ),
115
+ },
87
116
  },
88
- },
117
+ }
89
118
  }
119
+ return device
90
120
  }