Skip to main content

Ondotori WebStorage API クライアント

Project description

ondotori-client

CI PyPI version License

概要

Ondotori WebStorage API(RTR500B/その他機種)を Python から簡単に操作するクライアントライブラリです。 本ライブラリは、おんどとり WebStorage API でデータ取得が可能な全ての機種に対応しています。

Quickstart

  1. Ondotori Web Storage のアカウントを作成し、使用する機器の設定を行ってください。

  2. 公式ページ を参照して、APIキーを取得してください。

  3. 本ライブラリをインストールします。 以下のいずれかの方法でインストールできます:

    • pip install ondotori-client
    • または、src/ondotori_client ディレクトリを直接ダウンロードして使用します。
  4. 下記の config.json 設定ファイル を参照して、プロジェクトのルートディレクトリに適当な名前(例:config.json)で保存してください。 このファイルは、OndotoriClient のインスタンスを作成する際に必要となります。

  5. 次節に記載されている「典型的な使い方」を参照し、Ondotori のデータを取得してください。

インストール

pip install ondotori-client

典型的な使い方

from ondotori_client.client import OndotoriClient, parse_current, parse_data
import pandas as pd

# — 設定ファイルを使う場合 —
client = OndotoriClient(config="config.json", device_type="rtr500", verbose=True)

# — 1. 現在値取得 —
data_cur = client.get_current("<remote_serial_key or remote_serial>")
ts, temp, hum = parse_current(data_cur)
print(f"現在値: {ts}{temp}℃ / {hum}%")

# — 2. 過去指定期間のログ取得 —
res = client.get_data("<remote_serial_key or remote_serial>", dt_from="2025-05-01T00:00:00", dt_to="2025-05-02T00:00:00")
times, temps, hums = parse_data(res)
df = pd.DataFrame({"time": times, "temp": temps, "hum": hums})
print(df.head())

# — 3. 直近300件ログ(または hours=1)を DataFrame で —
df_latest = client.get_data("<remote_serial_key or remote_serial>", hours=1, as_df=True)
print(df_latest.tail())

# — 4. アラートログ取得 —
alerts = client.get_alerts("<remote_serial_key or remote_serial>")
print(alerts)

config.json 設定ファイル

config.json は、Web Storage APIの設定を定義するファイルです。このファイルには、APIの認証情報、基本情報、接続するセンサーの設定などが含まれています。以下に、config.json の構造と各項目の説明を示します。

設定例 (configs/config.example.json)

{
    "api_key": "<YOUR_API_KEY>",
    "login_id": "<YOUR_LOGIN_ID>",
    "login_pass": "<YOUR_LOGIN_PASSWORD>",
  
    "default_rtr500_base": "name_base1",
  
    "bases": {
      "name_base1": {
        "serial": "<YOUR_BASE_SERIAL_FOR_BASE1>"
      }
    },
  
    "remote_map": {
      "name1_rtr500":   { "serial": "name1_rtr500",  "type": "rtr500",  "base": "BASE1" },
      "name2_rtr500":   { "serial": "name2_rtr500",  "type": "rtr500",  "base": "BASE1" },
      "name3_rtr500":   { "serial": "name3_rtr500",  "type": "rtr500",  "base": "BASE1" },
  
      "name1_default":  { "serial": "name1_default", "type": "default" },
      "name2_default":  { "serial": "name2_default", "type": "default" }
    }
}

各項目の説明

  • api_key: 必須のAPIキー。サービスにアクセスするために使用されます。(公式ページをご参照ください。)

  • login_idlogin_pass: Ondotori Web StrageのユーザーのログインIDとパスワード。これらを使用して、サービスにログインします。

  • default_rtr500_base: デフォルトで使用するベースの名前。(RTR500Bを使用する時のみ必要)

  • bases: 使用するベースの設定。ここでは、name_base1 のような名前のベースと、そのシリアル番号を指定します。(RTR500Bを使用する時のみ必要)

  • remote_map: 各センサーとその設定をマッピングするための部分です。name1_rtr500 のようなセンサー名に対して、シリアル番号、タイプ、ベースを設定します。

    • key: センサーの名前(自由に設定して構いません。OndotoriClientのインスタンスメソッドの引数に使います。)
    • serial: シリアル番号(OndotoriのWeb Strageの機器設定にて確認できます。)
    • base: RTR500Bを使用する時のみその親機の名前を設定します。(上記で設定したbasesの中から選んでください。指定しないとdefault_rtr500_baseで設定したものが使用されます。)

使用方法

  1. configs/config.example.json をコピーして、config.json ファイルを作成します。
  2. 必要な設定(APIキー、ログイン情報、ベースやセンサー情報)を config.json に記入します。
  3. config.json をプロジェクトのルートディレクトリに配置してください。

License

MIT © Hiroki Tsusaka

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ondotori_client-0.3.2.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ondotori_client-0.3.2-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file ondotori_client-0.3.2.tar.gz.

File metadata

  • Download URL: ondotori_client-0.3.2.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for ondotori_client-0.3.2.tar.gz
Algorithm Hash digest
SHA256 585d9486431b33b56fed7ee5ac42be033051a9f0203f1bc0bd6053d64c1f2447
MD5 f3bbdeb66fc94f336ec3166d260fa690
BLAKE2b-256 e618e67ac50d99938617bb6ea35d81577357be852cebe2cb66ce3cbf7cb0adda

See more details on using hashes here.

File details

Details for the file ondotori_client-0.3.2-py3-none-any.whl.

File metadata

File hashes

Hashes for ondotori_client-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b99d2dcc143ca1f22ce85e04e72b3187dfab1b740597519396f6d88a9fede644
MD5 acfa60fc9c308484a73fa2c34f689355
BLAKE2b-256 b5875a9608fb5c9de977016a4d2e7963c8f15390c55f3ce99e2dc4726f1081eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page