Skip to main content

Ondotori WebStorage API クライアント

Project description

ondotori-client

CI PyPI version License

概要

Ondotori WebStorage API(RTR500B/その他機種)を Python から簡単に操作するクライアントライブラリです。

Quickstart

  1. Ondotori Web Storage のアカウントを作成し、使用する機器の設定を行ってください。 本ライブラリは、おんどとり WebStorage API でデータ取得が可能な全ての機種に対応しています。

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: ondotori_client-0.2.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.2.2.tar.gz
Algorithm Hash digest
SHA256 26f64f15e1a89d127bbc0be59c11ca704d3e814d5c7de191f05567e2f9ed85af
MD5 5e52b94564f3a8dc9349eb2e857b5944
BLAKE2b-256 b6701d007f256a6235fca6eaf9fefaf3f9f884d786cf491db0eb8e24ebbc369a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ondotori_client-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4f610a6d9bedcc3b56d6f2323c593bf1fab02cb6bcb9180f81e942093a3d61fe
MD5 a1b5cf725f8ed874378511993008aff6
BLAKE2b-256 1b4cd51505e4b9608d61eb1a42cd01e3af86033cd460649251c26124c190aea2

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