1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

TP-LINKのスマートスイッチの電力をNODE-REDで見る

Last updated at Posted at 2024-12-10

はじめに

手軽に電力を測りたい。
だけど、どこかのネットサービスには頼りたくない。
という事で
Matterに対応したTP-Link Tapo P110Mを購入してみました。(Amazonで1500円くらい)
https://www.tp-link.com/jp/technology/matter/
https://www.tp-link.com/jp/home-networking/smart-plug/tapo-p110m/
https://amzn.asia/d/ivaMfzS

しかし、使い方が悪いのか、Node-redのMatterノードで簡単に電力の取得出来そうにない。On-Offはできそう。(断念)
https://github.com/FezVrasta/node-red-matter
https://github.com/sammachin/node-red-matter-bridge

Node.js では以下のプロジェクトが進行中なので今後を期待!(上記2つもそれを利用したもの?)
https://github.com/project-chip/matter.js/

という事で、終わり......じゃなくて
https://github.com/mbserran/node-red-contrib-tapo-new-api
を利用してみました。

設定

Node-redはインストール済みとします。

Appをインストールします。

自分はiPhoneです。
インストールした後は、画面に沿ってTP-Link IDを作成します。
(自分は、WiFi-APでIDを作っていたのを忘れていました。)

デバイスの登録

Tapoアプリを立ち上げます
画面右上の+をタッチしデバイスを追加します。
プラグ->Tapo P110M を選びます。
同意した後
画面の指示に従って接続します。
画面に従って接続していきます。

パレットのインストール

パレットをインストールします。このパレットは、元々あったものをForkして修正したものです。

$ cd .node-red
$ npm i https://github.com/NW-Lab/node-red-contrib-tapo-new-api.git

作者のリポジトリからインストールする場合は、インストール後、P110Mで電力が測れるように修正します。

$ npm i https://github.com/mbserran/node-red-contrib-tapo-new-api.git

/.node-red/node_modules/node-red-contrib-tapo-new-api/nodes/tapo_klap_protocol.js の26行に”P110M”を加えます。

exports.supportEnergyUsage = ["P110", "P115","P110M"];

フローの作成と動作確認

Node-REDを動かします。

$ node-red

Nodeが増えているのでフローを作成します。

スクリーンショット 2024-12-08 21.02.50.png
Actionsノードを設定します。
Appを登録した時のメールアドレスとパスワードが必要です。
IPアドレスは、アプリで”デバイス設定”-->”端末情報”で調べられます。
Node-REDを動かすマシンと同じネットワークの必要があります。

Injectノードを押すとデバッグ情報に以下のデータがきます。

アプリと見比べると"cureent_power"が現在の電力で単位はmWみたいです。

という事でフローにテンプレートノードを加えて以下のように設定すると電力が得られます。

後は

後はDashBoardに接続するなり遊べます。
スクリーンショット 2024-12-08 21.36.48.png

終わりに

  • よく考えるとネットサービスが使えると遠隔操作ができたり、スマートフォンでみれたり便利ですよね。(職場のハンダゴテの切り忘れとかの確認など)。なのでMatterを使わないこの方法も有りかと思いました。
  • このパレットはローカルネットワークのみでした。(クラウド経由では有りません。クラウドは、Aliaseを見るためのものらしい)

参考 https://www.pc-koubou.jp/magazine/86980

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?