Amazon Alexa

来自Jack's Lab
(版本间的差异)
跳转到: 导航, 搜索
(Turn Off)
 
(未显示1个用户的9个中间版本)
第1行: 第1行:
## Alexa discover process
+
== Alexa discover process ==
  
 
Send UDP to: 239.255.255.250:1900
 
Send UDP to: 239.255.255.250:1900
第22行: 第22行:
  
  
*Device response:*
+
'''Device response:'''
  
*ST* must be same as the received packet
+
'''ST''' must be same as the received packet
  
 
<source lang=http>
 
<source lang=http>
第39行: 第39行:
 
Then Alexa send HTTP GET request to http://192.168.1.64:80/setup.xml:
 
Then Alexa send HTTP GET request to http://192.168.1.64:80/setup.xml:
  
```http
+
<source lang=bash>
 
GET /setup.xml HTTP/1.1
 
GET /setup.xml HTTP/1.1
 
Host: 192.168.1.81
 
Host: 192.168.1.81
 
Accept: */*
 
Accept: */*
```
+
</source>
  
  
第51行: 第51行:
 
     GET /setup.xml
 
     GET /setup.xml
  
 +
<br><br>
  
## WEMO
+
== WEMO ==
  
### Turn On
+
=== Turn On ===
  
```http
+
<source lang=xml>
 
POST /upnp/control/basicevent1 HTTP/1.1
 
POST /upnp/control/basicevent1 HTTP/1.1
 
Host: 192.168.1.69
 
Host: 192.168.1.69
第65行: 第66行:
  
 
<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1"><BinaryState>1</BinaryState></u:SetBinaryState></s:Body></s:Envelope>
 
<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1"><BinaryState>1</BinaryState></u:SetBinaryState></s:Body></s:Envelope>
```
+
</source>
 +
 
  
### Turn Off  
+
=== Turn Off ===
  
```http
+
<source lang=xml>
 
POST /upnp/control/basicevent1 HTTP/1.1
 
POST /upnp/control/basicevent1 HTTP/1.1
 
Host: 192.168.1.69
 
Host: 192.168.1.69
第78行: 第80行:
  
 
<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1"><BinaryState>0</BinaryState></u:SetBinaryState></s:Body></s:Envelope>
 
<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1"><BinaryState>0</BinaryState></u:SetBinaryState></s:Body></s:Envelope>
```
+
</source>
  
### Change Name
+
=== Change Name ===
  
```http
+
<source lang=xml>
 
POST /upnp/control/basicevent1 HTTP/1.1
 
POST /upnp/control/basicevent1 HTTP/1.1
 
Host: 192.168.1.69
 
Host: 192.168.1.69
第91行: 第93行:
  
 
<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><m:ChangeFriendlyName xmlns:m="urn:Belkin:service:basicevent:1"><FriendlyName>My Switch</FriendlyName></m:ChangeFriendlyName></s:Body></s:Envelope>
 
<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><m:ChangeFriendlyName xmlns:m="urn:Belkin:service:basicevent:1"><FriendlyName>My Switch</FriendlyName></m:ChangeFriendlyName></s:Body></s:Envelope>
```
+
</source>
  
  
第100行: 第102行:
 
TCP listen on port 49153
 
TCP listen on port 49153
  
 +
<br><br>
  
## HUE
+
== HUE ==
  
*setup.xml*
+
;;setup.xml
  
```xml
+
<source lang=xml>
<root>
+
<root><device>
<device>
+
 
<deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>
 
<deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>
 
<friendlyName>Philips hue (%s)</friendlyName>
 
<friendlyName>Philips hue (%s)</friendlyName>
第119行: 第121行:
 
<presentationURL>index.html</presentationURL>
 
<presentationURL>index.html</presentationURL>
 
</device></root>
 
</device></root>
```
+
</source>
  
```http
+
<source lang=xml>
 
GET /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights HTTP/1.1
 
GET /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights HTTP/1.1
 
Host: 192.168.1.64
 
Host: 192.168.1.64
 
Accept: */*
 
Accept: */*
```
+
</source>
  
```http
+
 
 +
<source lang=xml>
 
GET /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur HTTP/1.1
 
GET /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur HTTP/1.1
 
Host: 192.168.1.64
 
Host: 192.168.1.64
 
Accept: */*
 
Accept: */*
```
+
</source>
  
  
### Dim to 30%
+
=== Dim to 30% ===
  
```http
+
<source lang=bash>
 
PUT /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights/0/state HTTP/1.1
 
PUT /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights/0/state HTTP/1.1
 
Host: 192.168.1.53
 
Host: 192.168.1.53
第144行: 第147行:
  
 
{"on": true,"bri":76}
 
{"on": true,"bri":76}
```
+
</source>
  
### bright to 50%
 
  
*Request:*
+
=== bright to 50% ===
  
```http
+
;;Request:
 +
 
 +
<source lang=bash>
 
PUT /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights/0/state HTTP/1.1
 
PUT /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights/0/state HTTP/1.1
 
Host: 192.168.1.53
 
Host: 192.168.1.53
第158行: 第162行:
  
 
{"on": true,"bri":127}
 
{"on": true,"bri":127}
```
+
</source>
  
  
*Response:*
+
;;Response:
  
```http
+
<source lang=bash>
 
HTTP/1.1 200 OK
 
HTTP/1.1 200 OK
 
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
 
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
第169行: 第173行:
  
 
[{"success": {"on": true}}, {"success": {"bri": 255}}]
 
[{"success": {"on": true}}, {"success": {"bri": 255}}]
```
+
</source>
  
  
### Turn on
+
=== Turn On ===
  
