@matter/node 0.16.0-alpha.0-20250816-d22ad240d → 0.16.0-alpha.0-20250819-0a388db8b

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 (290) hide show
  1. package/dist/cjs/behavior/Behavior.d.ts +1 -1
  2. package/dist/cjs/behavior/Behavior.d.ts.map +1 -1
  3. package/dist/cjs/behavior/Events.js +1 -1
  4. package/dist/cjs/behavior/Events.js.map +1 -1
  5. package/dist/cjs/behavior/Transitions.d.ts +8 -8
  6. package/dist/cjs/behavior/Transitions.d.ts.map +1 -1
  7. package/dist/cjs/behavior/Transitions.js +8 -8
  8. package/dist/cjs/behavior/Transitions.js.map +1 -1
  9. package/dist/cjs/behavior/cluster/FabricScopedDataHandler.js +1 -1
  10. package/dist/cjs/behavior/cluster/FabricScopedDataHandler.js.map +1 -1
  11. package/dist/cjs/behavior/internal/BehaviorBacking.d.ts.map +1 -1
  12. package/dist/cjs/behavior/internal/BehaviorBacking.js +7 -2
  13. package/dist/cjs/behavior/internal/BehaviorBacking.js.map +1 -1
  14. package/dist/cjs/behavior/internal/Reactors.js +2 -2
  15. package/dist/cjs/behavior/internal/Reactors.js.map +1 -1
  16. package/dist/cjs/behavior/state/managed/values/PrimitiveManager.d.ts +3 -4
  17. package/dist/cjs/behavior/state/managed/values/PrimitiveManager.d.ts.map +1 -1
  18. package/dist/cjs/behavior/state/managed/values/PrimitiveManager.js.map +1 -1
  19. package/dist/cjs/behavior/state/managed/values/ValuePatcher.js.map +1 -1
  20. package/dist/cjs/behavior/state/migrations/Migration.d.ts +20 -0
  21. package/dist/cjs/behavior/state/migrations/Migration.d.ts.map +1 -0
  22. package/dist/cjs/behavior/state/migrations/Migration.js +43 -0
  23. package/dist/cjs/behavior/state/migrations/Migration.js.map +6 -0
  24. package/dist/cjs/behavior/{system/subscription → state/migrations}/index.d.ts +1 -1
  25. package/dist/cjs/behavior/state/migrations/index.d.ts.map +1 -0
  26. package/dist/{esm/behavior/system/subscription → cjs/behavior/state/migrations}/index.js +1 -1
  27. package/dist/cjs/behavior/state/migrations/index.js.map +6 -0
  28. package/dist/cjs/behavior/state/validation/ValueValidator.d.ts.map +1 -1
  29. package/dist/cjs/behavior/state/validation/ValueValidator.js +1 -0
  30. package/dist/cjs/behavior/state/validation/ValueValidator.js.map +1 -1
  31. package/dist/cjs/behavior/state/validation/assertions.d.ts +3 -2
  32. package/dist/cjs/behavior/state/validation/assertions.d.ts.map +1 -1
  33. package/dist/cjs/behavior/state/validation/assertions.js.map +1 -1
  34. package/dist/cjs/behavior/supervision/RootSupervisor.js +2 -2
  35. package/dist/cjs/behavior/supervision/RootSupervisor.js.map +1 -1
  36. package/dist/cjs/behavior/supervision/ValueSupervisor.d.ts +1 -1
  37. package/dist/cjs/behavior/supervision/ValueSupervisor.d.ts.map +1 -1
  38. package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts +7 -7
  39. package/dist/cjs/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
  40. package/dist/cjs/behavior/system/commissioning/CommissioningClient.js +6 -6
  41. package/dist/cjs/behavior/system/commissioning/CommissioningClient.js.map +1 -1
  42. package/dist/cjs/behavior/system/commissioning/CommissioningServer.d.ts +2 -2
  43. package/dist/cjs/behavior/system/commissioning/CommissioningServer.d.ts.map +1 -1
  44. package/dist/cjs/behavior/system/commissioning/CommissioningServer.js.map +1 -1
  45. package/dist/cjs/behavior/system/commissioning/RemoteDescriptor.d.ts.map +1 -1
  46. package/dist/cjs/behavior/system/commissioning/RemoteDescriptor.js +15 -14
  47. package/dist/cjs/behavior/system/commissioning/RemoteDescriptor.js.map +1 -1
  48. package/dist/cjs/behavior/system/controller/discovery/ContinuousDiscovery.js +1 -1
  49. package/dist/cjs/behavior/system/controller/discovery/ContinuousDiscovery.js.map +1 -1
  50. package/dist/cjs/behavior/system/controller/discovery/Discovery.d.ts +2 -2
  51. package/dist/cjs/behavior/system/controller/discovery/Discovery.d.ts.map +1 -1
  52. package/dist/cjs/behavior/system/controller/discovery/Discovery.js +2 -2
  53. package/dist/cjs/behavior/system/controller/discovery/Discovery.js.map +1 -1
  54. package/dist/cjs/behavior/system/network/NetworkClient.d.ts.map +1 -1
  55. package/dist/cjs/behavior/system/network/NetworkClient.js +2 -2
  56. package/dist/cjs/behavior/system/network/NetworkClient.js.map +1 -1
  57. package/dist/cjs/behavior/system/network/ServerNetworkRuntime.js +2 -2
  58. package/dist/cjs/behavior/system/network/ServerNetworkRuntime.js.map +1 -1
  59. package/dist/cjs/behavior/system/{subscription/SubscriptionBehavior.d.ts → subscriptions/SubscriptionsServer.d.ts} +6 -6
  60. package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.d.ts.map +1 -0
  61. package/dist/cjs/behavior/system/{subscription/SubscriptionBehavior.js → subscriptions/SubscriptionsServer.js} +22 -22
  62. package/dist/cjs/behavior/system/subscriptions/SubscriptionsServer.js.map +6 -0
  63. package/dist/{esm/behavior/system/subscription → cjs/behavior/system/subscriptions}/index.d.ts +1 -1
  64. package/dist/cjs/behavior/system/subscriptions/index.d.ts.map +1 -0
  65. package/dist/cjs/behavior/system/{subscription → subscriptions}/index.js +3 -3
  66. package/dist/cjs/behavior/system/subscriptions/index.js.map +6 -0
  67. package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts +3 -3
  68. package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts.map +1 -1
  69. package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +13 -11
  70. package/dist/cjs/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
  71. package/dist/cjs/behaviors/color-control/ColorControlServer.d.ts +2 -2
  72. package/dist/cjs/behaviors/color-control/ColorControlServer.d.ts.map +1 -1
  73. package/dist/cjs/behaviors/color-control/ColorControlServer.js +4 -4
  74. package/dist/cjs/behaviors/color-control/ColorControlServer.js.map +1 -1
  75. package/dist/cjs/behaviors/general-commissioning/GeneralCommissioningServer.d.ts.map +1 -1
  76. package/dist/cjs/behaviors/general-commissioning/GeneralCommissioningServer.js +3 -3
  77. package/dist/cjs/behaviors/general-commissioning/GeneralCommissioningServer.js.map +1 -1
  78. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts +4 -4
  79. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
  80. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +17 -16
  81. package/dist/cjs/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
  82. package/dist/cjs/behaviors/identify/IdentifyServer.d.ts.map +1 -1
  83. package/dist/cjs/behaviors/identify/IdentifyServer.js +1 -1
  84. package/dist/cjs/behaviors/identify/IdentifyServer.js.map +1 -1
  85. package/dist/cjs/behaviors/level-control/LevelControlServer.d.ts +1 -1
  86. package/dist/cjs/behaviors/level-control/LevelControlServer.d.ts.map +1 -1
  87. package/dist/cjs/behaviors/level-control/LevelControlServer.js +3 -3
  88. package/dist/cjs/behaviors/level-control/LevelControlServer.js.map +1 -1
  89. package/dist/cjs/behaviors/on-off/OnOffServer.d.ts.map +1 -1
  90. package/dist/cjs/behaviors/on-off/OnOffServer.js +2 -2
  91. package/dist/cjs/behaviors/on-off/OnOffServer.js.map +1 -1
  92. package/dist/cjs/behaviors/power-source/PowerSourceServer.d.ts.map +1 -1
  93. package/dist/cjs/behaviors/power-source/PowerSourceServer.js +2 -1
  94. package/dist/cjs/behaviors/power-source/PowerSourceServer.js.map +1 -1
  95. package/dist/cjs/behaviors/switch/SwitchServer.d.ts +4 -4
  96. package/dist/cjs/behaviors/switch/SwitchServer.d.ts.map +1 -1
  97. package/dist/cjs/behaviors/switch/SwitchServer.js +8 -6
  98. package/dist/cjs/behaviors/switch/SwitchServer.js.map +1 -1
  99. package/dist/cjs/endpoint/Endpoint.d.ts.map +1 -1
  100. package/dist/cjs/endpoint/Endpoint.js +11 -1
  101. package/dist/cjs/endpoint/Endpoint.js.map +1 -1
  102. package/dist/cjs/endpoint/properties/SupportedBehaviors.d.ts +1 -1
  103. package/dist/cjs/endpoint/properties/SupportedBehaviors.d.ts.map +1 -1
  104. package/dist/cjs/node/ServerNode.d.ts +2 -2
  105. package/dist/cjs/node/ServerNode.d.ts.map +1 -1
  106. package/dist/cjs/node/ServerNode.js +2 -2
  107. package/dist/cjs/node/ServerNode.js.map +1 -1
  108. package/dist/cjs/node/client/ClientNodes.js +4 -4
  109. package/dist/cjs/node/client/ClientNodes.js.map +1 -1
  110. package/dist/cjs/node/client/NodePeerAddressStore.d.ts.map +1 -1
  111. package/dist/cjs/node/client/NodePeerAddressStore.js +2 -1
  112. package/dist/cjs/node/client/NodePeerAddressStore.js.map +2 -2
  113. package/dist/cjs/node/server/InteractionServer.d.ts +6 -6
  114. package/dist/cjs/node/server/InteractionServer.d.ts.map +1 -1
  115. package/dist/cjs/node/server/InteractionServer.js +12 -11
  116. package/dist/cjs/node/server/InteractionServer.js.map +1 -1
  117. package/dist/cjs/node/server/ProtocolService.js +2 -2
  118. package/dist/cjs/node/server/ProtocolService.js.map +1 -1
  119. package/dist/cjs/node/server/ServerSubscription.d.ts +18 -17
  120. package/dist/cjs/node/server/ServerSubscription.d.ts.map +1 -1
  121. package/dist/cjs/node/server/ServerSubscription.js +61 -54
  122. package/dist/cjs/node/server/ServerSubscription.js.map +1 -1
  123. package/dist/esm/behavior/Behavior.d.ts +1 -1
  124. package/dist/esm/behavior/Behavior.d.ts.map +1 -1
  125. package/dist/esm/behavior/Events.js +1 -1
  126. package/dist/esm/behavior/Events.js.map +1 -1
  127. package/dist/esm/behavior/Transitions.d.ts +8 -8
  128. package/dist/esm/behavior/Transitions.d.ts.map +1 -1
  129. package/dist/esm/behavior/Transitions.js +12 -9
  130. package/dist/esm/behavior/Transitions.js.map +1 -1
  131. package/dist/esm/behavior/cluster/FabricScopedDataHandler.js +2 -2
  132. package/dist/esm/behavior/cluster/FabricScopedDataHandler.js.map +1 -1
  133. package/dist/esm/behavior/internal/BehaviorBacking.d.ts.map +1 -1
  134. package/dist/esm/behavior/internal/BehaviorBacking.js +7 -2
  135. package/dist/esm/behavior/internal/BehaviorBacking.js.map +1 -1
  136. package/dist/esm/behavior/internal/Reactors.js +2 -2
  137. package/dist/esm/behavior/internal/Reactors.js.map +1 -1
  138. package/dist/esm/behavior/state/managed/values/PrimitiveManager.d.ts +3 -4
  139. package/dist/esm/behavior/state/managed/values/PrimitiveManager.d.ts.map +1 -1
  140. package/dist/esm/behavior/state/managed/values/PrimitiveManager.js.map +1 -1
  141. package/dist/esm/behavior/state/managed/values/ValuePatcher.js.map +1 -1
  142. package/dist/esm/behavior/state/migrations/Migration.d.ts +20 -0
  143. package/dist/esm/behavior/state/migrations/Migration.d.ts.map +1 -0
  144. package/dist/esm/behavior/state/migrations/Migration.js +23 -0
  145. package/dist/esm/behavior/state/migrations/Migration.js.map +6 -0
  146. package/dist/esm/behavior/state/migrations/index.d.ts +7 -0
  147. package/dist/esm/behavior/state/migrations/index.d.ts.map +1 -0
  148. package/dist/esm/behavior/state/migrations/index.js +6 -0
  149. package/dist/esm/behavior/state/migrations/index.js.map +6 -0
  150. package/dist/esm/behavior/state/validation/ValueValidator.d.ts.map +1 -1
  151. package/dist/esm/behavior/state/validation/ValueValidator.js +1 -0
  152. package/dist/esm/behavior/state/validation/ValueValidator.js.map +1 -1
  153. package/dist/esm/behavior/state/validation/assertions.d.ts +3 -2
  154. package/dist/esm/behavior/state/validation/assertions.d.ts.map +1 -1
  155. package/dist/esm/behavior/state/validation/assertions.js.map +1 -1
  156. package/dist/esm/behavior/supervision/RootSupervisor.js +2 -2
  157. package/dist/esm/behavior/supervision/RootSupervisor.js.map +1 -1
  158. package/dist/esm/behavior/supervision/ValueSupervisor.d.ts +1 -1
  159. package/dist/esm/behavior/supervision/ValueSupervisor.d.ts.map +1 -1
  160. package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts +7 -7
  161. package/dist/esm/behavior/system/commissioning/CommissioningClient.d.ts.map +1 -1
  162. package/dist/esm/behavior/system/commissioning/CommissioningClient.js +13 -7
  163. package/dist/esm/behavior/system/commissioning/CommissioningClient.js.map +1 -1
  164. package/dist/esm/behavior/system/commissioning/CommissioningServer.d.ts +2 -2
  165. package/dist/esm/behavior/system/commissioning/CommissioningServer.d.ts.map +1 -1
  166. package/dist/esm/behavior/system/commissioning/CommissioningServer.js.map +1 -1
  167. package/dist/esm/behavior/system/commissioning/RemoteDescriptor.d.ts.map +1 -1
  168. package/dist/esm/behavior/system/commissioning/RemoteDescriptor.js +15 -14
  169. package/dist/esm/behavior/system/commissioning/RemoteDescriptor.js.map +1 -1
  170. package/dist/esm/behavior/system/controller/discovery/ContinuousDiscovery.js +1 -1
  171. package/dist/esm/behavior/system/controller/discovery/ContinuousDiscovery.js.map +1 -1
  172. package/dist/esm/behavior/system/controller/discovery/Discovery.d.ts +2 -2
  173. package/dist/esm/behavior/system/controller/discovery/Discovery.d.ts.map +1 -1
  174. package/dist/esm/behavior/system/controller/discovery/Discovery.js +2 -2
  175. package/dist/esm/behavior/system/controller/discovery/Discovery.js.map +1 -1
  176. package/dist/esm/behavior/system/network/NetworkClient.d.ts.map +1 -1
  177. package/dist/esm/behavior/system/network/NetworkClient.js +3 -3
  178. package/dist/esm/behavior/system/network/NetworkClient.js.map +1 -1
  179. package/dist/esm/behavior/system/network/ServerNetworkRuntime.js +2 -2
  180. package/dist/esm/behavior/system/network/ServerNetworkRuntime.js.map +1 -1
  181. package/dist/esm/behavior/system/{subscription/SubscriptionBehavior.d.ts → subscriptions/SubscriptionsServer.d.ts} +6 -6
  182. package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.d.ts.map +1 -0
  183. package/dist/esm/behavior/system/{subscription/SubscriptionBehavior.js → subscriptions/SubscriptionsServer.js} +20 -20
  184. package/dist/esm/behavior/system/subscriptions/SubscriptionsServer.js.map +6 -0
  185. package/dist/esm/behavior/system/subscriptions/index.d.ts +7 -0
  186. package/dist/esm/behavior/system/subscriptions/index.d.ts.map +1 -0
  187. package/dist/esm/behavior/system/subscriptions/index.js +7 -0
  188. package/dist/esm/behavior/system/{subscription → subscriptions}/index.js.map +1 -1
  189. package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts +3 -3
  190. package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.d.ts.map +1 -1
  191. package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js +16 -14
  192. package/dist/esm/behaviors/administrator-commissioning/AdministratorCommissioningServer.js.map +1 -1
  193. package/dist/esm/behaviors/color-control/ColorControlServer.d.ts +2 -2
  194. package/dist/esm/behaviors/color-control/ColorControlServer.d.ts.map +1 -1
  195. package/dist/esm/behaviors/color-control/ColorControlServer.js +6 -5
  196. package/dist/esm/behaviors/color-control/ColorControlServer.js.map +1 -1
  197. package/dist/esm/behaviors/general-commissioning/GeneralCommissioningServer.d.ts.map +1 -1
  198. package/dist/esm/behaviors/general-commissioning/GeneralCommissioningServer.js +4 -4
  199. package/dist/esm/behaviors/general-commissioning/GeneralCommissioningServer.js.map +1 -1
  200. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts +4 -4
  201. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.d.ts.map +1 -1
  202. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js +29 -17
  203. package/dist/esm/behaviors/general-diagnostics/GeneralDiagnosticsServer.js.map +1 -1
  204. package/dist/esm/behaviors/identify/IdentifyServer.d.ts.map +1 -1
  205. package/dist/esm/behaviors/identify/IdentifyServer.js +2 -2
  206. package/dist/esm/behaviors/identify/IdentifyServer.js.map +1 -1
  207. package/dist/esm/behaviors/level-control/LevelControlServer.d.ts +1 -1
  208. package/dist/esm/behaviors/level-control/LevelControlServer.d.ts.map +1 -1
  209. package/dist/esm/behaviors/level-control/LevelControlServer.js +4 -4
  210. package/dist/esm/behaviors/level-control/LevelControlServer.js.map +1 -1
  211. package/dist/esm/behaviors/on-off/OnOffServer.d.ts.map +1 -1
  212. package/dist/esm/behaviors/on-off/OnOffServer.js +3 -3
  213. package/dist/esm/behaviors/on-off/OnOffServer.js.map +1 -1
  214. package/dist/esm/behaviors/power-source/PowerSourceServer.d.ts.map +1 -1
  215. package/dist/esm/behaviors/power-source/PowerSourceServer.js +2 -1
  216. package/dist/esm/behaviors/power-source/PowerSourceServer.js.map +1 -1
  217. package/dist/esm/behaviors/switch/SwitchServer.d.ts +4 -4
  218. package/dist/esm/behaviors/switch/SwitchServer.d.ts.map +1 -1
  219. package/dist/esm/behaviors/switch/SwitchServer.js +9 -7
  220. package/dist/esm/behaviors/switch/SwitchServer.js.map +1 -1
  221. package/dist/esm/endpoint/Endpoint.d.ts.map +1 -1
  222. package/dist/esm/endpoint/Endpoint.js +11 -1
  223. package/dist/esm/endpoint/Endpoint.js.map +1 -1
  224. package/dist/esm/endpoint/properties/SupportedBehaviors.d.ts +1 -1
  225. package/dist/esm/endpoint/properties/SupportedBehaviors.d.ts.map +1 -1
  226. package/dist/esm/node/ServerNode.d.ts +2 -2
  227. package/dist/esm/node/ServerNode.d.ts.map +1 -1
  228. package/dist/esm/node/ServerNode.js +2 -2
  229. package/dist/esm/node/ServerNode.js.map +1 -1
  230. package/dist/esm/node/client/ClientNodes.js +5 -5
  231. package/dist/esm/node/client/ClientNodes.js.map +1 -1
  232. package/dist/esm/node/client/NodePeerAddressStore.d.ts.map +1 -1
  233. package/dist/esm/node/client/NodePeerAddressStore.js +3 -2
  234. package/dist/esm/node/client/NodePeerAddressStore.js.map +2 -2
  235. package/dist/esm/node/server/InteractionServer.d.ts +6 -6
  236. package/dist/esm/node/server/InteractionServer.d.ts.map +1 -1
  237. package/dist/esm/node/server/InteractionServer.js +16 -12
  238. package/dist/esm/node/server/InteractionServer.js.map +1 -1
  239. package/dist/esm/node/server/ProtocolService.js +2 -2
  240. package/dist/esm/node/server/ProtocolService.js.map +1 -1
  241. package/dist/esm/node/server/ServerSubscription.d.ts +18 -17
  242. package/dist/esm/node/server/ServerSubscription.d.ts.map +1 -1
  243. package/dist/esm/node/server/ServerSubscription.js +75 -55
  244. package/dist/esm/node/server/ServerSubscription.js.map +1 -1
  245. package/package.json +7 -7
  246. package/src/behavior/Behavior.ts +1 -1
  247. package/src/behavior/Events.ts +1 -1
  248. package/src/behavior/Transitions.ts +17 -13
  249. package/src/behavior/cluster/FabricScopedDataHandler.ts +2 -2
  250. package/src/behavior/internal/BehaviorBacking.ts +9 -2
  251. package/src/behavior/state/managed/values/PrimitiveManager.ts +3 -4
  252. package/src/behavior/state/managed/values/ValuePatcher.ts +2 -2
  253. package/src/behavior/state/migrations/Migration.ts +34 -0
  254. package/src/behavior/{system/subscription → state/migrations}/index.ts +1 -1
  255. package/src/behavior/state/validation/ValueValidator.ts +1 -0
  256. package/src/behavior/state/validation/assertions.ts +2 -2
  257. package/src/behavior/supervision/ValueSupervisor.ts +1 -1
  258. package/src/behavior/system/commissioning/CommissioningClient.ts +20 -12
  259. package/src/behavior/system/commissioning/CommissioningServer.ts +2 -1
  260. package/src/behavior/system/commissioning/RemoteDescriptor.ts +15 -15
  261. package/src/behavior/system/controller/discovery/ContinuousDiscovery.ts +1 -1
  262. package/src/behavior/system/controller/discovery/Discovery.ts +4 -4
  263. package/src/behavior/system/network/NetworkClient.ts +3 -3
  264. package/src/behavior/system/network/ServerNetworkRuntime.ts +2 -2
  265. package/src/behavior/system/sessions/SessionsBehavior.ts +1 -1
  266. package/src/behavior/system/{subscription/SubscriptionBehavior.ts → subscriptions/SubscriptionsServer.ts} +17 -17
  267. package/src/behavior/system/subscriptions/index.ts +7 -0
  268. package/src/behaviors/administrator-commissioning/AdministratorCommissioningServer.ts +20 -16
  269. package/src/behaviors/color-control/ColorControlServer.ts +5 -4
  270. package/src/behaviors/general-commissioning/GeneralCommissioningServer.ts +4 -4
  271. package/src/behaviors/general-diagnostics/GeneralDiagnosticsServer.ts +38 -21
  272. package/src/behaviors/identify/IdentifyServer.ts +2 -2
  273. package/src/behaviors/level-control/LevelControlServer.ts +4 -4
  274. package/src/behaviors/on-off/OnOffServer.ts +3 -3
  275. package/src/behaviors/power-source/PowerSourceServer.ts +2 -1
  276. package/src/behaviors/switch/SwitchServer.ts +10 -7
  277. package/src/endpoint/Endpoint.ts +13 -1
  278. package/src/endpoint/properties/SupportedBehaviors.ts +1 -1
  279. package/src/node/ServerNode.ts +2 -2
  280. package/src/node/client/ClientNodes.ts +8 -8
  281. package/src/node/client/NodePeerAddressStore.ts +4 -2
  282. package/src/node/server/InteractionServer.ts +21 -15
  283. package/src/node/server/ServerSubscription.ts +86 -64
  284. package/dist/cjs/behavior/system/subscription/SubscriptionBehavior.d.ts.map +0 -1
  285. package/dist/cjs/behavior/system/subscription/SubscriptionBehavior.js.map +0 -6
  286. package/dist/cjs/behavior/system/subscription/index.d.ts.map +0 -1
  287. package/dist/cjs/behavior/system/subscription/index.js.map +0 -6
  288. package/dist/esm/behavior/system/subscription/SubscriptionBehavior.d.ts.map +0 -1
  289. package/dist/esm/behavior/system/subscription/SubscriptionBehavior.js.map +0 -6
  290. package/dist/esm/behavior/system/subscription/index.d.ts.map +0 -1
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
 
