æã家ã®ç §æã¯ããªã¢ã³ã³ã§æä½ã§ããã ãªã®ã§ãNature Remoããããã¡ããæä½ã§ããã®ã ãããªã¢ã³ã³ã«ãããã¿ã³ã¯ON/OFFãåãæ¿ãããã¿ã³ãããªãã ãã®ãããæ示çã«ONã«ããããOFFã«ããããããã¨ã¯ã§ããªãã ããããåãã¡ã¼ã«ã¼ã®ä»ã®ç §æãªã¢ã³ã³ãè¦ã¦ã¿ãã¨ONã®ãã¿ã³ã¨OFFã®ãã¿ã³ãåå¨ãã¦ããã ããã¯æ¨æ¸¬ã ãããããããããã³ã«ä¸ãå®è£ ä¸åå¨ãã¦ããããå»ä¾¡ãªã¢ãã«ã®ãªã¢ã³ã³ã®ããçç¥ããã¦ããã¨èããããã ããã§ãNature Remoã®APIãé§ä½¿ããç©ççã«åå¨ããªããããããã³ã«ä¸ãå®è£ ä¸åå¨ãã¦ããã¨èããããONãã¿ã³ã¨OFFãã¿ã³ã調æ»ããNature Remoããç §æã®ONã¨OFFãæä½ã§ããããã«ããã

