@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,64 +1,88 @@
1
+ import type {
2
+ SeamActionAttemptFailedError,
3
+ SeamActionAttemptTimeoutError,
4
+ SeamHttpApiError,
5
+ ThermostatsHeatCoolBody,
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
- ThermostatDevice,
9
- ThermostatHeatCoolRequest,
10
- ThermostatsListResponse,
11
- } from 'seamapi'
12
13
 
14
+ import {
15
+ getCoolingSetPointCelsius,
16
+ getCoolingSetPointFahrenheit,
17
+ getHeatingSetPointCelsius,
18
+ getHeatingSetPointFahrenheit,
19
+ } from 'lib/seam/thermostats/unit-conversion.js'
13
20
  import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
14
21
 
15
- // UPSTREAM: Missing ThermostatHeatCoolResponse in seamapi.
16
- type UseHeatCoolThermostatData = Record<string, unknown>
17
- type UseHeatCoolThermostatMutationParams = ThermostatHeatCoolRequest
22
+ export type UseHeatCoolThermostatParams = never
23
+
24
+ export type UseHeatCoolThermostatData = undefined
25
+
26
+ export type UseHeatCoolThermostatMutationVariables = Pick<
27
+ ThermostatsHeatCoolBody,
28
+ | 'device_id'
29
+ | 'heating_set_point_celsius'
30
+ | 'heating_set_point_fahrenheit'
31
+ | 'cooling_set_point_celsius'
32
+ | 'cooling_set_point_fahrenheit'
33
+ >
34
+
35
+ type HeatCoolThermostatActionAttempt = Extract<
36
+ ActionAttempt,
37
+ { action_type: 'SET_HEAT_COOL' }
38
+ >
39
+
40
+ type MutationError =
41
+ | SeamHttpApiError
42
+ | SeamActionAttemptFailedError<HeatCoolThermostatActionAttempt>
43
+ | SeamActionAttemptTimeoutError<HeatCoolThermostatActionAttempt>
18
44
 
19
45
  export function useHeatCoolThermostat(): UseMutationResult<
20
46
  UseHeatCoolThermostatData,