*Request:*
+
;;Request:
  
```http
+
<source lang=bash>
 
PUT /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights/0/state HTTP/1.1
 
PUT /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights/0/state HTTP/1.1
 
Host: 192.168.1.53
 
Host: 192.168.1.53
第184行: 第188行:
  
 
{"on": true}
 
{"on": true}
```
+
</source>
  
  
```http
+
=== Turn Off ===
 +
 
 +
;;Request:
 +
 
 +
<source lang=bash>
 
PUT /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights/0/state HTTP/1.1
 
PUT /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights/0/state HTTP/1.1
 
Host: 192.168.1.53
 
Host: 192.168.1.53
第195行: 第203行:
  
 
{"on": false}
 
{"on": false}
```
+
</source>
 +
 
 +
<br><br>
 +
 
 +
== Reference ==
 +
 
 +
* [[Upnp]]
 +
 
 +
<br><br><br><br>

2019年1月31日 (四) 20:55的最后版本

目录

[编辑] 1 Alexa discover process

Send UDP to: 239.255.255.250:1900

Alexa send UDP packet when 'discover devices':

M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 15
ST: urn:schemas-upnp-org:device:basic:1
M-SEARCH * HTTP/1.1
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
MX: 15
ST: urn:Belkin:device:**


Device response:

ST must be same as the received packet

HTTP/1.1 200 OK
EXT:
CACHE-CONTROL: max-age=86400
SERVER: Noduino/1.0 UPNP/1.1 OpenLight Controller/1.0
USN: uuid:38323636-4558-4dda-9188-cda0115b5050
ST: urn:Belkin:device:**
LOCATION: http://192.168.1.64:80/setup.xml


Then Alexa send HTTP GET request to http://192.168.1.64:80/setup.xml:

GET /setup.xml HTTP/1.1
Host: 192.168.1.81
Accept: */*


Device need to implement:

   GET /
   GET /setup.xml



[编辑] 2 WEMO

[编辑] 2.1 Turn On

POST /upnp/control/basicevent1 HTTP/1.1
Host: 192.168.1.69
Accept: */*
Content-type: text/xml; charset="utf-8"
SOAPACTION: "urn:Belkin:service:basicevent:1#SetBinaryState"
Content-Length: 299

<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1"><BinaryState>1</BinaryState></u:SetBinaryState></s:Body></s:Envelope>


[编辑] 2.2 Turn Off

POST /upnp/control/basicevent1 HTTP/1.1
Host: 192.168.1.69
Accept: */*
Content-type: text/xml; charset="utf-8"
SOAPACTION: "urn:Belkin:service:basicevent:1#SetBinaryState"
Content-Length: 299

<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><u:SetBinaryState xmlns:u="urn:Belkin:service:basicevent:1"><BinaryState>0</BinaryState></u:SetBinaryState></s:Body></s:Envelope>

[编辑] 2.3 Change Name

POST /upnp/control/basicevent1 HTTP/1.1
Host: 192.168.1.69
Accept: */*
Content-type: text/xml; charset="utf-8"
SOAPACTION: "urn:Belkin:service:basicevent:1#ChangeFriendlyName"
Content-Length: 299

<?xml version="1.0" encoding="utf-8"?><s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body><m:ChangeFriendlyName xmlns:m="urn:Belkin:service:basicevent:1"><FriendlyName>My Switch</FriendlyName></m:ChangeFriendlyName></s:Body></s:Envelope>


It is the address and port specified by the UPnP protocol. Only one such listener is needed since it can send multiple responses, one for each switch, in response to a search request.

TCP listen on port 49153



[编辑] 3 HUE

setup.xml
<root><device>
<deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>
<friendlyName>Philips hue (%s)</friendlyName>
<manufacturer>Royal Philips Electronics</manufacturer>		<------- key
<manufacturerURL>http://www.philips.com</manufacturerURL>
<modelName>Philips hue bridge 2012</modelName>				<------- it's also the key
<modelNumber>929000226503</modelNumber>
<modelURL>http://www.meethue.com</modelURL>
<serialNumber>001788102201</serialNumber>
<UDN>uuid:2f402f80-da50-11e1-9b23-001788102201</UDN>
<presentationURL>index.html</presentationURL>
</device></root>
GET /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights HTTP/1.1
Host: 192.168.1.64
Accept: */*


GET /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur HTTP/1.1
Host: 192.168.1.64
Accept: */*


[编辑] 3.1 Dim to 30%

PUT /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights/0/state HTTP/1.1
Host: 192.168.1.53
Accept: */*
Content-type: application/x-www-form-urlencoded
Content-Length: 21

{"on": true,"bri":76}


[编辑] 3.2 bright to 50%

Request
PUT /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights/0/state HTTP/1.1
Host: 192.168.1.53
Accept: */*
Content-type: application/x-www-form-urlencoded
Content-Length: 22

{"on": true,"bri":127}


Response
HTTP/1.1 200 OK
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Content-type: application/json

[{"success": {"on": true}}, {"success": {"bri": 255}}]


[编辑] 3.3 Turn On

Request
PUT /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights/0/state HTTP/1.1
Host: 192.168.1.53
Accept: */*
Content-type: application/x-www-form-urlencoded
Content-Length: 12

{"on": true}


[编辑] 3.4 Turn Off

Request
PUT /api/h632JhAtwDezSwGk3VKEeFn4snXZUjro9OoEvdur/lights/0/state HTTP/1.1
Host: 192.168.1.53
Accept: */*
Content-type: application/x-www-form-urlencoded
Content-Length: 13

{"on": false}



[编辑] 4 Reference





个人工具
名字空间

变换
操作
导航
工具箱