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.0.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.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ondotori_client-0.3.0.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.0.tar.gz
Algorithm Hash digest
SHA256 a7ddfa68377ed4af9e2f3da7a9a2de0e1c3b47c8feaa00ce5c65b6903451e7f2
MD5 cb160cd8d3cbab9a5deac9776e5c041b
BLAKE2b-256 25d233721f71c1c9e291f3f54926a3dcf13a01d1f283578aa017f84393d553f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ondotori_client-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6539d89559e0debf96896be6d16236a1cd93f2b144bec6c47b882096dfce7a88
MD5 b695108f603beacd196dc8b61772eb5d
BLAKE2b-256 ea540e55db7e8ce9fb1811a7ac658cfb3ccbab452826da555fb4587ea3bd1388

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