{"id":73,"date":"2026-05-05T12:04:12","date_gmt":"2026-05-05T03:04:12","guid":{"rendered":"https:\/\/cre-noa.me\/?p=73"},"modified":"2026-05-05T12:41:57","modified_gmt":"2026-05-05T03:41:57","slug":"tesla-%e3%83%95%e3%83%aa%e3%83%bc%e3%83%88api-%e5%ae%9f%e8%a3%85%e3%81%ae%e5%82%99%e5%bf%98","status":"publish","type":"post","link":"https:\/\/cre-noa.me\/?p=73","title":{"rendered":"Tesla \u30d5\u30ea\u30fc\u30c8API \u5b9f\u88c5\u306e\u5099\u5fd8"},"content":{"rendered":"\n<p>Tesla API\uff08Fleet API\uff09\u306e\u5b9f\u88c5\u306b\u3064\u3044\u3066\u3001\u5099\u5fd8\u9332\u3068\u3057\u3066\u307e\u3068\u3081\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. \u524d\u63d0\u6761\u4ef6<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1.1. \u5fc5\u8981\u306a\u3082\u306e<\/h3>\n\n\n\n<p>\u5fc5\u8981\u306a\u57fa\u76e4\u3068\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u30fb\u30b5\u30fc\u30d0\u57fa\u76e4\uff1a<br>\u3000\u79c1\u306e\u74b0\u5883\u3067\u306fProxmox\u4e0a\u306edebian \u3067\u69cb\u7bc9<br><br>\u30fb\u72ec\u81ea\u30c9\u30e1\u30a4\u30f3\uff1a<br>\u3000\u8a8d\u8a3c\u306e\u305f\u3081\u306b\u5fc5\u8981<\/p>\n\n\n\n<p>\u30fbWeb\u30b5\u30fc\u30d0\uff1a<br>\u3000apache\/nginx\u7b49\u306eWeb\u30b5\u30fc\u30d0\u304c\u5fc5\u8981\u3000\u516c\u958b\u9375\u3092\u516c\u958b\u3059\u308b<br><\/p>\n\n\n\n<p>\u30fbPython \/ Go \u8a00\u8a9e\u74b0\u5883\uff1a<br>\u3000\u6700\u7d42\u7684\u306aAPI\u5236\u5fa1\u7528<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. \u4f5c\u696d\u6982\u8981<\/h2>\n\n\n\n<p><strong>STEP 1: \u9375\u4f5c\u6210\uff08\u79d8\u5bc6\u9375\u30fb\u516c\u958b\u9375\uff09<\/strong><br>\u64cd\u4f5c\u8005\u306e\u8a8d\u8a3c\u306e\u305f\u3081\u306b\u30ad\u30fc\u30da\u30a2\u3092\u4f5c\u6210\u3057\u3001\u81ea\u30c9\u30e1\u30a4\u30f3\u4e0a\u3067\u516c\u958b\u9375\u3092\u516c\u958b\u3059\u308b\u3002<br><\/p>\n\n\n\n<p><strong>STEP 2: Tesla Developer \u306b\u3066\u30a2\u30d7\u30ea\u767b\u9332\u3092\u884c\u3046<\/strong><br>API\u64cd\u4f5c\u306b\u5fc5\u8981\u306a Client ID \u3068 Client Secret \u3092\u53d6\u5f97\u3059\u308b\u3002<br><\/p>\n\n\n\n<p><strong>STEP 3: \u8eca\u4e21\u30ad\u30fc\u3068\u3057\u3066\u3001Tesla\u306b\u516c\u958b\u9375\u3092\u767b\u9332\u3059\u308b<\/strong><br>Tesla\u306e\u30ad\u30fc\u767b\u9332\u3068\u540c\u69d8\u306b\u3001\u81ea\u30c9\u30e1\u30a4\u30f3\u3068\u7d10\u4ed8\u304f\u516c\u958b\u9375\u3092\u8eca\u4e21\u306b\u767b\u9332\u3059\u308b\u3002<br><\/p>\n\n\n\n<p><strong>STEP 4: \u516c\u5f0f\u30c4\u30fc\u30eb\uff08tesla-control\uff09\u306e\u5c0e\u5165\u3068API\u5b9f\u884c<\/strong><br>\u4eca\u56de\u306f\u30a2\u30f3\u30da\u30a2\u64cd\u4f5c\u306a\u3069\u306e\u5145\u96fb\u64cd\u4f5c\u3092\u8a66\u3057\u307e\u3059\uff08\u5145\u96fb\u64cd\u4f5c\u306e\u307f\u306e\u6a29\u9650\u3092\u3064\u3051\u3066\u3044\u307e\u3059\uff09<br><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">STEP 1. \u9375\u4f5c\u6210\uff08\u79d8\u5bc6\u9375\u30fb\u516c\u958b\u9375\uff09\u3068Web\u30b5\u30fc\u30d0\u69cb\u7bc9<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\">1.1. APACHE\u306b\u3088\u308bWEB\u30b5\u30a4\u30c8\u306e\u69cb\u7bc9<\/h4>\n\n\n\n<p>\u6628\u4eca\u306fIPv4\u67af\u6e07\u306e\u5f71\u97ff\u3067\u30dd\u30fc\u30c8\u958b\u653e\u304c\u3067\u304d\u306a\u3044\u56de\u7dda\u304c\u591a\u3044\u305f\u3081\u3001Cloudflare\u30c8\u30f3\u30cd\u30eb\u306b\u3088\u308b\u30b5\u30a4\u30c8\u516c\u958b\u3068\u3057\u307e\u3059\u3002<br>Cloudflare \u306b\u3088\u308b\u901a\u4fe1\u6697\u53f7\u5316\u3001HTTPS\u5316\u3082\u53ef\u80fd\u3067\u3059\u3002\u3057\u304b\u3082\u7121\u6599\u3067\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1.1.1. apache2\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5fc5\u8981\u306b\u5fdc\u3058\u3066sudo \u3057\u3066\u304f\u3060\u3055\u3044\u3002\napt install apache2 -y\n\n#OS\u304c\u8d77\u52d5\u3057\u305f\u3068\u304d\u306b\u3001apache\u304c\u81ea\u52d5\u8d77\u52d5\u3055\u305b\u308b\u305f\u3081\u306e\u304a\u307e\u3058\u306a\u3044\nsystemctl start apache2\nsystemctl enable apache2\nsystemctl status apache2\n\u3000\u2192enabled \u3067\u3042\u308c\u3070\u3001OS\u518d\u8d77\u52d5\u6642\u3082apache\u304c\u81ea\u52d5\u8d77\u52d5\u3057\u307e\u3059\u3002\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">1.1.2. \u30b5\u30a4\u30c8\u30da\u30fc\u30b8\u306e\u8a2d\u7f6e<\/h4>\n\n\n\n<p>\u8ab0\u3082\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3053\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u30c7\u30d5\u30a9\u30eb\u30c8\u30da\u30fc\u30b8\u306e\u516c\u958b\u306f\u4e0d\u9069\u5207\u306a\u306e\u3067\u5ff5\u306e\u305f\u3081\u30b5\u30a4\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u8a2d\u7f6e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/var\/www\/html\n\n# \u30c7\u30d5\u30a9\u30eb\u30c8\u30da\u30fc\u30b8\u3092\u524a\u9664\nrm -rf index.html\n\n# \u660e\u793a\u7684\u306b\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210\ntouch index.html\n\n# \u30b5\u30a4\u30c8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001\u81ea\u524d\u306e\u30c9\u30e1\u30a4\u30f3\u540d\u304c\u8868\u793a\u3055\u308c\u308b\u3088\u3046\u306b\u3059\u308b\nsh -c 'echo \"\u81ea\u5206\u306e\u30c9\u30e1\u30a4\u30f3\u540d\" &gt; index.html'\n\n# \u4e00\u822c\u516c\u958b\u7528\u306a\u306e\u3067644 (rw-r--r--) \u306b\u8a2d\u5b9a\nchmod 644 index.html\n\n\u203b\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u6240\u6709\u8005\u306f\u300c\u8aad\u307f\u66f8\u304d\u300d\u304c\u3067\u304d\u3001\u4ed6\u306e\u4eba\u306f\u300c\u8aad\u307f\u53d6\u308a\u300d\u3057\u304b\u3067\u304d\u306a\u3044\u72b6\u614b\u306b\u3057\u307e\u3059\u3002<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">1.1.3. \u30ed\u30fc\u30ab\u30eb\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3067\u30b5\u30a4\u30c8\u304c\u8868\u793a\u3067\u304d\u308b\u304b\u3092\u78ba\u8a8d\u3059\u308b<br><\/h4>\n\n\n\n<p>\u5b85\u5185NW\u4e0a\u306e\u30b5\u30fc\u30d0\u306eIP\u30a2\u30c9\u30ec\u30b9\u3092\u8abf\u3079\u3001\u30d6\u30e9\u30a6\u30b6\u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002(ip a\u30b3\u30de\u30f3\u30c9\u306a\u3069\uff09<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1.2. \u9375\u30da\u30a2\u306e\u4f5c\u6210\uff08\u79d8\u5bc6\u9375\u30fb\u516c\u958b\u9375\uff09<\/h3>\n\n\n\n<p>\u53c2\u8003:<a href=\" https:\/\/developer.tesla.com\/docs\/fleet-api\/virtual-keys\/developer-guide#hosting-the-public-key\">https:\/\/developer.tesla.com\/docs\/fleet-api\/virtual-keys\/developer-guide#hosting-the-public-key<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir ~\/pem\ncd ~\/pem\n\n# 1. \u79d8\u5bc6\u9375\uff08\u7d76\u5bfe\u306b\u8ab0\u306b\u3082\u898b\u305b\u3061\u3083\u30c0\u30e1\uff09\u3092\u4f5c\u6210\nopenssl ecparam -name prime256v1 -genkey -noout -out private_key.pem\n\n# 2. \u79d8\u5bc6\u9375\u304b\u3089\u516c\u958b\u9375\uff08\u3053\u3061\u3089\u516c\u958b\uff09\u3092\u4f5c\u6210\nopenssl ec -in private_key.pem -pubout -out public_key.pem<\/code><\/pre>\n\n\n\n<p>\u516c\u958b\u9375\u3092\u516c\u958b\u3059\u308b\u305f\u3081\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3001\u516c\u958b\u9375\u3092\u914d\u7f6e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u516c\u958b\u306e\u305f\u3081\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3059\u308b\nmkdir -p \/var\/www\/html\/.well-known\/appspecific\n\n# \u516c\u958b\u9375\u3092\u30b3\u30d4\u30fc\u3057\u3001\u300ccom.tesla.3p.public-key.pem\u300d \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u540d\u306b\u5909\u3048\u308b\ncp ~\/pem\/public_key.pem \/var\/www\/html\/.well-known\/appspecific\/com.tesla.3p.public-key.pem<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1.3. Cloudflare\u306b\u3088\u308bWeb\u30da\u30fc\u30b8\u306e\u516c\u958b<\/h3>\n\n\n\n<p id=\"p-rc_c9df3f7ee47418ba-172\">Cloudflare\u306f\u81ea\u5b85\u306e\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u5074IP\u30a2\u30c9\u30ec\u30b9\u3092\u516c\u958b\u3059\u308b\u3053\u3068\u306a\u304f\u3001\u30b5\u30a4\u30c8\u516c\u958b\u304c\u3067\u304d\u307e\u3059\u3002&nbsp;https\u5316\u3082\u7121\u6599\u3067\u3059\u3002\u30b5\u30fc\u30d0\u306b\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3060\u3051\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u975e\u5e38\u306b\u308f\u304b\u308a\u3084\u3059\u3044\u8a18\u4e8b\u3092\u66f8\u3044\u3066\u3044\u308b\u65b9\u304c\u304a\u3089\u308c\u305f\u306e\u3067\u3001\u30ea\u30f3\u30af\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p id=\"p-rc_c9df3f7ee47418ba-173\">https:\/\/zenn.dev\/takajun\/articles\/fbd783e459c722<\/p>\n<\/blockquote>\n\n\n\n<p id=\"p-rc_c9df3f7ee47418ba-174\">\u81ea\u5206\u306e\u30c9\u30e1\u30a4\u30f3\u306b\u7f6e\u304d\u63db\u3048\u3066\u3001\u4ee5\u4e0b\u306b\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u3002&nbsp;<br>\u516c\u958b\u9375\u304c\u8868\u793a\u3067\u304d\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u3001\u3053\u3053\u307e\u3067\u5b8c\u4e86\u3067\u3059\u3002&nbsp;<\/p>\n\n\n\n<p id=\"p-rc_c9df3f7ee47418ba-174\"><code>https:\/\/\u81ea\u5206\u306e\u30c9\u30e1\u30a4\u30f3\/.well-known\/appspecific\/com.tesla.3p.public-key.pem<\/code><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">STEP 2. Tesla Developer \u306b\u3066\u30a2\u30d7\u30ea\u767b\u9332\u3092\u884c\u3046<\/h2>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2.1.<\/strong>&nbsp;Tesla Developer\u306b\u30a2\u30af\u30bb\u30b9\u3057\u3001Tesla\u30a2\u30ab\u30a6\u30f3\u30c8\u3067\u30b5\u30a4\u30f3\u30a4\u30f3\u3059\u308b\u3002<\/h4>\n\n\n\n<p><a href=\"https:\/\/developer.tesla.com\">https:\/\/developer.tesla.com<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2.2.\u00a0\u65b0\u3057\u3044\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210<\/h4>\n\n\n\n<p>\u300c\u65b0\u3057\u3044\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u6210\u3059\u308b\u300d\u304b\u3089\u3001\u5404\u7a2e\u5fc5\u8981\u4e8b\u9805\u3092\u5165\u529b\u3059\u308b\u3002\u3000<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u53c2\u8003<\/p>\n\n\n\n<p>\u30fb<strong>Auth\u4ed8\u4e0e\u30bf\u30a4\u30d7<\/strong>:&nbsp;<code>client-credentials<\/code>,&nbsp;<code>authorization-code<\/code><\/p>\n\n\n\n<p>\u30fb<strong>\u8a31\u53ef\u3055\u308c\u305f\u9001\u4fe1\u5143<\/strong>:&nbsp;<code>https:\/\/\u81ea\u5206\u306e\u30c9\u30e1\u30a4\u30f3<\/code><\/p>\n\n\n\n<p>\u30fb<strong>\u8a31\u53ef\u3055\u308c\u305f\u30ea\u30c0\u30a4\u30ec\u30af\u30c8URI<\/strong>:&nbsp;<code>https:\/\/\u81ea\u5206\u306e\u30c9\u30e1\u30a4\u30f3\/callback<\/code><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2.3.&nbsp;\u9867\u5ba2ID\uff08Client ID\uff09\u304a\u3088\u3073\u9867\u5ba2\u6a5f\u5bc6\uff08\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\uff09\u3092\u63a7\u3048\u308b\u3002<\/strong><\/h4>\n\n\n\n<p>\u5f8c\u307b\u3069\u4f7f\u3044\u307e\u3059\u3002\u3000\u203b\u6d41\u51fa\u3057\u306a\u3044\u3088\u3046\u306b\u6ce8\u610f<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2.4.&nbsp;Tesla \u30a2\u30d7\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f\u30b9\u30de\u30db\u3001\u307e\u305f\u306f\u30d6\u30e9\u30a6\u30b6\u304b\u3089\u3001\u4ee5\u4e0b\u306eURL\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3002<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;auth.tesla.com\/oauth2\/v3\/authorize?&amp;client_id=$\u3010ClientID\u3011\n&amp;locale=en-US&amp;prompt=login&amp;redirect_uri=$\u3010\u81ea\u5206\u306e\u30c9\u30e1\u30a4\u30f3\u3011\n&amp;response_type=code&amp;scope=scope=openid%20vehicle_device_data%20o\"i\nne_access%20vehicle_cmds\n\n\u203b\u3010ClientID\u3011\u3010\u30c9\u30e1\u30a4\u30f3\u3011\u306f\u7f6e\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/code><\/pre>\n\n\n\n<p><strong>\u3053\u306e\u3068\u304d\u3001\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u308c\u305fURL\u304b\u3089 \u300c<code>code=xxx<\/code>\u300d\u3092\u629c\u304d\u51fa\u3057\u3066\u3001\u4fdd\u7ba1\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/strong><br>\u6b21\u306e\u30b9\u30c6\u30c3\u30d7\u3067\u4f7f\u7528\u3057\u307e\u3059\u3002&nbsp;<strong>\u3053\u306e\u8a8d\u53ef\u30b3\u30fc\u30c9\u306f10\u5206\u306e\u671f\u9650\u304c\u3042\u308a\u307e\u3059\u3002<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><span data-path-to-node=\"32,0\" style=\"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); white-space: normal;\"><b data-path-to-node=\"32,0\" data-index-in-node=\"0\">2.5. \u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\u306e\u53d6\u5f97<\/b>&nbsp;<\/span>\uff08\u8a8d\u53ef\u30b3\u30fc\u30c9\u53d6\u5f97\u304b\u308910\u5206\u4ee5\u5185\uff09<\/h4>\n\n\n\n<p><span data-path-to-node=\"32,0\" style=\"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); white-space: normal;\">\u30c6\u30b9\u30e9\u3092\u64cd\u4f5c\u3059\u308b\u30b5\u30fc\u30d0\u304b\u3089\u3001\u4ee5\u4e0b\u306e<\/span>\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002<br><span data-path-to-node=\"32,0\" style=\"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); white-space: normal;\">\u8868\u793a\u3055\u308c\u305f Access Token\u3001Refresh Token \u3092\u63a7\u3048\u3066\u304f\u3060\u3055\u3044\u3002 <\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -X POST https:\/\/auth.tesla.com\/oauth2\/v3\/token \\\n-H \"Content-Type: application\/json\" \\\n-d '{\n\"grant_type\": \"authorization_code\",\n\"client_id\": \"\u30af\u30e9\u30a4\u30a2\u30f3\u30c8ID\",\n\"client_secret\": \"\u30b7\u30fc\u30af\u30ec\u30c3\u30c8\",\n\"code\": \"\u624b\u98062.4\u3067\u53d6\u5f97\u3057\u305f\u30b3\u30fc\u30c9\",\n\"audience\": \"https:\/\/fleet-api.prd.na.vn.cloud.tesla.com\",\n\"redirect_uri\": \"https:\/\/dev.cre-noa.me\/callback\"\n}'<\/code><\/pre>\n\n\n\n<p><span data-path-to-node=\"32,0\" style=\"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); white-space: normal;\">\u203b\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\u306b\u306f\u671f\u9650\u304c\u3042\u308a\u307e\u3059\u3002<\/span><br><span data-path-to-node=\"32,0\" style=\"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); white-space: normal;\">\u30ea\u30d5\u30ec\u30c3\u30b7\u30e5\u30c8\u30fc\u30af\u30f3\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u65b0\u3057\u3044\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\u3092\u53d6\u5f97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/span>\u30ea\u30d5\u30ec\u30c3\u30b7\u30e5\u30c8\u30fc\u30af\u30f3\u306b\u3064\u3044\u3066\u306f\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5b9f\u88c5\u6b21\u7b2c\u3067\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">STEP 3: \u8eca\u4e21\u30ad\u30fc\u3068\u3057\u3066\u3001Tesla\u306b\u516c\u958b\u9375\u3092\u767b\u9332\u3059\u308b<\/h2>\n\n\n\n<p>API\u7d4c\u7531\u3067\u8eca\u4e21\u3092\u64cd\u4f5c\uff08\u30b3\u30de\u30f3\u30c9\u9001\u4fe1\uff09\u3059\u308b\u305f\u3081\u306b\u306f\u3001Tesla\u306e\u30af\u30e9\u30a6\u30c9\u3068\u300c\u8eca\u4e21\u672c\u4f53\u300d\u306e\u4e21\u65b9\u306b\u3001\u4f5c\u6210\u3057\u305f\u516c\u958b\u9375\u3092\u767b\u9332\u30fb\u30da\u30a2\u30ea\u30f3\u30b0\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u64cd\u4f5c\u306e\u6d41\u308c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>3.1. Tesla\u516c\u5f0f\u30a2\u30d7\u30ea\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u304a\u308a\u3001\u30ed\u30b0\u30a4\u30f3\u6e08\u307f\u306e\u30b9\u30de\u30fc\u30c8\u30d5\u30a9\u30f3\u3092\u7528\u610f<\/p>\n\n\n\n<p>3.2. \uff08\u5ff5\u306e\u305f\u3081\uff09\u7269\u7406\u7684\u30ad\u30fc\u30ab\u30fc\u30c9\u3092\u6301\u3063\u3066\u3001\u8eca\u4e21\u306b\u4e57\u308a\u8fbc\u3080<\/p>\n\n\n\n<p>3.3. \u4ee5\u4e0b\u306eURL\u306b\u30a2\u30af\u30bb\u30b9\u3057\u307e\u3059\u3002<br>\u3000<a href=\"https:\/\/tesla.com\/_ak\/\u81ea\u5206\u306e\u30c9\u30e1\u30a4\u30f3\">https:\/\/tesla.com\/_ak\/\u81ea\u5206\u306e\u30c9\u30e1\u30a4\u30f3<\/a><\/p>\n\n\n\n<p>3.4.&nbsp;Finish Setup \u3092\u30bf\u30c3\u30d7\u3059\u308b\u3068\u3001\u81ea\u52d5\u7684\u306bTesla\u516c\u5f0f\u30a2\u30d7\u30ea\u304c\u8d77\u52d5\u3057\u307e\u3059\u3002<br>\u300c\u30b5\u30fc\u30c9\u30d1\u30fc\u30c6\u30a3\u30a2\u30d7\u30ea\u306b\u30a2\u30af\u30bb\u30b9\u3092\u8a31\u53ef\u3057\u307e\u3059\u304b\uff1f\u300d\u3068\u3044\u3046\u78ba\u8a8d\u753b\u9762\u3092\u78ba\u8a8d\u3057\u3001\u627f\u8a8d\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>\u203b\u8eca\u4e21\u306e\u30b3\u30f3\u30bd\u30fc\u30eb\u753b\u9762\u306b\u30ad\u30fc\u30ab\u30fc\u30c9\u3092\u304b\u3056\u3059\u3088\u3046\u6c42\u3081\u3089\u308c\u305f\u5834\u5408\u306f\u3001\u6307\u793a\u306b\u5f93\u3063\u3066\u7269\u7406\u30ad\u30fc\u304b\u3056\u3059<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">STEP 4: \u516c\u5f0f\u30c4\u30fc\u30eb\uff08tesla-control\uff09\u306e\u5c0e\u5165\u3068API\u5b9f\u884c<\/h2>\n\n\n\n<p>Tesla\u516c\u5f0f\u304c\u63d0\u4f9b\u3057\u3066\u3044\u308bGo\u8a00\u8a9e\u306eCLI\u30c4\u30fc\u30eb\u300ctesla-control\u300d\u3092\u5229\u7528\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">4.1. Go\u8a00\u8a9e\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h4>\n\n\n\n<p>tesla-control&nbsp;\u3092\u30d3\u30eb\u30c9\u30fb\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u305f\u3081\u306b\u3001\u307e\u305a\u306f\u30b5\u30fc\u30d0\u306bGo\u8a00\u8a9e\u74b0\u5883\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update\nsudo apt install golang -y\n\n# \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u78ba\u8a8d\ngo version<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">4.2. tesla-control \u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h4>\n\n\n\n<p><span style=\"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: -webkit-standard; font-size: medium; white-space: normal;\">Go\u74b0\u5883\u304c\u6574\u3063\u305f\u3089\u3001Tesla\u516c\u5f0f\u306eGitHub\u30ea\u30dd\u30b8\u30c8\u30ea\u304b\u3089&nbsp;<\/span><code data-path-to-node=\"5\" data-index-in-node=\"59\" style=\"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); white-space: normal;\">tesla-control<\/code><span style=\"caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: -webkit-standard; font-size: medium; white-space: normal;\">&nbsp;\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>go install https:\/\/github.com\/teslamotors\/vehicle-command\/cmd\/tesla-control@latest<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">4.3. \u5b9f\u884c\u74b0\u5883\uff08\u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3068\u30d5\u30a1\u30a4\u30eb\uff09\u306e\u6e96\u5099<\/h4>\n\n\n\n<p>\u30b9\u30af\u30ea\u30d7\u30c8\u3084\u30c8\u30fc\u30af\u30f3\u3092\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306e\u4f5c\u696d\u7528\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u3001STEP 2.5\u3067\u53d6\u5f97\u3057\u305f\u30c8\u30fc\u30af\u30f3\u3092\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001STEP 1\u3067\u4f5c\u6210\u3057\u305f\u79d8\u5bc6\u9375\u3082\u3053\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u96c6\u7d04\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u4f5c\u696d\u7528\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u4f5c\u6210\u3000\u203b\u4efb\u610f\u3067\u8aad\u307f\u66ff\u3048\u3066\u304f\u3060\u3055\u3044\u3002\nmkdir -p ~\/TESLA-POST \ncd ~\/TESLA-POST\n\n# STEP 1\u3067\u4f5c\u6210\u3057\u305f\u79d8\u5bc6\u9375\u3092\u4f5c\u696d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u30b3\u30d4\u30fc\ncp ~\/pem\/private_key.pem .\/\n\n# \u30c8\u30fc\u30af\u30f3\u3092\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3059\u308b\n\u3010\u3011\u306e\u4e2d\u8eab\u3092\u5b9f\u969b\u306e\u30c8\u30fc\u30af\u30f3\u306b\u7f6e\u304d\u63db\u3048\u3066\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\n\necho \"\u3010STEP2.5\u3067\u53d6\u5f97\u3057\u305f\u30a2\u30af\u30bb\u30b9\u30c8\u30fc\u30af\u30f3\u3011\" &gt; token.txt\necho \"\u3010STEP2.5\u3067\u53d6\u5f97\u3057\u305f\u30ea\u30d5\u30ec\u30c3\u30b7\u30e5\u30c8\u30fc\u30af\u30f3\u3011\" &gt; refresh_token.txt<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>4.4. \u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3059\u308b<\/strong><\/h4>\n\n\n\n<p><br>Python\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u30fb\u5b9f\u884c\u3057\u3066\u6b63\u3057\u304f\u52d5\u4f5c\u3059\u308b\u304b\u30c6\u30b9\u30c8\u3057\u307e\u3059\u3002<br>\uff08\u30b5\u30f3\u30d7\u30eb\u3092\u304a\u3044\u3066\u304a\u304d\u307e\u3059\uff09<\/p>\n\n\n\n<p> \u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u306e\u30d1\u30b9\u3084VIN\uff08\u8eca\u53f0\u756a\u53f7\uff09\u3001\u30a2\u30f3\u30da\u30a2\u6570\u3092\u3054\u81ea\u8eab\u306e\u74b0\u5883\u306b\u5408\u308f\u305b\u3066\u5909\u66f4\u3057\u3001\u5b9f\u884c\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>touch test_amps.py\nvim test_anps.py<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>import subprocess\nimport os\n\n# === \u8a2d\u5b9a\u9805\u76ee ===\nBASE_DIR = \"\u4ee5\u4e0b\u306ePATH\u304c\u542b\u307e\u308c\u308b\u30eb\u30fc\u30c8\u30d1\u30b9\"\n\nTESLA_CONTROL_PATH = os.path.join(BASE_DIR, \"\u624b\u98064-3\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305fvehicle-command\u306e\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\")\nTOKEN_FILE = os.path.join(BASE_DIR, \"\u30c8\u30fc\u30af\u30f3\u3092\u4fdd\u5b58\u3057\u305fTXT\u306e\u30d1\u30b9 token.txt\")\nKEY_FILE = os.path.join(BASE_DIR, \"\u79d8\u5bc6\u9375\u3092\u4fdd\u5b58\u3057\u305fTXT\u306e\u30d1\u30b9 private.pem\") \n\nVIN = \"\u64cd\u4f5c\u5bfe\u8c61\u306eVIM\u3092\u5927\u6587\u5b57\u3067\u5165\u529b\"\nAPI_URL = \"https:\/\/fleet-api.prd.na.vn.cloud.tesla.com\"\n# =================\n\ndef set_charging_amps(amps):\n    if not os.path.exists(TOKEN_FILE):\n        print(f\"\u30c8\u30fc\u30af\u30f3\u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093: {TOKEN_FILE}\")\n        return\n    if not os.path.exists(KEY_FILE):\n        print(f\"\u79d8\u5bc6\u9375({KEY_FILE})\u304c\u898b\u3064\u304b\u308a\u307e\u305b\u3093\")\n        return\n\n    # Fleet API\u3092\u4f7f\u3046\u305f\u3081\u306e\u74b0\u5883\u5909\u6570\u3092\u30bb\u30c3\u30c8\n    env = os.environ.copy()\n    env&#91;\"TESLA_API_URL\"] = API_URL\n\n    # tesla-control \u306e\u30b3\u30de\u30f3\u30c9\u30ea\u30b9\u30c8\u3092\u7d44\u307f\u7acb\u3066\u308b\n    command = &#91;\n        TESLA_CONTROL_PATH,\n        \"-command-timeout\", \"30s\",\n        \"-key-file\", KEY_FILE,\n        \"-token-file\", TOKEN_FILE, # token.txt\u3092\u76f4\u63a5\u8aad\n        \"-vin\", VIN,\n        \"-ble=false\", # Bluetooth\u3067\u306f\u306a\u304f\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u7d4c\u7531(Fleet API)\u3092\u4f7f\u3046\n        \"charging-set-amps\", str(amps)\n    ]\n\n    print(f\"Tesla (VIN: {VIN}) \u306b {amps}A \u3078\u306e\u5909\u66f4\u30b3\u30de\u30f3\u30c9\u3092\u9001\u4fe1\u4e2d...\")\n\n    try:\n        # \u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u884c\uff01\n        result = subprocess.run(\n            command, \n            env=env,\n            capture_output=True, \n            text=True, \n            check=True\n        )\n        print(\" \u6210\u529f\")\n        print(\"\u30ec\u30b9\u30dd\u30f3\u30b9:\", result.stdout.strip())\n\n    except subprocess.CalledProcessError as e:\n        print(\"\u30a8\u30e9\u30fc\u3042\u308a\")\n        print(\"\u7d42\u4e86\u30b3\u30fc\u30c9:\", e.returncode)\n        print(\"\u30a8\u30e9\u30fc\u5185\u5bb9:\", e.stderr.strip())\n\nif __name__ == \"__main__\":\n    # \u30c6\u30b9\u30c8\u5b9f\u884c: \u4f8b\u3068\u3057\u306616A\u306b\u5909\u66f4\n    set_charging_amps(16)<\/code><\/pre>\n\n\n\n<p>\u5b9f\u884c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>python test_amps.py<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u307e\u3068\u3081<\/h2>\n\n\n\n<p>\u30c6\u30b9\u30e9\u306e\u9b45\u529b\u306f\u3053\u3046\u3044\u3063\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u3088\u3063\u3066\u3001\u8eca\u4e21\u3092\u5236\u5fa1\u3067\u304d\u308b\u306e\u304c\u697d\u3057\u3044\u3067\u3059\u306d\u3002<br>\u30a4\u30f3\u30d5\u30e9\u30a8\u30f3\u30b8\u30cb\u30a2\u306b\u306f\u3061\u3087\u3063\u3068\u96e3\u3057\u304b\u3063\u305f\u3067\u3059<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tesla API\uff08Fleet API\uff09\u306e\u5b9f\u88c5\u306b\u3064\u3044\u3066\u3001\u5099\u5fd8\u9332\u3068\u3057\u3066\u307e\u3068\u3081\u307e\u3059\u3002 1. \u524d\u63d0\u6761\u4ef6 1.1. \u5fc5\u8981\u306a\u3082\u306e \u5fc5\u8981\u306a\u57fa\u76e4\u3068\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002 \u30fb\u30b5\u30fc\u30d0\u57fa\u76e4\uff1a\u3000\u79c1\u306e\u74b0\u5883\u3067\u306fProxmox\u4e0a\u306edebia &hellip; <a href=\"https:\/\/cre-noa.me\/?p=73\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;Tesla \u30d5\u30ea\u30fc\u30c8API \u5b9f\u88c5\u306e\u5099\u5fd8&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-73","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/cre-noa.me\/index.php?rest_route=\/wp\/v2\/posts\/73","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cre-noa.me\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cre-noa.me\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cre-noa.me\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cre-noa.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=73"}],"version-history":[{"count":27,"href":"https:\/\/cre-noa.me\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions"}],"predecessor-version":[{"id":105,"href":"https:\/\/cre-noa.me\/index.php?rest_route=\/wp\/v2\/posts\/73\/revisions\/105"}],"wp:attachment":[{"href":"https:\/\/cre-noa.me\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=73"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cre-noa.me\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=73"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cre-noa.me\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=73"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}