-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.html
More file actions
4082 lines (4031 loc) · 189 KB
/
index.html
File metadata and controls
4082 lines (4031 loc) · 189 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Web Thing Protocol</title>
<script src="https://www.w3.org/Tools/respec/respec-w3c" class="remove" defer></script>
<script class="remove">
// All config options at https://respec.org/docs/
var respecConfig = {
specStatus: "CG-DRAFT",
editors: [{
name: "Ben Francis",
company: "Krellian",
mailto: "ben@krellian.com",
companyURL: "https://krellian.com",
w3cid: "51527"
}],
github: "w3c/web-thing-protocol",
shortName: "web-thing-protocol",
xref: true,
group: "web-thing-protocol",
wgPublicList: "public-web-thing-protocol",
edDraftURI: "https://w3c.github.io/web-thing-protocol/",
latestVersion: "https://w3c.github.io/web-thing-protocol/"
};
</script>
<style>
figure {
max-width: 450px;
margin: 0 auto !important;
}
</style>
</head>
<body>
<h1 id="title">Web Thing Protocol</h1>
<h2 id="subtitle">WebSocket Sub-protocol</h2>
<section id="abstract">
<p>This document defines a WebSocket sub-protocol called the Web Thing
Protocol, for monitoring and controlling connected devices over the
World Wide Web. The Web Thing Protocol is intended as a dedicated
real-time protocol for the <a href="https://www.w3.org/WoT/">Web of
Things</a>, to enable a WoT
<a href="https://www.w3.org/TR/wot-architecture/#dfn-consumer">Consumer</a>
to communicate with one or more WoT
<a href="https://www.w3.org/TR/wot-architecture/#dfn-web-thing">Things</a>
over a WebSocket connection.
</p>
</section>
<section id="sotd">
</section>
<section id="introduction" class="informative">
<h2>Introduction</h2>
<p>This document defines a WebSocket [[WEBSOCKETS-PROTOCOL]] sub-protocol for
monitoring and controlling connected devices over the Web.
</p>
<p>The <a href="https://www.w3.org/WoT/">Web of Things</a> (WoT) is a
collection of standardised technology building blocks that help provide
interoperability on the
<a href="https://en.wikipedia.org/wiki/Internet_of_things">Internet of
Things</a> (IoT). The WoT Thing Description specification
[[wot-thing-description11]] defines a metadata format for
<em>describing</em> the capabilities of "Things" (connected
devices) on the Web. The WoT Discovery specification [[wot-discovery]]
defines mechanisms for <em>discovering</em> Things on the Web. This
specification complements those building blocks by
defining a dedicated real-time protocol for <em>communicating</em> with Things over the
Web.
</p>
<p>WebSockets [[WEBSOCKETS-PROTOCOL]] provide a way to upgrade a
standard HTTP [[HTTP11]] request to a full-duplex, persistent, real-time
communication channel over a single TCP connection. This can be used to
create a versatile and efficient two-way channel with which a WoT
<a href="https://www.w3.org/TR/wot-architecture/#dfn-consumer">Consumer</a>
can communicate with one or more
<a href="https://www.w3.org/TR/wot-architecture/#dfn-web-thing">Things</a>
[[wot-architecture11]] to carry out the full set of WoT
<a href="https://www.w3.org/TR/wot-thing-description/#table-well-known-operation-types">operations</a>.
However, since a WebSocket is essentially just a raw TCP socket with no
semantics of its own, a sub-protocol needs to be defined in order for a
Consumer and Thing to communicate.
</p>
<p>Whilst many other <a href="https://www.iana.org/assignments/websocket/websocket.xml#subprotocol-name">WebSocket
sub-protocols</a> exist, what makes the Web Thing Protocol unique
is that it is specifically designed around the Web of Things
<a href="https://www.w3.org/TR/wot-thing-description11/#sec-vocabulary-definition">information
model</a> and
<a href="https://www.w3.org/TR/wot-thing-description11/#table-well-known-operation-types">set
of operations</a> [[wot-thing-description11]], as well as being
targeted specifically at Web of Things use cases [[wot-usecases]]. It
can therefore be thought of as being native to the Web of Things.
</p>
<p>
The sub-protocol defines message payload formats for each of the
well-known
<a href="https://www.w3.org/TR/wot-thing-description11/#table-well-known-operation-types">
operation types</a> defined in the WoT
<a href="https://www.w3.org/TR/wot-architecture/#sec-interaction-model">
interaction model</a> [[wot-architecture11]].
</p>
<p>
This specification is intended to complement deliverables of the
<a href="https://www.w3.org/WoT/wg/">WoT Working Group</a>, including WoT
Architecture [[wot-architecture11]], WoT Thing Description
[[wot-thing-description11]], WoT Discovery [[wot-discovery]],
WoT Binding Templates [[wot-binding-templates]] and WoT Profile
[[wot-profile]]. It is intended to implement use cases and requirements
defined in the
<a
href="https://www.w3.org/community/reports/web-thing-protocol/CG-FINAL-web-thing-protocol-requirements-20231101/">Web
Thing Protocol Use Cases & Requirements</a> community report.
</p>
<p>Whilst this document is not on a standards track, the Web Thing Protocol
is intended to eventually join a standards track at the W3C or another
standards body such as the IETF.
</p>
</section>
<section id="conformance">
</section>
<section id="terminology">
<h2>Terminology</h2>
<p>Fundamental WoT terminology such as <dfn>Thing</dfn> or <dfn>Web Thing</dfn>, <dfn>Consumer</dfn> or <dfn>WoT
Consumer</dfn>, WoT Thing Description or <dfn>Thing Description</dfn>, Interaction Model,
<dfn>Interaction Affordance</dfn>, <dfn>Property</dfn>, <dfn>Action</dfn> and <dfn>Event</dfn> are defined in
the
<a href="https://www.w3.org/TR/wot-architecture/#terminology">Terminology</a>
section of the WoT Architecture specification [[wot-architecture11]].
</p>
</section>
<section id="deployment-models" class="informative">
<h1>Deployment Models</h1>
<p>The Web Thing Protocol is intended to operate within three key deployment models depending on whether a Web Thing
is hosted by a connected device, by an on-premises Web of Things gateway, or an off-premises Web of Things cloud
service.</p>
<p>These three deployment models are common across a range of different application domains.</p>
<p>For a broader discussion of deployment models for the Web of Things in general, see <a
href="https://w3c.github.io/wot-architecture/#sec-common-deployment-patterns">Common Deployment Patterns</a> in
Web of Things (WoT) Architecture 1.1 [[wot-architecture11]].</p>
<section id="deployment-model-direct">
<h2>Direct</h2>
<p>The direct deployment model is when a Consumer communicates directly with an IoT device using the Web Thing
Protocol.</p>
<figure>
<img src="images/direct_deployment_model.png"
alt="A diagram showing a WoT Consumer directly communicating with a collection of connected devices using the Web Thing Protocol." />
<figcaption>Direct deployment model</figcaption>
</figure>
<p>In this deployment model, the IoT device itself must act as an HTTP and WebSockets server which serves its own
Thing Description and can maintain a WebSocket connection with a Consumer.</p>
</section>
<section id="deployment-model-gateway">
<h2>Gateway</h2>
<p>The gateway deployment model is when a Consumer communicates with a connected device via a gateway on the same
premises as the device, which bridges another protocol to the Web Thing Protocol.</p>
<figure>
<img src="images/gateway_deployment_model.png"
alt="A diagram showing a WoT Consumer communicating with a collection of Web Things via a Web of Things gateway using the Web Thing Protocol." />
<figcaption>Gateway deployment model</figcaption>
</figure>
<p>In this deployment model, a gateway acts as an HTTP and WebSockets server which exposes a Web Thing for a
connected device and translates WebSocket messages into messages of the device's native protocol (e.g. Zigbee,
Z-Wave, Matter, Modbus or BACnet) over a local area network (LAN) or personal area network (PAN).</p>
<p>A gateway can also act as a Consumer which consumes Web Things using the direct deployment model, and can be
used to proxy a Web Thing from one network to another.</p>
<figure>
<img src="images/gateway_deployment_model2.png"
alt="A diagram showing a WoT Consumer communicating with a Web of Things gateway using the Web Thing protocol and the gateway also communicating with a collection of connected devices using the Web Thing Protocol." />
<figcaption>Gateway deployment model with gateway also acting as a Consumer</figcaption>
</figure>
</section>
<section id="deployment-model-cloud">
<h2>Cloud</h2>
<p>The cloud deployment model is when a Consumer communicates with an IoT device via cloud service on the
internet, which communicates with the device using some other protocol on the back end.</p>
</section>
<figure>
<img src="images/cloud_deployment_model.png"
alt="A diagram showing a WoT Consumer communicating with a collection of connected devices via cloud service using the Web Thing Protocol." />
<figcaption>Cloud deployment model</figcaption>
</figure>
<p>In this deployment model, a cloud service hosted in a data centre acts as an HTTP and WebSockets server which
exposes a Web Thing for an IoT device and translates WebSocket messages into messages using another IoT protocol
(e.g. AMQP or MQTT).</p>
<p>The cloud deployment model differs from the gateway deployment model in that the Web Thing is hosted on different
premises to the IoT device it represents and communicates with the device over the internet.</p>
<p>A cloud service can also act as a Consumer which consumes Web Things that use the direct or gateway deployment
model, and can be used to proxy a Web Thing from one origin to another.</p>
<figure>
<img src="images/cloud_deployment_model2.png"
alt="A diagram showing a WoT Consumer communicating with a Web of Things cloud service using the Web Thing protocol and the cloud service also communicating with a collection of connected devices and a Web of Things Gateway using the Web Thing Protocol." />
<figcaption>Cloud deployment model with cloud service also acting as a Consumer</figcaption>
</figure>
</section>
<section id="websocket-connection">
<h2>WebSocket Connection</h2>
<section id="protocol-handshake">
<h3>Protocol Handshake</h3>
<p>In order to communicate with a <a>Web Thing</a>,
a WoT <a>Consumer</a> [[wot-architecture11]] MUST
locate one or more WebSocket [[WEBSOCKETS-PROTOCOL]] endpoints provided by the <a>Thing</a> for a given set of
<a>Interaction Affordances</a>
[[wot-thing-description11]].
</p>
<p>The URL of a WebSocket endpoint to be used for a given interaction MUST be obtained from a <a>Thing
Description</a>
[[wot-architecture11]] by locating a <a href="https://www.w3.org/TR/wot-thing-description/#form">Form</a> inside
the corresponding <a>Interaction Affordance</a> for which:
</p>
<ul>
<li>After being resolved against a <a
href="https://www.w3.org/TR/wot-thing-description/#td-vocab-base--Thing"><code>base</code></a> URL
[[wot-thing-description11]] where applicable, the URI scheme [[RFC3986]] of the value of its <a
href="https://www.w3.org/TR/wot-thing-description/#td-vocab-href--Form"><code>href</code></a> member
[[wot-thing-description11]] is <code>"ws"</code> or &<code>"wss"</code></li>
<li>Its <a
href="https://www.w3.org/TR/wot-thing-description/#td-vocab-subprotocol--Form"><code>subprotocol</code></a>
member has a value of <code>"webthingprotocol"</code></li>
</ul>
<p>To open a WebSocket on a Thing, an HTTP <a
href="https://httpwg.org/specs/rfc9110.html#GET"><code>GET</code></a> request [[RFC9110]] MUST be upgraded to
a WebSocket connection using a standard WebSocket <a
href="https://www.rfc-editor.org/rfc/rfc6455#page-6">protocol handshake</a> [[WEBSOCKETS-PROTOCOL]],
specifying the "webthingprotocol" sub-protocol.
</p>
<pre class="example" title="WebSocket Protocol Handshake HTTP Request">
GET wss://mythingserver.com/things/robot
Host: mythingserver.com
Origin: https://mythingserver.com
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: x3JJHMbDL1EzLkh9GBhXDw==
Sec-WebSocket-Protocol: webthingprotocol
Sec-WebSocket-Version: 13
</pre>
<pre class="example" title="WebSocket Protocol Handshake HTTP Response">
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Accept: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
Sec-WebSocket-Protocol: webthingprotocol
</pre>
<p class="ednote" title="Sub-protocol Name">
Sub-protocol name to be confirmed, see <a href="#iana-considerations">IANA Considerations</a>.
</p>
<p class="note">A WebSocket can be opened from a web page using the JavaScript WebSocket API [[WEBSOCKETS-API]]
which will take care of the handshake detailed above and allow messages to be sent and received.
</p>
<pre class="example" title="WebSocket Instantiation in JavaScript">
const socket = new WebSocket('wss://mywebthingserver/things/robot', 'webthingprotocol');
</pre>
</section>
<section id="websocket-reuse">
<h3>WebSocket Re-use</h3>
<p>A single WebSocket [[WEBSOCKETS-PROTOCOL]] connection from a <a>WoT Consumer</a> MAY be shared between multiple
<a>Interaction
Affordances</a> of a <a>Thing</a>. A single WebSocket connection from a <a>WoT Consumer</a> MAY also be shared
between multiple <a>Things</a>.
</p>
<p>Before opening a new WebSocket connection, a <a>WoT Consumer</a> SHOULD check whether it already has an open
connection to the same WebSocket endpoint URL.</p>
<p>If an existing connection to the same WebSocket endpoint URL exists, then that connection SHOULD be re-used
rather than opening an additional socket.</p>
<p>If an existing connection to the same WebSocket endpoint URL exists but is using a different set of credentials
for its given <a
href="https://www.w3.org/TR/wot-thing-description11/#securityscheme"><code>SecurityScheme</code></a>
[[wot-thing-description11]] (e.g. a different Bearer Token), then the <a>WoT Consumer</a> MUST NOT re-use the
connection.</p>
</section>
</section>
<section id="websocket-messages">
<h2>WebSocket Messages</h2>
<section id="message-format">
<h3>Message Format</h3>
<p>All messages MUST be a JSON <a href="https://www.rfc-editor.org/rfc/rfc8259#section-4">object</a> [[JSON]].</p>
<table id="common-members-table" class="def">
<caption>Common members of all messages</caption>
<thead>
<tr>
<th>Member</th>
<th>Type</th>
<th>Assignment</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>thingID</code></td>
<td>string</td>
<td>Mandatory</td>
<td>The ID (URI) of the <a>Thing</a> to which the message relates.</td>
</tr>
<tr>
<td><code>messageID</code></td>
<td>string</td>
<td>Mandatory</td>
<td>A unique identifier (UUID) for the current message.</td>
</tr>
<tr>
<td><code>messageType</code></td>
<td>string</td>
<td>Mandatory</td>
<td>A string which denotes the type of message (one of <code>request</code>, <code>response</code> or
<code>notification</code>).
</td>
</tr>
<tr>
<td><code>operation</code></td>
<td>string</td>
<td>Mandatory</td>
<td>A string which denotes the type of <a
href="https://www.w3.org/TR/wot-thing-description/#td-vocab-op--Form">WoT operation</a>
[[wot-thing-description11]] to which the message relates (one of
<code>readproperty</code>, <code>writeproperty</code>, <code>observeproperty</code>,
<code>unobserveproperty</code>, <code>invokeaction</code>, <code>queryaction</code>,
<code>cancelaction</code>, <code>subscribeevent</code>, <code>unsubscribeevent</code>,
<code>readallproperties</code>, <code>writeallproperties</code>, <code>readmultipleproperties</code>,
<code>writemultipleproperties</code>, <code>observeallproperties</code>,
<code>unobserveallproperties</code>, <code>subscribeallevents</code>, <code>unsubscribeallevents</code>,
or
<code>queryallactions</code>).
</tr>
<tr>
<td><code>correlationID</code></td>
<td>string</td>
<td>Optional</td>
<td>A unique identifer (UUID) which is shared between messages corresponding to the same operation, e.g. a
request and a response.</td>
</tr>
</tbody>
</table>
<p>The top level JSON object MUST contain a <code>thingID</code> member with the value set to a unique identifier
of
the <a>Web Thing</a> to which the message relates.
If the <a>Thing Description</a> of the <a>Web Thing</a> contains an <code>id</code> member then the value of
that
<code>id</code> member MUST be used as the unique identifier assigned to <code>thingID</code>.
If the <a>Thing Description</a> of the <a>Web Thing</a> does not contain an <code>id</code> member then the URL
[[URL]] from which the <a>Thing Description</a> was retrieved MAY be used as the <code>thingID</code> value
instead. The value of the <code>thingID</code> member MUST be a valid URI [[URI]] serialised as a string.
</p>
<p>The top level JSON object MUST contain a <code>messageID</code> member with the value set to a unique
identifier
for the current message in UUIDv4 format [[rfc9562]].</p>
<p>The top level JSON object MUST contain a <code>messageType</code> member, with its value set to one of
<code>request</code>, <code>response</code> or <code>notification</code>.
</p>
<table id="message-types-table" class="def">
<caption>Message types</caption>
<thead>
<tr>
<th>Message type</th>
<th>Direction</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>request</code></td>
<td>Consumer ➡ Thing</td>
<td>A message sent from a Consumer to a Thing (e.g. to request a reading of a property, invoke an
action or subscribe to an event)</td>
</tr>
<tr>
<td><code>response</code></td>
<td>Thing ➡ Consumer</td>
<td>A message sent from a Thing to a Consumer in response to a request (e.g. to respond with a property
reading, provide the final response to an action or confirm a subscription to an event)</td>
</tr>
<tr>
<td><code>notification</code></td>
<td>Thing ➡ Consumer</td>
<td>A message pushed from a Thing to a Consumer (e.g. an event or change in property value)</td>
</tr>
</tbody>
</table>
<p>The top level JSON object MUST contain an <code>operation</code> member, with its value set to one of the
well-known <a href="https://www.w3.org/TR/wot-thing-description/#td-vocab-op--Form">WoT operation</a> names from
the Thing Description specification [[wot-thing-description11]].</p>
<p>The top level JSON object MAY contain a <code>correlationID</code> member which provides a unique identifier in
UUIDv4 format [[rfc9562]] which is shared between messages corresponding to the same WoT operation (e.g. a
property read request and response, or an event subscription request and event notification). If a request
message
contains a <code>correlatonID</code> member then any response and notification messages which correspond to the
same operation MUST also include a <code>correlationID</code> member with the same value.</p>
<p>All date and time values MUST use the <code>date-time</code> format
defined in [[RFC3339]].
</p>
<pre class="example" title="Example timestamp">
<code>2025-01-15T12:08:00.42Z</code>
</pre>
<p class="note">
In order to reduce ambiguity, RFC 3339 only permits an hour with a value
between 00 and 23 (not 24), and time zones expressed as a numerical
offset relative to UTC. The suffix "Z" when applied to a time denotes a
UTC offset of 00:00.
</p>
</section>
<section id="operation-lifecycles">
<h3>Operation Lifecycles</h3>
<p>The lifecycle of an operation consists of a series of messages in a sequence (e.g. a request followed by a
response, or a request followed by a response then one or more notifications). Each type of operation follows a
particular sequence of message types, outlined in the table below:</p>
<table id="operation-lifecycles-table" class="def">
<caption>Operation lifecycles</caption>
<thead>
<tr>
<th>Operation</th>
<th>Lifecycle</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="#readproperty"><code>readproperty</code></a></td>
<td><a href="#readproperty-request">request</a>, <a href="#readproperty-response">response</a></td>
</tr>
<tr>
<td><a href="#writeproperty"><code>writeproperty</code></a></td>
<td><a href="#writeproperty-request">request</a>, <a href="#writeproperty-response">response</a></td>
</tr>
<tr>
<td><a href="#readallproperties"><code>readallproperties</code></a></td>
<td><a href="#readallproperties-request">request</a>, <a href="#readallproperties-response">response</a>
</td>
</tr>
<tr>
<td><a href="#readmultipleproperties"><code>readmultipleproperties</code></a></td>
<td><a href="#readmultipleproperties-request">request</a>, <a
href="#readmultipleproperties-response">response</a></td>
</tr>
<tr>
<td><a href="#writeallproperties"><code>writeallproperties</code></a></td>
<td><a href="#writeallproperties-request">request</a>,
<a href="#writeallproperties-response">response</a>
</td>
</tr>
<tr>
<td><a href="#writemultipleproperties"><code>writemultipleproperties</code></a></td>
<td><a href="#writemultipleproperties-request">request</a>,
<a href="#writemultipleproperties-response">response</a>
</td>
</tr>
<tr>
<td><a href="#observeproperty"><code>observeproperty</code></a></td>
<td><a href="#observeproperty-request">request</a>,
<a href="#observeproperty-response">response</a>,
<a href="#observeproperty-notification">notification</a>,
<a href="#observeproperty-notification">notification</a>...
</td>
</tr>
<tr>
<td><a href="#unobserveproperty"><code>unobserveproperty</code></a></td>
<td><a href="#unobserveproperty-request">request</a>, <a href="#unobserveproperty-response">response</a>
</td>
</tr>
<tr>
<td><a href="#observeallproperties"><code>observeallproperties</code></a></td>
<td><a href="#observeallproperties-request">request</a>,
<a href="#observeallproperties-response">response</a>,
<a href="#observeallproperties-notification">notification</a>,
<a href="#observeallproperties-notification">notification</a>...
</td>
</tr>
<tr>
<td><a href="#unobserveallproperties"><code>unobserveallproperties</code></a></td>
<td><a href="#unobserveallproperties-request">request</a>,
<a href="#unobserveallproperties-response">response</a>
</td>
</tr>
<tr>
<td><a href="#invokeaction"><code>invokeaction</code></a></td>
<td><a href="#invokeaction-request">request</a>, <a href="#invokeaction-response">response</a>
</td>
</tr>
<tr>
<td><a href="#queryaction"><code>queryaction</code></a></td>
<td><a href="#queryaction-request">request</a>, <a href="#queryaction-response">response</a>
</td>
</tr>
<tr>
<td><a href="#queryallactions"><code>queryallactions</code></a></td>
<td><a href="#queryallactions-request">request</a>, <a href="#queryallactions-response">response</a>
</td>
</tr>
<tr>
<td><a href="#cancelaction"><code>cancelaction</code></a></td>
<td><a href="#cancelaction-request">request</a>, <a href="#cancelaction-response">response</a>
</td>
</tr>
<tr>
<td><a href="#subscribeevent"><code>subscribeevent</code></a></td>
<td><a href="#subscribeevent-request">request</a>,
<a href="#subscribeevent-response">response</a>,
<a href="#subscribeevent-notification">notification</a>,
<a href="#subscribeevent-notification">notification</a>...
</td>
</tr>
<tr>
<td><a href="#unsubscribeevent"><code>unsubscribeevent</code></a></td>
<td><a href="#unsubscribeevent-request">request</a>, <a href="#unsubscribeevent-response">response</a></td>
</tr>
<tr>
<td><a href="#subscribeallevents"><code>subscribeallevents</code></a></td>
<td><a href="#subscribeallevents-request">request</a>,
<a href="#subscribeallevents-response">response</a>,
<a href="#subscribeallevents-notification">notification</a>,
<a href="#subscribeallevents-notification">notification</a>...
</td>
</tr>
<tr>
<td><a href="#unsubscribeallevents"><code>unsubscribeallevents</code></a></td>
<td><a href="#unsubscribeallevents-request">request</a>,
<a href="#unsubscribeallevents-response">response</a>
</tr>
</tbody>
</table>
</section>
<section id="property-operations">
<h3>Property Operations</h3>
<section id="readproperty">
<h4><code>readproperty</code></h4>
<section id="readproperty-request">
<h5>Request</h5>
<p>To request a property reading from a <a>Thing</a>, a <a>Consumer</a> MUST send a <a
href="#websocket-messages">message</a> to the <a>Thing</a>
which contains the following members:</p>
<table class="def">
<caption>Members of a <code>readproperty</code> request message</caption>
<thead>
<tr>
<th>Member</th>
<th>Type</th>
<th>Assignment</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>messageType</code></td>
<td>string</td>
<td>"request"</td>
<td>A string which denotes that this message is a request sent from a Consumer to a Thing.</td>
</tr>
<tr>
<td><code>operation</code></td>
<td>string</td>
<td>"readproperty"</td>
<td>A string which denotes that this message relates to a <code>readproperty</code> operation.</td>
</tr>
<tr>
<td><code>name</code></td>
<td>string</td>
<td>Mandatory</td>
<td>The name of the <a>Property</a> to read, as per its key in the <code>properties</code> member of
the <a>Thing Description</a>.
</td>
</tr>
</tbody>
</table>
<pre class="example" title="readproperty request message">
{
"thingID": "https://mythingserver.com/things/mylamp1",
"messageID": "c370da58-69ae-4e83-bb5a-ac6cfb2fed54",
"messageType": "request",
"operation": "readproperty",
"name": "on",
"correlationID": "5afb752f-8be0-4a3c-8108-1327a6009cbd"
}
</pre>
<p>When a <a>Thing</a> receives a message from a <a>Consumer</a> with <code>messageType</code> set to
<code>request</code> and <code>operation</code> set to <code>readproperty</code> it MUST
attempt to read the value of the <a>Property</a> with the given <code>name</code>.
</p>
</section>
<section id="readproperty-response">
<h5>Response</h5>
<p>Upon successfully reading the value of the requested <a>Property</a>, the Thing MUST send a message to the
requesting <code>Consumer</code> containing the following members:</p>
<table class="def">
<caption>Members of a <code>readproperty</code> response message</caption>
<thead>
<tr>
<th>Member</th>
<th>Type</th>
<th>Assignment</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>messageType</code></td>
<td>string</td>
<td>"response"</td>
<td>A string which denotes that this message is a response sent from a <a>Thing</a> to a
<a>Consumer</a>.
</td>
</tr>
<tr>
<td><code>operation</code></td>
<td>string</td>
<td>"readproperty"</td>
<td>A string which denotes that this message relates to a <code>readproperty</code> operation.
</td>
</tr>
<tr>
<td><code>name</code></td>
<td>string</td>
<td>Mandatory</td>
<td>The name of the <a>Property</a> being read, as per its key in the <code>properties</code> member of
the
<a>Thing Description</a>.
</td>
</tr>
<tr>
<td><code>value</code></td>
<td>any</td>
<td>Mandatory</td>
<td>The current value of the <a>Property</a> being read, with a type and structure conforming to the
data
schema of the corresponding PropertyAffordance in the <a>Thing Description</a>.</td>
</tr>
<tr>
<td><code>timestamp</code></td>
<td>string</td>
<td>Optional</td>
<td>A timestamp in date-time format [[RFC3339]] set to the time the property reading took place.</td>
</tr>
</tbody>
</table>
<pre class="example" title="readproperty response message">
{
"thingID": "https://mythingserver.com/things/mylamp1",
"messageID": "79057736-3e0e-4dc3-b139-a33051901ee2",
"messageType": "response",
"operation": "readproperty",
"name": "on",
"value": true,
"timestamp": "2024-01-13T23:20:50.52Z",
"correlationID": "5afb752f-8be0-4a3c-8108-1327a6009cbd"
}
</pre>
</section>
</section>
<section id="writeproperty">
<h4><code>writeproperty</code></h4>
<section id="writeproperty-request">
<h5>Request</h5>
<p>To set the value of a <a>Property</a> of a <a>Thing</a>, a <a>Consumer</a> MUST send a <a
href="#websocket-messages">message</a> to the <a>Thing</a> which contains the following members:</p>
<table class="def">
<caption>Members of a <code>writeproperty</code> request message</caption>
<thead>
<tr>
<th>Member</th>
<th>Type</th>
<th>Assignment</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>messageType</code></td>
<td>string</td>
<td>"request"</td>
<td>A string which denotes that this message is a request sent from a Consumer to a Thing.</td>
</tr>
<tr>
<td><code>operation</code></td>
<td>string</td>
<td>"writeproperty"</td>
<td>A string which denotes that this message relates to a <code>writeproperty</code> operation.</td>
</tr>
<tr>
<td><code>name</code></td>
<td>string</td>
<td>Mandatory</td>
<td>The name of the <a>Property</a> whose value should be set, as per its key in the
<code>properties</code> member of the <a>Thing Description</a>.
</td>
</tr>
<tr>
<td><code>value</code></td>
<td>any</td>
<td>Mandatory</td>
<td>The desired new value of the <a>Property</a>, with a type and structure conforming to the data
schema
of the corresponding PropertyAffordance in the <a>Thing Description</a>.</td>
</tr>
</tbody>
</table>
<pre class="example" title="writeproperty request message">
{
"thingID": "https://mythingserver.com/things/mylamp1",
"messageID": "97d22676-6d45-4435-aef5-dd87467a0c44",
"messageType": "response",
"operation": "writeproperty",
"name": "on",
"value": true,
"correlationID": "f6cf46a8-9c96-437e-8b53-925b7679a990"
}
</pre>
</section>
<section id="writeproperty-response">
<h5>Response</h5>
<p>When a <a>Thing</a> receives a message from a <a>Consumer</a> with <code>messageType</code> set to
<code>request</code> and <code>operation</code> set to <code>writeproperty</code> it MUST
attempt to set the <a>Property</a> with the name provided in the <code>name</code> member to
the value provided in the <code>value</code> member.
</p>
<p>Upon successfully submitting the value of the requested <a>Property</a>, the Thing MUST send a message to
the
requesting <code>Consumer</code> containing the following members:</p>
<table class="def">
<caption>Members of a <code>writeproperty</code> response message</caption>
<thead>
<tr>
<th>Member</th>
<th>Type</th>
<th>Assignment</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>messageType</code></td>
<td>string</td>
<td>"response"</td>
<td>A string which denotes that this message is a response sent from a <a>Thing</a> to a
<a>Consumer</a>.
</td>
</tr>
<tr>
<td><code>operation</code></td>
<td>string</td>
<td>"writeproperty"</td>
<td>A string which denotes that this message relates to a <code>writeproperty</code> operation.
</td>
</tr>
<tr>
<td><code>name</code></td>
<td>string</td>
<td>Mandatory</td>
<td>The name of the <a>Property</a> being written, as per its key in the <code>properties</code> member
of
the
<a>Thing Description</a>.
</td>
</tr>
<tr>
<td><code>value</code></td>
<td>any</td>
<td>Optional</td>
<td>The value which has been successfully assigned to the <a>Property</a> being written, with a type and
structure conforming to the data schema of the corresponding PropertyAffordance in the <a>Thing
Description</a>.
</td>
</tr>
<tr>
<td><code>timestamp</code></td>
<td>string</td>
<td>Optional</td>
<td>A timestamp in date-time format [[RFC3339]] set to the time the property write took place.</td>
</tr>
</tbody>
</table>
<pre class="example" title="writeproperty response message">
{
"thingID": "https://mythingserver.com/things/mylamp1",
"messageID": "db25fe4f-bee8-43a7-8ff0-3a1ff6e620b0",
"messageType": "response",
"operation": "writeproperty",
"name": "on",
"value": true,
"timestamp": "2024-01-13T23:20:50.52Z",
"correlationID": "f6cf46a8-9c96-437e-8b53-925b7679a990"
}
</pre>
<p>If the <a>Thing</a> can confirm that the requested value has been set successfully then the response
message
to a <code>writeproperty</code> request SHOULD contain a <code>value</code> member with its value set to the
value which has been successfully set.
</p>
<p>If the <a>Thing</a> can not confirm that the requested value has been set successfully (e.g. in the case of
a
write-only property or a device that is temporarily asleep so the write has been queued) then
the response message to a <code>writeproperty</code> request MUST NOT contain a
<code>value</code> member.
</p>
<p>If a Consumer attempts to set the value of a numerical <a>Property</a> to a value which conforms to the
<a>Property</a>'s data schema but to a level of precision the Thing does not support, (e.g. 3.14159), then
the
<a>Thing</a> MAY respond with the actual value set (e.g. 3.14).
</p>
</section>
</section>
<section id="readallproperties">
<h4><code>readallproperties</code></h4>
<section id="readallproperties-request">
<h5>Request</h5>
<p>To request a reading of all of a <a>Thing</a>'s readable <a>Properties</a> at once, a <a>Consumer</a> MUST
send a <a href="#websocket-messages">message</a> to the <a>Thing</a>
which contains the following members:</p>
<table class="def">
<caption>Members of a <code>readallproperties</code> request message</caption>
<thead>
<tr>
<th>Member</th>
<th>Type</th>
<th>Assignment</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>messageType</code></td>
<td>string</td>
<td>"request"</td>
<td>A string which denotes that this message is a request sent from a Consumer to a Thing.</td>
</tr>
<tr>
<td><code>operation</code></td>
<td>string</td>
<td>"readallproperties"</td>
<td>A string which denotes that this message relates to a <code>readallproperties</code> operation.</td>
</tr>
</tbody>
</table>
<pre class="example" title="readallproperties request message">
{
"thingID": "https://mythingserver.com/things/mylamp1",
"messageID": "e144349c-5cd7-4002-938f-aac5adf99789",
"messageType": "request",
"operation": "readallproperties",
"correlationID": "c08075a4-d53c-4f51-b251-a6b6922c2b1f"
}
</pre>
<p>When a <a>Thing</a> receives a message from a <a>Consumer</a> with <code>messageType</code> set to
<code>request</code> and <code>operation</code> set to <code>readallproperties</code> it MUST
attempt to read the value of all of its readable <a>Properties</a> (i.e. all
<a href="https://www.w3.org/TR/wot-thing-description/#propertyaffordance">Property Affordances</a> where
<a
href="https://www.w3.org/TR/wot-thing-description/#td-vocab-writeOnly--DataSchema"><code>writeOnly</code></a>
[[wot-thing-description11]] is not set to <code>true</code>).
</p>
</section>
<section id="readallproperties-response">
<h5>Response</h5>
<p>Upon successfully reading the value of all of its readable <a>Properties</a>, the Thing MUST send a message
to the requesting <a>Consumer</a> containing the following members:</p>
<table class="def">
<caption>Members of a <code>readallproperties</code> response message</caption>
<thead>
<tr>
<th>Member</th>
<th>Type</th>
<th>Assignment</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>messageType</code></td>
<td>string</td>
<td>"response"</td>
<td>A string which denotes that this message is a response sent from a <a>Thing</a> to a
<a>Consumer</a>.
</td>
</tr>
<tr>
<td><code>operation</code></td>
<td>string</td>
<td>"readallproperties"</td>
<td>A string which denotes that this message relates to a <code>readallproperties</code> operation.
</td>
</tr>
<tr>
<td><code>values</code></td>
<td>object</td>
<td>Mandatory</td>
<td>The values of all <a>Properties</a> contained in an object keyed by <a>Property</a> name, with the
value of each <a>Property</a> conforming to the data schema of the corresponding PropertyAffordance in
the <a>Thing Description</a>.</td>
</tr>
<tr>
<td><code>timestamp</code></td>
<td>string</td>
<td>Optional</td>
<td>A timestamp in date-time format [[RFC3339]] set to the time the property readings took place.</td>
</tr>
</tbody>
</table>
<pre class="example" title="readallproperties response message">
{
"thingID": "https://mythingserver.com/things/mylamp1",
"messageID": "79057736-3e0e-4dc3-b139-a33051901ee2",
"messageType": "response",
"operation": "readallproperties",
"values": {
"on": true,
"level": 50
},
"timestamp": "2025-05-22T17:15:35.636Z",
"correlationID": "c08075a4-d53c-4f51-b251-a6b6922c2b1f"
}
</pre>
</section>
<section id="readallproperties-error-response">
<h5>Error Response</h5>
<p>If a <a>Thing</a> receives a <code>readallproperties</code> request message from a <a>Consumer</a>
but the reading of at least one of the properties unexpectedly fails, then it MUST send an
<a href="#error-response">error response</a> to the <a>Consumer</a> with <code>status</code> set to
<code>500</code>.
</p>
<pre class="example" title="Example readallproperties Internal Server Error error response message">
<code>
{
"thingID": "https://mythingserver.com/things/mylamp1",
"messageID": "1876e481-5fc2-4b39-93b4-1f434f7b6a47",
"messageType": "response",
"operation": "readallproperties",
"error": {
"status": 500,
"type": "https://w3c.github.io/web-thing-protocol/errors#500",
"title": "Internal Server Error"
"detail": "Reading the 'level' property unexpectedly failed"
}
"timestamp": "2025-05-22T17:15:36.636Z",
"correlationID": "c08075a4-d53c-4f51-b251-a6b6922c2b1f"
}
</code>
</pre>
<p>If a <code>readallproperties</code> operation only partially fails (i.e. some <a>Properties</a> can be
read but others can not), a <a>Thing</a> MAY include the successfully read values in the error
response, in a <code>values</code> member keyed by <a>Property</a> name.
</p>
</section>
</section>
<section id="readmultipleproperties">
<h4><code>readmultipleproperties</code></h4>
<section id="readmultipleproperties-request">
<h5>Request</h5>
<p>To request a reading of multiple readable <a>Properties</a> of a <a>Thing</a> at once, a <a>Consumer</a>
MUST
send a
<a href="#websocket-messages">message</a> to the <a>Thing</a> which contains the following members:
</p>
<table class="def">
<caption>Members of a <code>readmultipleproperties</code> request message</caption>
<thead>
<tr>
<th>Member</th>
<th>Type</th>
<th>Assignment</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>messageType</code></td>
<td>string</td>
<td>"request"</td>
<td>A string which denotes that this message is a request sent from a Consumer to a Thing.</td>
</tr>
<tr>
<td><code>operation</code></td>
<td>string</td>
<td>"readmultipleproperties"</td>
<td>A string which denotes that this message relates to a <code>readmultipleproperties</code> operation.
</td>
</tr>
<tr>
<td><code>names</code></td>
<td>array</td>
<td>Mandatory</td>
<td>An array of strings specifying the names of the <a>Properties</a> to read, as per their keys in the
<code>properties</code> member of the <a>Thing Description</a>.
</tr>
</tbody>
</table>
<pre class="example" title="readmultipleproperties request message">