21
- SeamError,
22
- UseHeatCoolThermostatMutationParams
47
+ MutationError,
48
+ UseHeatCoolThermostatMutationVariables
23
49
  > {
24
50
  const { client } = useSeamClient()
25
51
  const queryClient = useQueryClient()
26
52
 
27
53
  return useMutation<
28
54
  UseHeatCoolThermostatData,
29
- SeamError,
30
- UseHeatCoolThermostatMutationParams
55
+ MutationError,
56
+ UseHeatCoolThermostatMutationVariables
31
57
  >({
32
- mutationFn: async (mutationParams: UseHeatCoolThermostatMutationParams) => {
58
+ mutationFn: async (variables) => {
33
59
  if (client === null) throw new NullSeamClientError()
34
-
35
- return await client.thermostats.heatCool(mutationParams)
60
+ await client.thermostats.heatCool(variables)
36
61
  },
37
62
  onSuccess: (_data, variables) => {
38
- queryClient.setQueryData<ThermostatDevice | null>(
63
+ queryClient.setQueryData<Device | null>(
39
64
  ['devices', 'get', { device_id: variables.device_id }],
40
- (thermostat) => {
41
- if (thermostat == null) {
65
+ (device) => {
66
+ if (device == null) {
42
67
  return
43
68
  }
44
-
45
- return getUpdatedThermostat(thermostat, variables)
69
+ return getUpdatedDevice(device, variables)
46
70
  }
47
71
  )
48
72
 
49
- queryClient.setQueryData<ThermostatsListResponse['thermostats']>(
73
+ queryClient.setQueryData<Device[]>(
50
74
  ['devices', 'list', { device_id: variables.device_id }],
51
- (thermostats): ThermostatDevice[] => {
52
- if (thermostats == null) {
75
+ (devices): Device[] => {
76
+ if (devices == null) {
53
77
  return []
54
78
  }
55
79
 
56
- return thermostats.map((thermostat) => {
57
- if (thermostat.device_id === variables.device_id) {
58
- return getUpdatedThermostat(thermostat, variables)
80
+ return devices.map((device) => {
81
+ if (device.device_id === variables.device_id) {
82
+ return getUpdatedDevice(device, variables)
59
83
  }
60
84
 
61
- return thermostat
85
+ return device
62
86
  })
63
87
  }
64
88
  )
@@ -66,18 +90,43 @@ export function useHeatCoolThermostat(): UseMutationResult<
66
90
  })
67
91
  }
68
92
 
69
- function getUpdatedThermostat(
70
- thermostat: ThermostatDevice,
71
- variables: UseHeatCoolThermostatMutationParams
72
- ): ThermostatDevice {
73
- return {
74
- ...thermostat,
75
- properties: {
76
- ...thermostat.properties,
77
- current_climate_setting: {
78
- ...thermostat.properties.current_climate_setting,
79
- ...variables,
93
+ const getUpdatedDevice = (
94
+ device: Device,
95
+ variables: UseHeatCoolThermostatMutationVariables
96
+ ): Device => {
97
+ const { properties } = device
98
+ if (
99
+ 'current_climate_setting' in properties &&
100
+ properties.current_climate_setting != null
101
+ ) {
102
+ return {
103
+ ...device,
104
+ properties: {
105
+ ...properties,
106
+ current_climate_setting: {
107
+ ...properties.current_climate_setting,
108
+ hvac_mode_setting: 'heat_cool',
109
+ automatic_heating_enabled: true,
110
+ automatic_cooling_enabled: true,
111
+ heating_set_point_celsius: getHeatingSetPointCelsius(
112
+ variables,
113
+ device
114
+ ),
115
+ heating_set_point_fahrenheit: getHeatingSetPointFahrenheit(
116
+ variables,
117
+ device
118
+ ),
119
+ cooling_set_point_celsius: getCoolingSetPointCelsius(
120
+ variables,
121
+ device
122
+ ),
123
+ cooling_set_point_fahrenheit: getCoolingSetPointFahrenheit(
124
+ variables,
125
+ device
126
+ ),
127
+ },
80
128
  },
81
- },
129
+ }
82
130
  }
131
+ return device
83
132
  }
@@ -1,64 +1,82 @@
1
+ import type {
2
+ SeamActionAttemptFailedError,
3
+ SeamActionAttemptTimeoutError,
4
+ SeamHttpApiError,
5
+ ThermostatsHeatBody,
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
- ThermostatDevice,
9
- ThermostatHeatRequest,
10
- ThermostatsListResponse,
11
- } from 'seamapi'
12
13
 
14
+ import {
15
+ getHeatingSetPointCelsius,
16
+ getHeatingSetPointFahrenheit,
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 ThermostatHeatResponse in seamapi.
16
- type UseHeatThermostatData = Record<string, unknown>
17
- type UseHeatThermostatMutationParams = ThermostatHeatRequest
20
+ export type UseHeatThermostatParams = never
21
+
22
+ export type UseHeatThermostatData = undefined
23
+
24
+ export type UseHeatThermostatMutationVariables = Pick<
25
+ ThermostatsHeatBody,
26
+ 'device_id' | 'heating_set_point_celsius' | 'heating_set_point_fahrenheit'
27
+ >
28
+
29
+ type HeatThermostatActionAttempt = Extract<
30
+ ActionAttempt,
31
+ { action_type: 'SET_HEAT' }
32
+ >
33
+
34
+ type MutationError =
35
+ | SeamHttpApiError
36
+ | SeamActionAttemptFailedError<HeatThermostatActionAttempt>
37
+ | SeamActionAttemptTimeoutError<HeatThermostatActionAttempt>
18
38
 
19
39
  export function useHeatThermostat(): UseMutationResult<
20
40
  UseHeatThermostatData,
21
- SeamError,
22
- UseHeatThermostatMutationParams
41
+ MutationError,
42
+ UseHeatThermostatMutationVariables
23
43
  > {
24
44
  const { client } = useSeamClient()
25
45
  const queryClient = useQueryClient()
26
46
 
27
47
  return useMutation<
28
48
  UseHeatThermostatData,
29
- SeamError,
30
- UseHeatThermostatMutationParams
49
+ MutationError,
50
+ UseHeatThermostatMutationVariables
31
51
  >({
32
- mutationFn: async (mutationParams: UseHeatThermostatMutationParams) => {
52
+ mutationFn: async (variables) => {
33
53
  if (client === null) throw new NullSeamClientError()
34
-
35
- return await client.thermostats.heat(mutationParams)
54
+ await client.thermostats.heat(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 useHeatThermostat(): UseMutationResult<
66
84
  })
67
85
  }
68
86
 
69
- function getUpdatedThermostat(
70
- thermostat: ThermostatDevice,
71
- variables: UseHeatThermostatMutationParams
72
- ): ThermostatDevice {
73
- return {
74
- ...thermostat,
75
- properties: {
76
- ...thermostat.properties,
77
- current_climate_setting: {
78
- ...thermostat.properties.current_climate_setting,
79
- heating_set_point_fahrenheit:
80
- variables.heating_set_point_fahrenheit ??
81
- thermostat.properties.current_climate_setting
82
- .heating_set_point_fahrenheit,
83
- heating_set_point_celsius:
84
- variables.heating_set_point_celsius ??
85
- thermostat.properties.current_climate_setting
86
- .heating_set_point_celsius,
87
+ const getUpdatedDevice = (
88
+ device: Device,
89
+ variables: UseHeatThermostatMutationVariables
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: 'heat',
103
+ automatic_heating_enabled: true,
104
+ automatic_cooling_enabled: false,
105
+ cooling_set_point_celsius: undefined,
106
+ cooling_set_point_fahrenheit: undefined,
107
+ heating_set_point_celsius: getHeatingSetPointCelsius(
108
+ variables,
109
+ device
110
+ ),
111
+ heating_set_point_fahrenheit: getHeatingSetPointFahrenheit(
112
+ variables,
113
+ device
114
+ ),
115
+ },
87
116
  },
88
- },
117
+ }
89
118
  }
119
+ return device
90
120
  }
@@ -0,0 +1,95 @@
1
+ import type {
2
+ SeamActionAttemptFailedError,
3
+ SeamActionAttemptTimeoutError,
4
+ SeamHttpApiError,
5
+ ThermostatsSetFanModeBody,
6
+ } from '@seamapi/http/connect'
7
+ import type { ActionAttempt, Device } from '@seamapi/types/connect'
8
+ import {
9
+ useMutation,
10
+ type UseMutationResult,
11
+ useQueryClient,
12
+ } from '@tanstack/react-query'
13
+
14
+ import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
15
+
16
+ export type UseSetThermostatFanModeParams = never
17
+
18
+ export type UseSetThermostatFanModeData = undefined
19
+
20
+ export type UseSetThermostatFanModeMutationVariables = ThermostatsSetFanModeBody
21
+
22
+ type SetThermostatFanModeActionAttempt = Extract<
23
+ ActionAttempt,
24
+ { action_type: 'SET_FAN_MODE' }
25
+ >
26
+
27
+ type MutationError =
28
+ | SeamHttpApiError
29
+ | SeamActionAttemptFailedError<SetThermostatFanModeActionAttempt>
30
+ | SeamActionAttemptTimeoutError<SetThermostatFanModeActionAttempt>
31
+
32
+ export function useSetThermostatFanMode(): UseMutationResult<
33
+ UseSetThermostatFanModeData,
34
+ MutationError,
35
+ UseSetThermostatFanModeMutationVariables
36
+ > {
37
+ const { client } = useSeamClient()
38
+ const queryClient = useQueryClient()
39
+
40
+ return useMutation<
41
+ UseSetThermostatFanModeData,
42
+ MutationError,
43
+ UseSetThermostatFanModeMutationVariables
44
+ >({
45
+ mutationFn: async (variables) => {
46
+ if (client === null) throw new NullSeamClientError()
47
+ await client.thermostats.setFanMode(variables)
48
+ },
49
+ onSuccess: (_data, variables) => {
50
+ queryClient.setQueryData<Device | null>(
51
+ ['devices', 'get', { device_id: variables.device_id }],
52
+ (device) => {
53
+ if (device == null) {
54
+ return
55
+ }
56
+ return getUpdatedDevice(device, variables)
57
+ }
58
+ )
59
+
60
+ queryClient.setQueryData<Device[]>(
61
+ ['devices', 'list', { device_id: variables.device_id }],
62
+ (devices): Device[] => {
63
+ if (devices == null) {
64
+ return []
65
+ }
66
+
67
+ return devices.map((device) => {
68
+ if (device.device_id === variables.device_id) {
69
+ return getUpdatedDevice(device, variables)
70
+ }
71
+
72
+ return device
73
+ })
74
+ }
75
+ )
76
+ },
77
+ })
78
+ }
79
+
80
+ const getUpdatedDevice = (
81
+ device: Device,
82
+ variables: UseSetThermostatFanModeMutationVariables
83
+ ): Device => {
84
+ const { properties } = device
85
+ if ('fan_mode_setting' in properties && properties.fan_mode_setting != null) {
86
+ return {
87
+ ...device,
88
+ properties: {
89
+ ...properties,
90
+ fan_mode_setting: variables.fan_mode_setting,
91
+ },
92
+ }
93
+ }
94
+ return device
95
+ }
@@ -1,64 +1,75 @@
1
+ import type {
2
+ SeamActionAttemptFailedError,
3
+ SeamActionAttemptTimeoutError,
4
+ SeamHttpApiError,
5
+ ThermostatsOffBody,
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
- ThermostatDevice,
9
- ThermostatOffRequest,
10
- ThermostatsListResponse,
11
- } from 'seamapi'
12
13
 
13
14
  import { NullSeamClientError, useSeamClient } from 'lib/seam/use-seam-client.js'
14
15
 
15
- // UPSTREAM: Missing ThermostatOffResponse in seamapi.
16
- type UseSetThermostatOffData = Record<string, unknown>
17
- type UseSetThermostatOffMutationParams = ThermostatOffRequest
16
+ export type UseSetThermostatOffParams = never
17
+
18
+ export type UseSetThermostatOffData = undefined
19
+
20
+ export type UseSetThermostatOffMutationVariables = ThermostatsOffBody
21
+
22
+ type SetThermostatOffActionAttempt = Extract<
23
+ ActionAttempt,
24
+ { action_type: 'SET_THERMOSTAT_OFF' }
25
+ >
26
+
27
+ type MutationError =
28
+ | SeamHttpApiError
29
+ | SeamActionAttemptFailedError<SetThermostatOffActionAttempt>
30
+ | SeamActionAttemptTimeoutError<SetThermostatOffActionAttempt>
18
31
 
19
32
  export function useSetThermostatOff(): UseMutationResult<
20
33
  UseSetThermostatOffData,
21
- SeamError,
22
- UseSetThermostatOffMutationParams
34
+ MutationError,
35
+ UseSetThermostatOffMutationVariables
23
36
  > {
24
37
  const { client } = useSeamClient()
25
38
  const queryClient = useQueryClient()
26
39
 
27
40
  return useMutation<
28
41
  UseSetThermostatOffData,
29
- SeamError,
30
- UseSetThermostatOffMutationParams
42
+ MutationError,
43
+ UseSetThermostatOffMutationVariables
31
44
  >({
32
- mutationFn: async (mutationParams: UseSetThermostatOffMutationParams) => {
45
+ mutationFn: async (variables) => {
33
46
  if (client === null) throw new NullSeamClientError()
34
-
35
- return await client.thermostats.off(mutationParams)
47
+ await client.thermostats.off(variables)
36
48
  },
37
49
  onSuccess: (_data, variables) => {
38
- queryClient.setQueryData<ThermostatDevice | null>(
50
+ queryClient.setQueryData<Device | null>(
39
51
  ['devices', 'get', { device_id: variables.device_id }],
40
- (thermostat) => {
41
- if (thermostat == null) {
52
+ (device) => {
53
+ if (device == null) {
42
54
  return
43
55
  }
44
-
45
- return getUpdatedThermostat(thermostat)
56
+ return getUpdatedDevice(device)
46
57
  }
47
58
  )
48
59
 
49
- queryClient.setQueryData<ThermostatsListResponse['thermostats']>(
60
+ queryClient.setQueryData<Device[]>(
50
61
  ['devices', 'list', { device_id: variables.device_id }],
51
- (thermostats): ThermostatDevice[] => {
52
- if (thermostats == null) {
62
+ (devices): Device[] => {
63
+ if (devices == null) {
53
64
  return []
54
65
  }
55
66
 
56
- return thermostats.map((thermostat) => {
57
- if (thermostat.device_id === variables.device_id) {
58
- return getUpdatedThermostat(thermostat)
67
+ return devices.map((device) => {
68
+ if (device.device_id === variables.device_id) {
69
+ return getUpdatedDevice(device)
59
70
  }
60
71
 
61
- return thermostat
72
+ return device
62
73
  })
63
74
  }
64
75
  )
@@ -66,18 +77,31 @@ export function useSetThermostatOff(): UseMutationResult<
66
77
  })
67
78
  }
68
79
 
69
- function getUpdatedThermostat(thermostat: ThermostatDevice): ThermostatDevice {
70
- return {
71
- ...thermostat,
72
- properties: {
73
- ...thermostat.properties,
74
- is_fan_running: false,
75
- current_climate_setting: {
76
- ...thermostat.properties.current_climate_setting,
77
- automatic_cooling_enabled: false,
78
- automatic_heating_enabled: false,
79
- hvac_mode_setting: 'off',
80
+ const getUpdatedDevice = (device: Device): Device => {
81
+ const { properties } = device
82
+ if (
83
+ 'current_climate_setting' in properties &&
84
+ properties.current_climate_setting != null
85
+ ) {
86
+ return {
87
+ ...device,
88
+ properties: {
89
+ ...properties,
90
+ is_fan_running: false,
91
+ is_cooling: false,
92
+ is_heating: false,
93
+ current_climate_setting: {
94
+ ...properties.current_climate_setting,
95
+ automatic_cooling_enabled: false,
96
+ automatic_heating_enabled: false,
97
+ hvac_mode_setting: 'off',
98
+ heating_set_point_celsius: undefined,
99
+ heating_set_point_fahrenheit: undefined,
100
+ cooling_set_point_celsius: undefined,
101
+ cooling_set_point_fahrenheit: undefined,
102
+ },
80
103
  },
81
- },
104
+ }
82
105
  }
106
+ return device
83
107
  }