7
- import { deepCopy, isIpNetworkChannel, Logger, MatterError, MaybePromise, ServerAddressIp } from "#general";
7
+ import { deepCopy, isIpNetworkChannel, Logger, MatterError, MaybePromise, Seconds, ServerAddressIp } from "#general";
8
8
  import { DatatypeModel, FieldElement } from "#model";
9
9
  import { InteractionServer, PeerSubscription } from "#node/server/InteractionServer.js";
10
10
  import { ServerSubscription } from "#node/server/ServerSubscription.js";
@@ -21,10 +21,10 @@ import {
21
21
  import { StatusCode, StatusResponseError } from "#types";
22
22
  import { Behavior } from "../../Behavior.js";
23
23
  import { SessionsBehavior } from "../sessions/SessionsBehavior.js";
24
- const logger = Logger.get("SubscriptionBehavior");
24
+ const logger = Logger.get("SubscriptionsBehavior");
25
25
 
26
26
  /** Timeout in seconds to wait for responses or discovery of the peer node when trying to re-establish a subscription. */
27
- const REESTABLISH_SUBSCRIPTIONS_TIMEOUT_S = 2;
27
+ const REESTABLISH_SUBSCRIPTIONS_TIMEOUT = Seconds(2);
28
28
 
29
29
  /**
30
30
  * Subscriptions Persistence handling.
@@ -33,11 +33,11 @@ const REESTABLISH_SUBSCRIPTIONS_TIMEOUT_S = 2;
33
33
  * speed up the controller reconnection process. This can mean a bit more memory usage on start of the device. To
34
34
  * disable this feature set `persistenceEnabled` as state of the `subscription` behavior to `false`.
35
35
  */
36
- export class SubscriptionBehavior extends Behavior {
37
- static override readonly id = "subscription";
36
+ export class SubscriptionsBehavior extends Behavior {
37
+ static override readonly id = "subscriptions";
38
38
 
39
- declare state: SubscriptionBehavior.State;
40
- declare internal: SubscriptionBehavior.Internal;
39
+ declare state: SubscriptionsBehavior.State;
40
+ declare internal: SubscriptionsBehavior.Internal;
41
41
 
42
42
  override initialize() {
43
43
  if (this.state.subscriptions !== undefined && this.state.persistenceEnabled !== false) {
@@ -115,10 +115,10 @@ export class SubscriptionBehavior extends Behavior {
115
115
  ),
116
116
  ),
117
117
  FieldElement({ name: "isFabricFiltered", type: "bool" }),
118
- FieldElement({ name: "maxIntervalCeilingSeconds", type: "uint16" }),
119
- FieldElement({ name: "minIntervalFloorSeconds", type: "uint16" }),
120
- FieldElement({ name: "maxInterval", type: "uint16" }),
121
- FieldElement({ name: "sendInterval", type: "uint16" }),
118
+ FieldElement({ name: "maxIntervalCeiling", type: "duration" }),
119
+ FieldElement({ name: "minIntervalFloor", type: "duration" }),
120
+ FieldElement({ name: "maxInterval", type: "duration" }),
121
+ FieldElement({ name: "sendInterval", type: "duration" }),
122
122
  FieldElement(
123
123
  {
124
124
  name: "operationalAddress",
@@ -142,8 +142,8 @@ export class SubscriptionBehavior extends Behavior {
142
142
  maxInterval,
143
143
  sendInterval,
144
144
  id,
145
- maxIntervalCeilingSeconds,
146
- minIntervalFloorSeconds,
145
+ maxIntervalCeiling,
146
+ minIntervalFloor,
147
147
  } = subscription;
148
148
  const { peerAddress } = session;
149
149
  const { fabricIndex, nodeId } = peerAddress;
@@ -160,8 +160,8 @@ export class SubscriptionBehavior extends Behavior {
160
160
  const peerSubscription: PeerSubscription = {
161
161
  subscriptionId: id,
162
162
  peerAddress: { fabricIndex, nodeId },
163
- maxIntervalCeilingSeconds,
164
- minIntervalFloorSeconds,
163
+ maxIntervalCeiling,
164
+ minIntervalFloor,
165
165
  attributeRequests,
166
166
  eventRequests,
167
167
  isFabricFiltered,
@@ -234,7 +234,7 @@ export class SubscriptionBehavior extends Behavior {
234
234
  await peers.ensureConnection(peerAddress, {
235
235
  discoveryOptions: {
236
236
  discoveryType: NodeDiscoveryType.TimedDiscovery,
237
- timeoutSeconds: REESTABLISH_SUBSCRIPTIONS_TIMEOUT_S,
237
+ timeout: REESTABLISH_SUBSCRIPTIONS_TIMEOUT,
238
238
  },
239
239
  allowUnknownPeer: true,
240
240
  operationalAddress,
@@ -282,7 +282,7 @@ export class SubscriptionBehavior extends Behavior {
282
282
  }
283
283
  }
284
284
 
285
- export namespace SubscriptionBehavior {
285
+ export namespace SubscriptionsBehavior {
286
286
  export class State {
287
287
  /** Set to false if persistence of subscriptions should be disabled */
288
288
  persistenceEnabled = true;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2025 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ export * from "./SubscriptionsServer.js";
@@ -5,14 +5,14 @@
5
5
  */
6
6
 
7
7
  import { AdministratorCommissioning } from "#clusters/administrator-commissioning";
8
- import { InternalError, Logger, Time, Timer } from "#general";
8
+ import { Duration, InternalError, Logger, Seconds, Time, Timer } from "#general";
9
9
  import { AccessLevel } from "#model";
10
10
  import { DeviceCommissioner, FailsafeContext, PaseServer, SessionManager } from "#protocol";
11
11
  import {
12
12
  Command,
13
- MINIMUM_COMMISSIONING_TIMEOUT_S,
13
+ MINIMUM_COMMISSIONING_TIMEOUT,
14
14
  PAKE_PASSCODE_VERIFIER_LENGTH,
15
- STANDARD_COMMISSIONING_TIMEOUT_S,
15
+ STANDARD_COMMISSIONING_TIMEOUT,
16
16
  Status,
17
17
  StatusResponseError,
18
18
  TlvByteString,
@@ -86,10 +86,12 @@ export class AdministratorCommissioningServer extends AdministratorCommissioning
86
86
 
87
87
  const commissioner = this.env.get(DeviceCommissioner);
88
88
 
89
- this.#assertCommissioningWindowRequirements(commissioningTimeout, commissioner);
89
+ const timeout = Seconds(commissioningTimeout);
90
+
91
+ this.#assertCommissioningWindowRequirements(timeout, commissioner);
90
92
 
91
93
  this.#initializeCommissioningWindow(
92
- commissioningTimeout,
94
+ timeout,
93
95
  AdministratorCommissioning.CommissioningWindowStatus.EnhancedWindowOpen,
94
96
  );
95
97
 
@@ -109,10 +111,12 @@ export class AdministratorCommissioningServer extends AdministratorCommissioning
109
111
  }: AdministratorCommissioning.OpenBasicCommissioningWindowRequest) {
110
112
  const commissioner = this.env.get(DeviceCommissioner);
111
113
 
112
- this.#assertCommissioningWindowRequirements(commissioningTimeout, commissioner);
114
+ const timeout = Seconds(commissioningTimeout);
115
+
116
+ this.#assertCommissioningWindowRequirements(timeout, commissioner);
113
117
 
114
118
  this.#initializeCommissioningWindow(
115
- commissioningTimeout,
119
+ timeout,
116
120
  AdministratorCommissioning.CommissioningWindowStatus.BasicWindowOpen,
117
121
  );
118
122
 
@@ -144,7 +148,7 @@ export class AdministratorCommissioningServer extends AdministratorCommissioning
144
148
  * adjusts the needed attributes.
145
149
  */
146
150
  #initializeCommissioningWindow(
147
- commissioningTimeout: number,
151
+ commissioningTimeout: Duration,
148
152
  windowStatus: AdministratorCommissioning.CommissioningWindowStatus,
149
153
  ) {
150
154
  if (this.internal.commissioningWindowTimeout !== undefined) {
@@ -156,7 +160,7 @@ export class AdministratorCommissioningServer extends AdministratorCommissioning
156
160
  );
157
161
  this.internal.commissioningWindowTimeout = Time.getTimer(
158
162
  "Commissioning timeout",
159
- commissioningTimeout * 1000,
163
+ commissioningTimeout,
160
164
  this.callback(this.#commissioningTimeout),
161
165
  ).start();
162
166
 
@@ -178,21 +182,21 @@ export class AdministratorCommissioningServer extends AdministratorCommissioning
178
182
  /**
179
183
  * This method validates if a commissioning window can be opened and throws various exceptions in case of failures.
180
184
  */
181
- #assertCommissioningWindowRequirements(commissioningTimeout: number, commissioner: DeviceCommissioner) {
185
+ #assertCommissioningWindowRequirements(commissioningTimeout: Duration, commissioner: DeviceCommissioner) {
182
186
  if (this.internal.commissioningWindowTimeout !== undefined) {
183
187
  throw new AdministratorCommissioning.BusyError("A commissioning window is already opened");
184
188
  }
185
189
 
186
- if (commissioningTimeout > this.internal.maximumCommissioningTimeoutS) {
190
+ if (commissioningTimeout > this.internal.maximumCommissioningTimeout) {
187
191
  throw new StatusResponseError(
188
- `Commissioning timeout must not exceed ${this.internal.maximumCommissioningTimeoutS} seconds.`,
192
+ `Commissioning timeout must not exceed ${this.internal.maximumCommissioningTimeout} seconds.`,
189
193
  Status.InvalidCommand,
190
194
  );
191
195
  }
192
196
 
193
- if (commissioningTimeout < this.internal.minimumCommissioningTimeoutS) {
197
+ if (commissioningTimeout < this.internal.minimumCommissioningTimeout) {
194
198
  throw new StatusResponseError(
195
- `Commissioning timeout must not be lower then ${this.internal.minimumCommissioningTimeoutS} seconds.`,
199
+ `Commissioning timeout must not be lower then ${this.internal.minimumCommissioningTimeout} seconds.`,
196
200
  Status.InvalidCommand,
197
201
  );
198
202
  }
@@ -261,13 +265,13 @@ export namespace AdministratorCommissioningServer {
261
265
  /**
262
266
  * Mandated by spec; should only be modified in testing.
263
267
  */
264
- minimumCommissioningTimeoutS = MINIMUM_COMMISSIONING_TIMEOUT_S;
268
+ minimumCommissioningTimeout = MINIMUM_COMMISSIONING_TIMEOUT;
265
269
 
266
270
  /**
267
271
  * Commissioning beyond the standard 15-minute window is "extended commissioning" and has limitations on
268
272
  * advertisement. We default to the standard window.
269
273
  */
270
- maximumCommissioningTimeoutS = STANDARD_COMMISSIONING_TIMEOUT_S;
274
+ maximumCommissioningTimeout = STANDARD_COMMISSIONING_TIMEOUT;
271
275
  }
272
276
 
273
277
  export class State extends AdministratorCommissioningBehavior.State {
@@ -19,6 +19,7 @@ import {
19
19
  ImplementationError,
20
20
  Logger,
21
21
  MaybePromise,
22
+ Millis,
22
23
  } from "#general";
23
24
  import { ServerNode } from "#node/ServerNode.js";
24
25
  import { Val } from "#protocol";
@@ -1671,8 +1672,8 @@ export class ColorControlBaseServer extends ColorControlBase {
1671
1672
  return readOnlyState.transitionEndTimeMs;
1672
1673
  },
1673
1674
 
1674
- get stepIntervalMs() {
1675
- return readOnlyState.transitionStepIntervalMs;
1675
+ get stepInterval() {
1676
+ return readOnlyState.transitionStepInterval;
1676
1677
  },
1677
1678
 
1678
1679
  properties: {
@@ -1803,12 +1804,12 @@ export namespace ColorControlBaseServer {
1803
1804
  * If transition management is disabled you may specify this as the "end time" for transitions. The remaining
1804
1805
  * time attribute will then report correctly.
1805
1806
  */
1806
- transitionEndTimeMs = undefined;
1807
+ transitionEndTimeMs?: number;
1807
1808
 
1808
1809
  /**
1809
1810
  * When managing transitions, this is the interval at which steps occur in ms.
1810
1811
  */
1811
- transitionStepIntervalMs = 100;
1812
+ transitionStepInterval = Millis(100);
1812
1813
 
1813
1814
  [Val.properties](endpoint: Endpoint) {
1814
1815
  // Only return remaining time if the attribute is defined in the endpoint
@@ -8,7 +8,7 @@ import { AdministratorCommissioningServer } from "#behaviors/administrator-commi
8
8
  import { BasicInformationServer } from "#behaviors/basic-information";
9
9
  import { AdministratorCommissioning } from "#clusters/administrator-commissioning";
10
10
  import { GeneralCommissioning } from "#clusters/general-commissioning";
11
- import { Bytes, Diagnostic, Logger, MatterFlowError, MaybePromise } from "#general";
11
+ import { Bytes, Diagnostic, Logger, MatterFlowError, MaybePromise, Seconds } from "#general";
12
12
  import type { ServerNode } from "#node/ServerNode.js";
13
13
  import { DeviceCommissioner, FabricManager, GroupSession, NodeSession, SecureSession, SessionManager } from "#protocol";
14
14
  import { GeneralCommissioningBehavior } from "./GeneralCommissioningBehavior.js";
@@ -80,7 +80,7 @@ export class GeneralCommissioningServer extends GeneralCommissioningBehavior {
80
80
  }
81
81
 
82
82
  if (commissioner.isFailsafeArmed) {
83
- await commissioner.failsafeContext.extend(session.fabric, expiryLengthSeconds);
83
+ await commissioner.failsafeContext.extend(session.fabric, Seconds(expiryLengthSeconds));
84
84
  } else {
85
85
  // If ExpiryLengthSeconds is 0 and the fail-safe timer was not armed, then this command invocation SHALL
86
86
  // lead to a success response with no side effect against the fail-safe context.
@@ -89,8 +89,8 @@ export class GeneralCommissioningServer extends GeneralCommissioningBehavior {
89
89
  const failsafe = new ServerNodeFailsafeContext(this.endpoint as ServerNode, {
90
90
  fabrics: this.env.get(FabricManager),
91
91
  sessions: this.env.get(SessionManager),
92
- expiryLengthSeconds,
93
- maxCumulativeFailsafeSeconds: this.state.basicCommissioningInfo.maxCumulativeFailsafeSeconds,
92
+ expiryLength: Seconds(expiryLengthSeconds),
93
+ maxCumulativeFailsafe: Seconds(this.state.basicCommissioningInfo.maxCumulativeFailsafeSeconds),
94
94
  associatedFabric: session.fabric,
95
95
  });
96
96
 
@@ -11,7 +11,21 @@ import { NetworkCommissioningServer } from "#behaviors/network-commissioning";
11
11
  import { TimeSynchronizationBehavior } from "#behaviors/time-synchronization";
12
12
  import { GeneralDiagnostics } from "#clusters/general-diagnostics";
13
13
  import type { Endpoint } from "#endpoint/Endpoint.js";
14
- import { Bytes, ImplementationError, ipv4ToBytes, Logger, MaybePromise, Time, Timer } from "#general";
14
+ import {
15
+ Bytes,
16
+ Duration,
17
+ Hours,
18
+ ImplementationError,
19
+ ipv4ToBytes,
20
+ Logger,
21
+ MaybePromise,
22
+ Millis,
23
+ Minutes,
24
+ Seconds,
25
+ Time,
26
+ Timer,
27
+ Timespan,
28
+ } from "#general";
15
29
  import { FieldElement, Specification } from "#model";
16
30
  import type { NodeLifecycle } from "#node/NodeLifecycle.js";
17
31
  import { MdnsService, Val } from "#protocol";
@@ -105,7 +119,7 @@ export class GeneralDiagnosticsServer extends Base {
105
119
  }
106
120
 
107
121
  override timeSnapshot(): MaybePromise<GeneralDiagnostics.TimeSnapshotResponse> {
108
- const time = Time.nowMs();
122
+ const time = Time.nowMs;
109
123
 
110
124
  // TC_DGGEN_2_4.py fails us if we set this without TimeSynchronizationCluster support. Spec is worded poorly
111
125
  // but my read of "SHALL only if" is "may not unless" and not "SHALL if and only if". But conforming to tests
@@ -294,11 +308,11 @@ export class GeneralDiagnosticsServer extends Base {
294
308
  );
295
309
 
296
310
  // Update the timestamps now that node is really online.
297
- this.internal.lastTotalOperationalHoursCounterUpdateTime = Time.nowMs();
311
+ this.internal.lastTotalOperationalHoursCounterUpdateTime = Time.nowMs;
298
312
 
299
313
  this.internal.lastTotalOperationalHoursTimer = Time.getPeriodicTimer(
300
314
  "GeneralDiagnostics.operationalHours",
301
- 5 * 60_000,
315
+ Minutes(5),
302
316
  this.callback(this.#updateTotalOperationalHoursCounter),
303
317
  ).start();
304
318
 
@@ -311,9 +325,9 @@ export class GeneralDiagnosticsServer extends Base {
311
325
  }
312
326
 
313
327
  #updateTotalOperationalHoursCounter() {
314
- const now = Time.nowMs();
315
- const elapsedTime = now - this.internal.lastTotalOperationalHoursCounterUpdateTime;
316
- this.state.totalOperationalHoursCounter = this.state.totalOperationalHoursCounter + elapsedTime;
328
+ const now = Time.nowMs;
329
+ const elapsedTime = Timespan(this.internal.lastTotalOperationalHoursCounterUpdateTime, now).duration;
330
+ this.state.totalOperationalHoursCounter = Millis(this.state.totalOperationalHoursCounter + elapsedTime);
317
331
  this.internal.lastTotalOperationalHoursCounterUpdateTime = now;
318
332
  }
319
333
 
@@ -382,15 +396,15 @@ export class GeneralDiagnosticsServer extends Base {
382
396
  export namespace GeneralDiagnosticsServer {
383
397
  export class Internal {
384
398
  /** Last time the total operational hours counter was updated. */
385
- lastTotalOperationalHoursCounterUpdateTime: number = Time.nowMs();
399
+ lastTotalOperationalHoursCounterUpdateTime = Time.nowMs;
386
400
 
387
401
  /** Timer to update the total operational hours counter every 5 minutes. */
388
402
  lastTotalOperationalHoursTimer: Timer | undefined;
389
403
  }
390
404
 
391
405
  export class State extends Base.State {
392
- /** Internal counter of the total operational hours, counted in seconds, updated every 5 minutes. */
393
- totalOperationalHoursCounter: number = 0;
406
+ /** Internal counter of the total time, updated every 5 minutes. */
407
+ totalOperationalHoursCounter: Duration = 0;
394
408
 
395
409
  /** The TestEnableKey set for this device for the test commands. Default means "not enabled"." */
396
410
  deviceTestEnableKey: Bytes = new Uint8Array(16).fill(0);
@@ -415,7 +429,7 @@ export namespace GeneralDiagnosticsServer {
415
429
  return 0;
416
430
  }
417
431
 
418
- return Math.round((Time.nowMs() - onlineAt.getTime()) / 1000);
432
+ return Seconds.of(Timespan(onlineAt, Time.nowMs).duration);
419
433
  },
420
434
 
421
435
  /**
@@ -423,16 +437,19 @@ export namespace GeneralDiagnosticsServer {
423
437
  * is not send out via subscriptions anyway.
424
438
  */
425
439
  get totalOperationalHours() {
426
- const lastTotalOperationalHoursCounterUpdateTime =
427
- endpoint.behaviors.internalsOf(
428
- GeneralDiagnosticsServer,
429
- ).lastTotalOperationalHoursCounterUpdateTime;
430
- const totalOperationalHoursCounter =
431
- endpoint.stateOf(GeneralDiagnosticsServer).totalOperationalHoursCounter;
432
- return Math.floor(
433
- (Time.nowMs() - lastTotalOperationalHoursCounterUpdateTime + totalOperationalHoursCounter) /
434
- (60 * 60_000),
435
- );
440
+ const { lastTotalOperationalHoursCounterUpdateTime } =
441
+ endpoint.behaviors.internalsOf(GeneralDiagnosticsServer);
442
+
443
+ const timeSinceLastUpdate = Timespan(
444
+ lastTotalOperationalHoursCounterUpdateTime,
445
+ Time.nowMs,
446
+ ).duration;
447
+
448
+ const timeAsOfLastUpdate = endpoint.stateOf(GeneralDiagnosticsServer).totalOperationalHoursCounter;
449
+
450
+ const totalOperationalTime = Millis(timeAsOfLastUpdate + timeSinceLastUpdate);
451
+
452
+ return Hours.of(totalOperationalTime);
436
453
  },
437
454
  };
438
455
  }
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { Identify } from "#clusters/identify";
8
- import { MaybePromise, Observable, Time, Timer } from "#general";
8
+ import { MaybePromise, Observable, Seconds, Time, Timer } from "#general";
9
9
  import { IdentifyBehavior } from "./IdentifyBehavior.js";
10
10
 
11
11
  /**
@@ -37,7 +37,7 @@ export class IdentifyServer extends IdentifyBehavior {
37
37
  // Enable I/2.4 once this is done
38
38
  this.internal.identifyTimer = Time.getPeriodicTimer(
39
39
  "Identify time update",
40
- 1000,
40
+ Seconds.one,
41
41
  this.callback(this.#identifyTick, { lock: true }),
42
42
  );
43
43
 
@@ -13,7 +13,7 @@ import { OnOffServer } from "#behaviors/on-off";
13
13
  import { GeneralDiagnostics } from "#clusters/general-diagnostics";
14
14
  import { LevelControl } from "#clusters/level-control";
15
15
  import { Endpoint } from "#endpoint/Endpoint.js";
16
- import { AsyncObservable, Identity, Logger, MaybePromise } from "#general";
16
+ import { AsyncObservable, Identity, Logger, MaybePromise, Millis } from "#general";
17
17
  import { ServerNode } from "#node/ServerNode.js";
18
18
  import { Val } from "#protocol";
19
19
  import { ClusterType, StatusCode, StatusResponseError, TypeFromPartialBitSchema } from "#types";
@@ -141,8 +141,8 @@ export class LevelControlBaseServer extends LevelControlBase {
141
141
  return readOnlyState.transitionEndTimeMs;
142
142
  },
143
143
 
144
- get stepIntervalMs() {
145
- return readOnlyState.transitionStepIntervalMs;
144
+ get stepInterval() {
145
+ return readOnlyState.transitionStepInterval;
146
146
  },
147
147
 
148
148
  properties: {
@@ -614,7 +614,7 @@ export namespace LevelControlBaseServer {
614
614
  /**
615
615
  * When managing transitions, this is the interval at which steps occur in ms.
616
616
  */
617
- transitionStepIntervalMs = 100;
617
+ transitionStepInterval = Millis(100);
618
618
 
619
619
  [Val.properties](endpoint: Endpoint) {
620
620
  // Only return remaining time if the attribute is defined in the endpoint
@@ -7,7 +7,7 @@
7
7
  import { GeneralDiagnosticsBehavior } from "#behaviors/general-diagnostics";
8
8
  import { GeneralDiagnostics } from "#clusters/general-diagnostics";
9
9
  import { OnOff } from "#clusters/on-off";
10
- import { MaybePromise, Time, Timer } from "#general";
10
+ import { MaybePromise, Millis, Time, Timer } from "#general";
11
11
  import { ServerNode } from "#node/ServerNode.js";
12
12
  import { OnOffBehavior } from "./OnOffBehavior.js";
13
13
 
@@ -147,7 +147,7 @@ export class OnOffBaseServer extends OnOffLogicBase {
147
147
  if (timer === undefined) {
148
148
  timer = this.internal.timedOnTimer = Time.getPeriodicTimer(
149
149
  "Timed on",
150
- 100,
150
+ Millis(100),
151
151
  this.callback(this.#timedOnTick, { lock: true }),
152
152
  );
153
153
  }
@@ -170,7 +170,7 @@ export class OnOffBaseServer extends OnOffLogicBase {
170
170
  if (timer === undefined) {
171
171
  timer = this.internal.delayedOffTimer = Time.getPeriodicTimer(
172
172
  "Delayed off",
173
- 100,
173
+ Millis(100),
174
174
  this.callback(this.#delayedOffTick, { lock: true }),
175
175
  );
176
176
  }
@@ -6,6 +6,7 @@
6
6
 
7
7
  import { DescriptorServer } from "#behaviors/descriptor";
8
8
  import { PowerSource } from "#clusters/power-source";
9
+ import { Seconds } from "#general";
9
10
  import { ClusterType } from "#types";
10
11
  import { PowerSourceBehavior } from "./PowerSourceBehavior.js";
11
12
 
@@ -25,7 +26,7 @@ export class PowerSourceBaseServer extends PowerSourceLevelBase {
25
26
  this.events.batTimeToFullCharge$Changed,
26
27
  ].forEach(event => {
27
28
  if (event !== undefined) {
28
- event.quiet.minimumEmitIntervalMs = 10_000;
29
+ event.quiet.minimumEmitInterval = Seconds(10);
29
30
  }
30
31
  });
31
32
  }
@@ -6,11 +6,14 @@
6
6
 
7
7
  import { ActionContext } from "#behavior/context/ActionContext.js";
8
8
  import { Switch } from "#clusters/switch";
9
- import { Logger, MaybePromise, Observable, Time, Timer } from "#general";
9
+ import { Duration, Logger, MaybePromise, Millis, Observable, Seconds, Time, Timer } from "#general";
10
10
  import { FieldElement } from "#model";
11
11
  import { ClusterType, StatusCode, StatusResponseError } from "#types";
12
12
  import { SwitchBehavior } from "./SwitchBehavior.js";
13
13
 
14
+ const DEFAULT_MULTIPRESS_DELAY = Millis(300);
15
+ const DEFAULT_LONG_PRESS_DELAY = Seconds(2);
16
+
14
17
  const logger = Logger.get("SwitchServer");
15
18
 
16
19
  const SwitchServerBase = SwitchBehavior.for(Switch.Complete).with(
@@ -99,7 +102,7 @@ export class SwitchBaseServer extends SwitchServerBase {
99
102
 
100
103
  #debounceRawPosition(newPosition: number) {
101
104
  // When a debounce delay is set then we debounce the raw position, else we set the current position immediately
102
- if (this.state.debounceDelay !== 0) {
105
+ if (this.state.debounceDelay) {
103
106
  this.internal.debounceTimer?.stop();
104
107
 
105
108
  this.internal.currentUnstablePosition = newPosition;
@@ -170,7 +173,7 @@ export class SwitchBaseServer extends SwitchServerBase {
170
173
  this.internal.currentLongPressPosition = newPosition;
171
174
  this.internal.longPressTimer = Time.getTimer(
172
175
  "longPress",
173
- this.state.longPressDelay,
176
+ this.state.longPressDelay ?? DEFAULT_LONG_PRESS_DELAY,
174
177
  this.callback(this.#handleLongPress, { lock: true }),
175
178
  ).start();
176
179
  }
@@ -226,7 +229,7 @@ export class SwitchBaseServer extends SwitchServerBase {
226
229
  if (!pressSequenceFinished) {
227
230
  this.internal.multiPressTimer = Time.getTimer(
228
231
  "multiPress",
229
- this.state.multiPressDelay,
232
+ this.state.multiPressDelay ?? DEFAULT_MULTIPRESS_DELAY,
230
233
  this.callback(this.#handleMultiPressComplete, { lock: true }),
231
234
  ).start();
232
235
  }
@@ -318,13 +321,13 @@ export namespace SwitchBaseServer {
318
321
  * Debounce Delay to wait until a newly reported raw position is considered stable and written to the
319
322
  * currentPosition attribue.
320
323
  */
321
- debounceDelay: number = 0;
324
+ debounceDelay?: Duration;
322
325
 
323
326
  /** Time to wait until a value is considered "long" pressed */
324
- longPressDelay: number = 0;
327
+ longPressDelay?: Duration;
325
328
 
326
329
  /** Timeframe starting with a stable release to detect multi-presses. */
327
- multiPressDelay: number = 0;
330
+ multiPressDelay?: Duration;
328
331
 
329
332
  /** Number of the position considered as the neutral position for the momentary switch. */
330
333
  momentaryNeutralPosition: number = 0;
@@ -206,8 +206,15 @@ export class Endpoint<T extends EndpointType = EndpointType.Empty> {
206
206
  `State values for ${behaviorId} must be an object, not ${typeof vals}`,
207
207
  );
208
208
  }
209
+
210
+ if (vals instanceof Date) {
211
+ throw new ImplementationError(
212
+ `State values for ${behaviorId} must be an object, not ${vals.constructor.name}`,
213
+ );
214
+ }
215
+
209
216
  if (Array.isArray(vals)) {
210
- throw new ImplementationError(`StateValue for ${behaviorId} must be an object, not an array`);
217
+ throw new ImplementationError(`State value for ${behaviorId} must be an object, not an array`);
211
218
  }
212
219
 
213
220
  patch(vals, behavior.state, this.path);
@@ -236,6 +243,11 @@ export class Endpoint<T extends EndpointType = EndpointType.Empty> {
236
243
  if (typeof values !== "object") {
237
244
  throw new ImplementationError(`State values for ${type.id} must be an object, not ${typeof values}`);
238
245
  }
246
+ if (values instanceof Date) {
247
+ throw new ImplementationError(
248
+ `State values for ${type.id} must be an object, not ${values.constructor.name}`,
249
+ );
250
+ }
239
251
  if (Array.isArray(values)) {
240
252
  throw new ImplementationError(`State values for ${type.id} must be an object, not an array`);
241
253
  }
@@ -100,7 +100,7 @@ export namespace SupportedBehaviors {
100
100
  * Patch input version of {@link StateOf}.
101
101
  */
102
102
  export type StatePatchOf<SB extends SupportedBehaviors> = {
103
- [K in keyof SB]?: Behavior.PatchStateOf<SB[K]>;
103
+ readonly [K in keyof SB]?: Behavior.PatchStateOf<SB[K]>;
104
104
  } & {
105
105
  descriptor?: Behavior.PatchStateOf<typeof DescriptorBehavior>;
106
106
  };
@@ -12,7 +12,7 @@ import { NetworkServer } from "#behavior/system/network/NetworkServer.js";
12
12
  import { ServerNetworkRuntime } from "#behavior/system/network/ServerNetworkRuntime.js";
13
13
  import { ProductDescriptionServer } from "#behavior/system/product-description/ProductDescriptionServer.js";
14
14
  import { SessionsBehavior } from "#behavior/system/sessions/SessionsBehavior.js";
15
- import { SubscriptionBehavior } from "#behavior/system/subscription/SubscriptionBehavior.js";
15
+ import { SubscriptionsBehavior } from "#behavior/system/subscriptions/SubscriptionsServer.js";
16
16
  import { Endpoint } from "#endpoint/Endpoint.js";
17
17
  import type { Environment } from "#general";
18
18
  import { asyncNew, Construction, DiagnosticSource, errorOf, Identity, MatterError } from "#general";
@@ -207,7 +207,7 @@ export namespace ServerNode {
207
207
  CommissioningServer,
208
208
  NetworkServer,
209
209
  ProductDescriptionServer,
210
- SubscriptionBehavior,
210
+ SubscriptionsBehavior,
211
211
  SessionsBehavior,
212
212
  EventsBehavior,
213
213
  ControllerBehavior,
@@ -10,7 +10,7 @@ import { ContinuousDiscovery } from "#behavior/system/controller/discovery/Conti
10
10
  import { Discovery } from "#behavior/system/controller/discovery/Discovery.js";
11
11
  import { InstanceDiscovery } from "#behavior/system/controller/discovery/InstanceDiscovery.js";
12
12
  import { EndpointContainer } from "#endpoint/properties/EndpointContainer.js";
13
- import { CancelablePromise, Lifespan, Logger, Time } from "#general";
13
+ import { CancelablePromise, Duration, Logger, Minutes, Seconds, Time, Timestamp } from "#general";
14
14
  import { PeerAddress, PeerAddressStore } from "#protocol";
15
15
  import { ServerNodeStore } from "#storage/server/ServerNodeStore.js";
16
16
  import { ClientNode } from "../ClientNode.js";
@@ -20,8 +20,8 @@ import { NodePeerAddressStore } from "./NodePeerAddressStore.js";
20
20
 
21
21
  const logger = Logger.get("ClientNodes");
22
22
 
23
- const DEFAULT_TTL = 900 * 1000;
24
- const EXPIRATION_INTERVAL = 60 * 1000;
23
+ const DEFAULT_TTL = Minutes(15);
24
+ const EXPIRATION_INTERVAL = Minutes.one;
25
25
 
26
26
  /**
27
27
  * Manages the set of known remote nodes.
@@ -160,7 +160,7 @@ export class ClientNodes extends EndpointContainer<ClientNode> {
160
160
  }
161
161
 
162
162
  async #cullExpiredNodesAndAddresses() {
163
- const now = Time.nowMs();
163
+ const now = Time.nowMs;
164
164
 
165
165
  for (const node of this) {
166
166
  const state = node.state.commissioning;
@@ -243,11 +243,11 @@ class Factory extends ClientNodeFactory {
243
243
  }
244
244
  }
245
245
 
246
- function expirationOf<T extends Partial<Lifespan>>(
246
+ function expirationOf<T extends { discoveredAt?: Timestamp; ttl?: Duration | number }>(
247
247
  lifespan: T,
248
- ): T extends { discoveredAt: number } ? number : number | undefined {
248
+ ): T extends { discoveredAt: Timestamp } ? Timestamp : Timestamp | undefined {
249
249
  if (lifespan.discoveredAt !== undefined) {
250
- return lifespan.discoveredAt + (lifespan.ttl ?? DEFAULT_TTL);
250
+ return Timestamp(lifespan.discoveredAt + (Seconds(lifespan.ttl) ?? DEFAULT_TTL));
251
251
  }
252
- return undefined as unknown as number;
252
+ return undefined as unknown as Timestamp;
253
253
  }