Nature Remoã®IPã¢ãã¬ã¹ã調ã¹ã
IPã¢ãã¬ã¹ãããããªãã¨ãLocal APIãå©ããªãã®ã§èª¿ã¹ãã
ã¾ããNature Remoã¨åããããã¯ã¼ã¯(LAN)ã«ã¤ãªãã
ã¤ãã«ãmDNSã§ãµã¼ãã¹ã¿ã¤ããããã¤ã³ã¹ã¿ã³ã¹åãå¼ãã
$ dns-sd -B _remo._tcp
Browsing for _remo._tcp
DATE: ---Sat 12 Jan 2019---
13:33:50.261 ...STARTING...
Timestamp A/R Flags if Domain Service Type Instance Name
13:33:50.413 Add 3 5 local. _remo._tcp. Remo-4A8BDD
13:33:50.413 Add 2 5 local. _remo._tcp. Remo-9086AB
ãªãã³ã°ã«ã¼ã ã¨ãã¤ãã³ã°ã«ã¼ã ã®Nature Remoãè¦ã¤ããããã
æå¾ã«ãmDNSã§ã¤ã³ã¹ã¿ã³ã¹åããIPv4ã¢ãã¬ã¹ãå¼ãã
$ dns-sd -G v4 Remo-4A8BDD.local
DATE: ---Sat 12 Jan 2019---
13:40:19.941 ...STARTING...
Timestamp A/R Flags if Hostname Address
TTL
13:40:19.942 Add 2 5 Remo-4A8BDD.local. 192.168.0.18 120
ããã§ãªãã³ã°ã«ã¼ã ã®Nature Remoã®IPã¢ãã¬ã¹ãããã£ãã
åä¿¡ããä¿¡å·ãè¦ã
Nature Remoã«å¯¾ãã¦ãç §æãªã¢ã³ã³ã®ON/OFFãã¿ã³ãæ¼ãã¦ã赤å¤ç·ä¿¡å·ãéä¿¡ããã
Nature Remo Local APIã®message APIã§ãNature Remoãåä¿¡ããä¿¡å·ãè¦ãã
$ curl -s -X GET 'http://192.168.0.4/messages' -H 'X-Requested-With: curl'
{"format":"us","freq":37,"data":[4675,2627,564,959,572,1850,563,1863,562,958,564,1860,571,1849,566,956,575,949,564,959,571,1849,574,1850,575,952,571,1850,570,1854,572,1849,564,961,571,1847,568,1859,568,951,566,955,573,951,565,955,564,965,562,1854,576,948,567,956,565,957,572,950,571,951,571,953,570,950,572,945,572,16480,4670,2633,565,959,562,1860,572,1848,574,952,571,1849,573,1851,573,949,573,950,564,956,575,1849,576,1850,562,959,575,1848,572,1853,562,1857,566,959,572,1848,567,1859,570,951,571,953,563,956,565,959,570,951,567,1858,571,949,573,951,564,957,572,949,575,949,564,955,574,948,574,944,566,16484,4682,2624,571,951,564,1859,564,1858,572,952,571,1849,569,1855,573,951,571,949,566,960,562,1857,577,1849,570,951,565,1861,569,1850,574,1849,576,946,575,1849,573,1850,571,953,565,955,573,950,574,947,575,946,574,1852,570,953,570,949,566,959,563,956,573,952,563,959,564,960,569,943,574]}
dataé åã®åè¦ç´ ã¯ã赤å¤ç·ONã®æéãOFFã®æéãONã®æéãOFFã®æéããããã表ãã¦ããã å³å¯ã«ã¯ãããã¯38kHzã®å¤èª¿ããã³ã¼ããããã¨ã®çµæã§ãããå®éã«ã¯ONã®æéã¯38kHzã®å¤èª¿ä¿¡å·ã«ãªã£ã¦ããã
ãããã³ã«ã®è©³ç´°ã¯æ¸ããåç §ããããã
ããã¦ããã®çµæããã±ã£ã¨è¦ãæãã
NECãã©ã¼ããã
T=560us
ãªã¼ãã¼ã³ã¼ã: ON:4T, OFF:8T,
ããã0: ON: 1T, 1.7T
ããã1: ON: 1T, 3.4T
ã§ãããã¨ããããã
ããã°ã©ã ã«åã¾ãã¦èµ¤å¤ç·ä¿¡å·ã16é²4ãã¤ãã®ãã¼ã¿ã«ãã³ã¼ãããã
$ cat decode.py
import sys
import json
obj_txt = sys.stdin.read()
obj = json.loads(obj_txt)
bit_array = [int(not x < 1100) for x in obj['data'] if 900 < x < 2000]
byte_array = [sum([x<<i for (i, x) in enumerate(x)]) for x in zip(*[iter(bit_array)]*8)]
print(' '.join(["{:02x}".format(x) for x in byte_array]))
$ curl -s -X GET 'http://192.168.0.4/messages' -H 'X-Requested-With: curl' | python decode.py
36 76 83 00 36 76 83 00 36 76 83 00
ããã§ããã¼ã¿ãããã£ããããããã¹ã¦ã®ãã¿ã³ã«å¯¾ãã¦è¡ãããã¿ã³ã«å¯¾å¿ãããã¼ã¿ã®ä¸è¦§ãå¾ãã
(ch1)
Button | Data |
---|---|
è±ç | 36 76 48 00 |
ãªãã¿ã¤ãã¼60 | 36 76 80 00 |
ãªãã¿ã¤ãã¼30 | 36 76 82 00 |
ON/OFF | 36 76 84 00 |
æãã | 36 76 86 00 |
æã | 36 76 88 00 |
(ch2)
Button | Data |
---|---|
è±ç | 36 76 47 00 |
ãªãã¿ã¤ãã¼60 | 36 76 8f 00 |
ãªãã¿ã¤ãã¼30 | 36 76 81 00 |
ON/OFF | 36 76 83 00 |
æãã | 36 76 85 00 |
æã | 36 76 87 00 |
ãããã®çµæããããããã3ãã¤ãç®ãç §æã®åãã¿ã³ã®æä½ã«å¯¾å¿ãã¦ããã¨æ¨å¯ã§ããã ããããããã®3ãã¤ãç®ãæ¸ãæãã¦ã赤å¤ç·ãéä¿¡ããONã¨OFFã«å¯¾å¿ãããã¼ã¿ãæ¢ãã
åä¿¡ããä¿¡å·ãè¦ã
ããã°ã©ã ã«åã¾ãã¦16é²4ãã¤ãã®ãã¼ã¿ã赤å¤ç·ä¿¡å·ã«ãã³ã¼ãããã ããã¦ãNature Remo Local APIã®message APIã§ãç §æã«å¯¾ãã¦èµ¤å¤ç·ãéä¿¡ããã
$ cat encode.py
import sys
import json
byte_array = [int(x, 16) for x in sys.stdin.read().split(' ')]
data = [4668,2636]
for x in byte_array:
for i in range(8):
b = (x>>i)&1
if b == 1:
data += [562, 1877]
else:
data += [562, 951]
data += [548, 16504]
obj = {
'format': 'us',
'freq': 37,
'data': data,
}
obj_txt = json.dumps(obj)
sys.stdout.write(obj_txt)
$ echo "36 76 83 00" | python encode.py | curl -X POST 'http://192.168.0.4/messages' -H 'X-Requested-With: curl' -d @-
ç¡äºç §æãç¹ããï¼æ¶ãã¦ããã®ã§ON/OFFãã¿ã³ã§ç¹ç¯ããï¼ã
3ãã¤ãç®ãæ¸ãæãã¦ã¿ã¦ãåä½ãããã¿ã³ã¨ãåä½å 容ã®ä¸è¦§ãå¾ãã
(ch1)
Button | Data |
---|---|
ON | 36 76 42 00 |
OFF | 36 76 4a 00 |
(ch2)
Button | Data |
---|---|
ON | 36 76 41 00 |
OFF | 36 76 49 00 |
41ãONã49ãOFFã«å¯¾å¿ãã¦ãããã¨ãããã£ãã ãããããNature Remo Cloud APIã使ã£ã¦ãNature Remoã«ãã¿ã³ãç»é²ããã
ä¿¡å·ãç»é²ãã
ã¾ããNature Remo Global APIã®ã¢ã¯ã»ã¹ç¨ã®ãã¼ã¯ã³ãçæããåå¾ããã以éãã¼ã¯ã³ã¯XXXXï¼ä¼ãåï¼ã¨è¡¨ãã
次ã«ãNature Remo Global APIã®ã®appliances APIã§ãæ©å¨ã®ä¸è¦§ãè¦ãã
$ curl -s -X GET "https://api.nature.global/1/appliances" -H "Authorization: Bearer XXXX" | python -mjson.tool
(snip)
{
"id": "YYYY",
"device": {
"name": "Living Room",
"id": "XXXX",
(snip)
},
"model": null,
"type": "IR",
"nickname": "Living Room Light",
"image": "ico_light",
"settings": null,
"aircon": null,
"signals": [
(snip)
]
},
(snip)
æ©å¨ã®IDããããã以éæ©å¨ã®IDã¯YYYYï¼ä¼ãåï¼ã¨ããã
æå¾ã«ãNature Remo Global APIã®ã®signals APIã§ã赤å¤ç·ä¿¡å·ãç»é²ããã
$ echo "36 76 41 00" | python encode.py | urlencode
%7B%22format%22%3A%20%22us%22%2C%20%22freq%22%3A%2037%2C%20%22data%22...5D%7D
$ curl -s -X POST "https://api.nature.global/1/appliances/YYYY/signals" -H "Authorization: Bearer XXXX" -d "message=ZZZZ&image=ico_on&name=ON"
{"id":"XXXX","name":"ON","image":"ico_on"}
$ echo "36 76 49 00" | python encode.py | urlencode
%7B%22format%22%3A%20%22us%22%2C%20%22freq%22%3A%2037%2C%20%22data%22...5D%7D
$ curl -s -X POST "https://api.nature.global/1/appliances/YYYY/signals" -H "Authorization: Bearer XXXX" -d "message=ZZZZ&image=ico_off&name=OFF"
{"id":"XXXX","name":"OFF","image":"ico_off"}
ç¡äºãONã®ãã¿ã³ã¨ãOFFã®ãã¿ã³ãç»é²ãããã
ã±ã¡ã±ã¡ã±ã¡