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", verbose=True)

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

# — 2. 過去指定期間のログ取得 —
res = client.get_data("<remote_serial_key>", 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>", hours=1, as_df=True)
print(df_latest.tail())

# — 4. アラートログ取得 —
alerts = client.get_alerts("<remote_serial_key>")
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.5.tar.gz (21.5 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.5-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ondotori_client-0.3.5.tar.gz
Algorithm Hash digest
SHA256 d16db06ec019dbc3e77ab5cb87712629447c3b718ac7afdf6f8e1358a36eda7c
MD5 c7c18ed171ca71d3bdf0df31daa6aa27
BLAKE2b-256 9bfc75bb9eb322011b152b5c934d2dacc892cde0352b66139bee38933144d0d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ondotori_client-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 890ed496c5bf70673e9c53b150df77eb3b4d96c6d2b89ba7b258fad519ce995b
MD5 e69bcbfdad5b24e90c98c5ab43ddf2a4
BLAKE2b-256 f511ab897d9e4aa9cd18459036b3b4f63fdb9144cc34fb1b1661f7af748911ec

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