<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>2022/06/25 on Yano&#39;s digital garage</title>
    <link>https://www.bravotouring.com/~yano/archives/2022/06/25/</link>
    <description>Recent content in 2022/06/25 on Yano&#39;s digital garage</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sat, 25 Jun 2022 17:11:20 +0900</lastBuildDate>
    <atom:link href="https://www.bravotouring.com/~yano/archives/2022/06/25/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Nature Remo</title>
      <link>https://www.bravotouring.com/~yano/diary/it/20230809_nature_remo.htm</link>
      <pubDate>Sat, 25 Jun 2022 17:11:20 +0900</pubDate>
      <guid>https://www.bravotouring.com/~yano/diary/it/20230809_nature_remo.htm</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://www.bravotouring.com/~yano/diary/it/20220611_irkit.htm&#34;&gt;昨年6月&lt;/a&gt;に復活した&lt;span class=&#34;Tradename&#34;&gt;IRKit&lt;/span&gt;の不調具合が加速してきた折、&lt;a href=&#34;https://pc.watch.impress.co.jp/docs/news/1513752.html&#34;&gt;3,980円であらゆる家電をIoT化。Matterリモコン「Nature Remo nano」&lt;/a&gt;というニュースで、一つ前世代の&lt;a href=&#34;https://nature.global/nature-remo/nature-remo-mini/&#34;&gt;Nature Remo mini&lt;/a&gt;を調達してたのを思い出し、慌てて投入。&lt;/p&gt;&#xA;&lt;p&gt;&#xA;&lt;blockquote class=&#34;Log&#34;&gt;&#xA;yano@haswell:~/smarthome$ Token=zjKKjfAL6X36SJvKtuqqXxm2SHMFeAjBnTHxZUhdzjKKjfAL6X36SJvKtuqqXxm2SHMFeAjBnTHxZUhd&lt;br/&gt;&#xA;yano@haswell:~/smarthome$ curl -X GET &#34;https://api.nature.global/1/devices&#34; -H &#34;accept: application/json&#34; -k --header &#34;Authorization: Bearer ${Token}&#34; | jq&lt;br/&gt;&#xA;[&lt;br/&gt;&#xA;  {&lt;br/&gt;&#xA;    &#34;name&#34;: &#34;Remo mini&#34;,&lt;br/&gt;&#xA;    &#34;id&#34;: &#34;deb07f72-a5ab-4262-915b-ABCDEFG&#34;,&lt;br/&gt;&#xA;    &#34;created_at&#34;: &#34;2023-08-09T01:31:06Z&#34;,&lt;br/&gt;&#xA;    &#34;updated_at&#34;: &#34;2023-08-09T02:15:12Z&#34;,&lt;br/&gt;&#xA;    &#34;mac_address&#34;: &#34;98:cd:ac:XX:YY:ZZ&#34;,&lt;br/&gt;&#xA;    &#34;bt_mac_address&#34;: &#34;98:cd:ac:XX:YY:ZZ&#34;,&lt;br/&gt;&#xA;    &#34;serial_number&#34;: &#34;2W221070012345678&#34;,&lt;br/&gt;&#xA;    &#34;firmware_version&#34;: &#34;Remo-mini/1.12.2&#34;,&lt;br/&gt;&#xA;    &#34;temperature_offset&#34;: 0,&lt;br/&gt;&#xA;    &#34;humidity_offset&#34;: 0,&lt;br/&gt;&#xA;    &#34;users&#34;: [&lt;br/&gt;&#xA;      {&lt;br/&gt;&#xA;        &#34;id&#34;: &#34;c376a287-5300-4c8b-b793-ABCDEFG&#34;,&lt;br/&gt;&#xA;        &#34;nickname&#34;: &#34;ホゲホゲフーガ&#34;,&lt;br/&gt;&#xA;        &#34;superuser&#34;: true&lt;br/&gt;&#xA;      }&lt;br/&gt;&#xA;    ],&lt;br/&gt;&#xA;    &#34;newest_events&#34;: {&lt;br/&gt;&#xA;      &#34;te&#34;: {&lt;br/&gt;&#xA;        &#34;val&#34;: 32,&lt;br/&gt;&#xA;        &#34;created_at&#34;: &#34;2023-08-09T05:03:19Z&#34;&lt;br/&gt;&#xA;      }&lt;br/&gt;&#xA;    }&lt;br/&gt;&#xA;  }&lt;br/&gt;&#xA;]&lt;br/&gt;yano@haswell:~/smarthome$&#xA;&lt;/blockquote&gt;&#xA;&lt;/p&gt;&#xA;&lt;p&gt;&#xA;&lt;a href=&#34;https://developer.nature.global/&#34;&gt;Nature Developer Page&lt;/a&gt;によると&lt;span class=&#34;Tradename&#34;&gt;IRKit&lt;/span&gt;のような「Local API」も公開されているらしい。&#xA;&lt;blockquote class=&#34;Log&#34;&gt;&#xA;yano@haswell:~/smarthome$ avahi-browse -t _remo._tcp&lt;br/&gt;&#xA;+ vlan.3 IPv6 Remo-mini5CD364                               _remo._tcp           local&lt;br/&gt;&#xA;+ vlan.3 IPv4 Remo-mini5CD364                               _remo._tcp           local&lt;br/&gt;&#xA;yano@haswell:~/smarthome$ avahi-resolve -n Remo-mini5CD364.local&lt;br/&gt;&#xA;Remo-mini5CD364.local   10.20.199.127&lt;br/&gt;&#xA;yano@haswell:~/smarthome$&#xA;&lt;/blockquote&gt;&#xA;&lt;span class=&#34;Tradename&#34;&gt;IRKit&lt;/span&gt;と同じ流儀で&#xA;&lt;blockquote class=&#34;Log&#34;&gt;&#xA;yano@haswell:~/smarthome$ REMO_TCP=$(avahi-browse -t _remo._tcp);&lt;br/&gt;&#xA;yano@haswell:~/smarthome$ ADDR_REMO=$(avahi-resolve -n $(echo $REMO_TCP | awk &#39;{print $4&#34;.&#34;$6}&#39;) | awk &#39;{print $2}&#39;)&lt;br/&gt;&#xA;yano@haswell:~/smarthome$ curl -H &#34;X-Requested-With: curl&#34; -i &#34;http://$ADDR_REMO/messages&#34;&lt;br/&gt;&#xA;HTTP/1.1 200 OK&lt;br/&gt;&#xA;Content-Type: application/json&lt;br/&gt;&#xA;Content-Length: 1726&lt;br/&gt;&#xA;Server: Remo-mini/1.12.2&lt;br/&gt;&#xA;&lt;br/&gt;&#xA;{&#34;format&#34;:&#34;us&#34;,&#34;freq&#34;:39,&#34;data&#34;:[&#xA;8543,4395,482,595,510,621,484,619,536,568,482,621,484,621,484,619,480,1779,450,655,480,1777,482,1779,481,1777,530,575,448,1810,485,1772,476,629,472,631,483,622,450,640,499,618,479,626,482,621,520,585,470,633,479,1779,479,1780,506,1754,474,1784,483,1777,450,1810,475,1756,476,1794,520,42264,9999,5162,546,1966,518,1996,540,1971,544,713,548,710,545,1964,550,1964,544,1967,544,713,516,739,553,1961,517,1994,551,706,517,737,544,713,518,739,542,1970,544,1968,549,708,517,1994,544,712,545,710,544,713,552,1962,541,713,544,713,542,1970,542,715,542,1969,544,1970,595,1917,541,713,555,47213,3289,1769,310,1373,333,490,340,480,380,442,320,486,351,471,342,495,293,529,293,527,295,527,295,527,292,528,294,1361,310,527,294,525,373,449,331,490,296,527,329,464,324,510,338,1345,297,1373,293,521,303,510,346,464,322,527,293,527,295,527,319,1334,310,512,310,1373,321,501,295,1372,296,1359,310,1373,295,1375,295,527,292,1360,310,527,375,1294,294,527,295,525,295,512,336,486,310,512,309,526,341,482,383,438,295,1358,377,1308,293,1375,295,1358,388,1297,295,1373,294,1358,310,1375,293,1375,295,1358,310,512,310,527,293,527,295,527,370,451,294,527,297,510,312,510,310,1373,295,1375,293,1360,310,1373,295,1375,295,1358,341,494,374,1294,296,528,292,527,298,510,312,509,311,1372,298,1355,314,1372,292,527,326,1344,293,1360,311,1372,333,1336,294,512,310,512,310,36593,3461,1829,337,538,332,538,332,1407,356,1383,399,471,358,1377,334,536,362,507,364,500,372,1368,369,500,338,538,331,1408,332,538,361,1370,338,536,360,1379,363,501,337,539,331,1408,329,540,332,538,330,540,377,488,360,1379,360,1380,331,1408,363,1371,371,496,338,1405,334,536,370,496,369,500,367,1371,337,1408,332,538,331,538,396,1336,337,536,360]}&lt;br/&gt;&#xA;yano@haswell:~/smarthome$&#xA;&lt;/blockquote&gt;&#xA;と、リモコンのデータも取得できるようだ。&#xA;&lt;/p&gt;</description>
    </item>
    <item>
      <title>SwitchBot API</title>
      <link>https://www.bravotouring.com/~yano/diary/it/20220625_switchbot_api.htm</link>
      <pubDate>Sat, 25 Jun 2022 17:11:20 +0900</pubDate>
      <guid>https://www.bravotouring.com/~yano/diary/it/20220625_switchbot_api.htm</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://www.bravotouring.com/~yano/diary/it/20220225_ifttt.htm&#34;&gt;IFTTT不発事故&lt;/a&gt;に起因する&lt;a href=&#34;https://www.bravotouring.com/~yano/diary/it/20210129_ifttt.htm&#34;&gt;2021年版AirconShutdown&lt;/a&gt;の善後策。&lt;/p&gt;&#xA;&lt;table align=&#34;right&#34; class=&#34;Panorama&#34;&gt;&#xA;&lt;tr&gt;&#xA;&lt;td&gt;&lt;img alt=&#34;SwitchBotハブミニ&#34; src=&#34;https://www.bravotouring.com/~yano/images/2020/20200628_switchbot.jpg&#34;/&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;tr&gt;&#xA;&lt;td class=&#34;PhotoMemo&#34;&gt;&lt;a href=&#34;https://www.switchbot.jp/products/switchbot-hub-mini&#34;&gt;SwitchBotハブミニ&lt;/a&gt;&lt;/td&gt;&#xA;&lt;/tr&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;これまでは&lt;a href=&#34;https://www.bravotouring.com/~yano/diary/it/20210118_twurl.htm&#34;&gt;Twitter経由&lt;/a&gt;の&lt;span class=&#34;Tradename&#34;&gt;IFTTT&lt;/span&gt;で&lt;a href=&#34;https://www.bravotouring.com/~yano/diary/it/20171211_remocon.htm&#34;&gt;家電リモコン&lt;/a&gt;と&lt;a href=&#34;https://www.bravotouring.com/~yano/diary/it/20200624_switchbot.htm&#34;&gt;SwitchBot&lt;/a&gt;を制御していたところ、&lt;a href=&#34;https://www.bravotouring.com/~yano/diary/it/20220310_irkit.htm&#34;&gt;2022年版IRKit&lt;/a&gt;では直接APIを叩くようにできたので、&lt;a href=&#34;https://www.bravotouring.com/~yano/diary/it/20200624_switchbot.htm&#34;&gt;SwitchBot&lt;/a&gt;も&lt;a href=&#34;https://github.com/OpenWonderLabs/SwitchBotAPI&#34;&gt;SwitchBot Open API&lt;/a&gt;を叩くことに。&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://github.com/OpenWonderLabs/SwitchBotAPI&#34;&gt;SwitchBot Open API&lt;/a&gt;は&#xA;&lt;blockquote class=&#34;Log&#34;&gt;https://api.switch-bot.com/v1.0/devices/&lt;span class=&#34;Strong&#34;&gt;&lt;deviceId&gt;&lt;/span&gt;/commands&lt;/blockquote&gt;というRESTエンドポイントに制御データをPOSTする枠組み。&lt;span class=&#34;Strong&#34;&gt;&lt;deviceId&gt;&lt;/span&gt;で指定する対象装置は&lt;blockquote class=&#34;Log&#34;&gt;&#xA;curl --request GET &#39;https://api.switch-bot.com/v1.0/devices&#39; \&lt;br/&gt;&#xA;  --header &#39;Authorization: &lt;span class=&#34;Topics&#34;&gt;認証トークン&lt;/span&gt;&#39; \&lt;br/&gt;&#xA;  --header &#39;Content-Type: application/json; charset=utf8&#39;&lt;/blockquote&gt;で一覧を取得できる。なお、&lt;span class=&#34;Topics&#34;&gt;認証トークン&lt;/span&gt;は&lt;a href=&#34;https://qiita.com/itouuuuuuuuu/items/874cd992f473f30de45b&#34;&gt;SwitchBotをHub経由でAPIから操作する&lt;/a&gt;に倣い、SwitchBotアプリの「開発者向けオプション」から取得できる。&lt;/p&gt;&#xA;&lt;p&gt;ちなみに、エアコンの制御データのパラメータは&#xA;&lt;table class=&#34;List&#34;&gt;&#xA;&lt;tr class=&#34;List&#34;&gt;&lt;th&gt;deviceType&lt;/th&gt;&lt;td&gt;Air Conditioner&lt;/td&gt;&lt;/tr&gt;&#xA;&lt;tr class=&#34;List&#34;&gt;&lt;th&gt;commandType&lt;/th&gt;&lt;td&gt;command&lt;/td&gt;&lt;/tr&gt;&#xA;&lt;tr class=&#34;List&#34;&gt;&lt;th&gt;Command&lt;/th&gt;&lt;td&gt;setAll&lt;/td&gt;&lt;/tr&gt;&#xA;&lt;tr class=&#34;List&#34;&gt;&lt;th&gt;command parameter&lt;/th&gt;&lt;td&gt;{temperature},{mode},{fan speed},{power state}&lt;br/&gt;e.g. 26,1,3,on&lt;/td&gt;&lt;/tr&gt;&#xA;&lt;tr class=&#34;List&#34;&gt;&lt;th&gt;Description&lt;/th&gt;&#xA;&lt;td&gt;the unit of temperature is in celsius;&lt;br/&gt;modes include 1 (auto), 2 (cool), 3 (dry), 4 (fan), 5 (heat);&lt;br/&gt;fan speed includes 1 (auto), 2 (low), 3 (medium), 4 (high);&lt;br/&gt;power state includes on and off&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;…となっているので、、エアコン停止用の&lt;blockquote class=&#34;Log&#34;&gt;&#xA;{  &#34;command&#34;: &#34;setAll&#34;, &#34;parameter&#34;: &#34;25,1,1,off&#34;, &#34;commandType&#34;: &#34;command&#34;}&lt;/blockquote&gt;というデータを&#34;switchbot_aircon_off.json&#34;というファイルにして&#xA;&lt;blockquote class=&#34;Log&#34;&gt;&#xA;#!/bin/bash&lt;br/&gt;&#xA;&lt;br/&gt;&#xA;BASEPATH=$(dirname $0);&lt;br/&gt;&#xA;&lt;br/&gt;&#xA;SWITCHBOT_API=&#34;https://api.switch-bot.com/v1.0&#34;&lt;br/&gt;&#xA;SWITCHBOT_TOKEN=&lt;span class=&#34;Topics&#34;&gt;&#34;90edf....3431&#34;&lt;/span&gt;&lt;br/&gt;&#xA;&lt;br/&gt;&#xA;hdr_auth=&#34;Authorization:${SWITCHBOT_TOKEN}&#34;&lt;br/&gt;&#xA;hdr_type=&#34;Content-Type: application/json&#34;&lt;br/&gt;&#xA;# BODY=&#34;@${BASEPATH}/switchbot_aircon_off.json&#34;&lt;br/&gt;&#xA;BODY=&#39;{&#34;commandType&#34;: &#34;command&#34;, &#34;command&#34;: &#34;setAll&#34;, &#34;parameter&#34;: &#34;25,1,1,off&#34;}&#39;&lt;br/&gt;&#xA;&lt;br/&gt;&#xA;AIRCON_1F=&#34;01-2020XXXXXXXX-32&#34;  # 1F&lt;br/&gt;&#xA;AIRCON_2F=&#34;01-2020YYYYYYYY-52&#34;  # 2F&lt;br/&gt;&#xA;AIRCON_3F=&#34;01-2020ZZZZZZZZ-82&#34;  # 3F&lt;br/&gt;&#xA;&lt;br/&gt;&#xA;for DEVICE_ID in $AIRCON_1F $AIRCON_2F $AIRCON_3F;&lt;br/&gt;&#xA;do&lt;br/&gt;&#xA;    URL=&#34;${SWITCHBOT_API}/devices/${DEVICE_ID}/commands&#34;&lt;br/&gt;&#xA;    curl &#34;${URL}&#34; \&lt;br/&gt;&#xA;         --silent -O /dev/null \&lt;br/&gt;&#xA;         -H &#34;${hdr_auth}&#34; -H &#34;${hdr_type}&#34; \&lt;br/&gt;&#xA;         -X POST -d &#34;${BODY}&#34;&lt;br/&gt;&#xA;done&lt;/blockquote&gt;&#xA;というスクリプトを回せばエアコン3台が順次停止になる運びだ。&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
