Skip to main content

Utilities to use Sharp, COCORO API

Project description

cocoro

PyPI version COCORO test

Tools for COCORO API (SHARP products).

Install and Usage

Using pip

$ pip install cocoro

Using source code

Use poetry to setup the environment.

$ pip install poetry
$ git clone https://github.com/rcmdnk/cocoro.git
$ cd cocoro
$ poetry install

Appliances

API commands were taken for Sharp, KI-JS50 (humidifying air purifier, KI-JS50 加湿空気清浄機/空気清浄機:シャープ).

It may work for other (humidifying) air purifiers.

Requirement

You need to get appSecret and terminalAppIdKey to control appliances.

To get them, you can use mitmproxy.

By using mitmproxy, you will see following POST command while you are controlling COCORO in your smart phone:

POST https://hms.cloudlabs.sharp.co.jp/hems/pfApi/ta/setting/login/?appSecret=XXXXXXXXX…
       ← 200 application/json 38b 308ms

Open this command and you will see following in `Request tab:

pic

2021-02-21 21:55:40 POST https://hms.cloudlabs.sharp.co.jp/hems/pfApi/ta/setting/login/?app
                         Secret=<*************appSecret**********************>&serviceName=
                         iClub
                         ← 200 OK application/json 38b 308ms
            Request                         Response                        Detail
Host:             hms.cloudlabs.sharp.co.jp
Content-Type:     application/json; charset=utf-8
Connection:       keep-alive
Accept:           */*
User-Agent:       smartlink_v200i Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X)
                  AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
Content-Length:   110
Accept-Language:  ja-jp
Accept-Encoding:  gzip, deflate, br
JSON                                                                                  [m:auto]
{
    "terminalAppId":
"https://db.cloudlabs.sharp.co.jp/clpf/key/<************terminalAppIdKey*************>"
}

Find appSecret and terminalAppIdKey values from above details.

Then, make following configuration file as ~/.config/cocoro/config.yml:

---
appSecret: <*************appSecret**********************>
terminalAppIdKey: <************terminalAppIdKey*************>

Usage

If you installed cocoro by pip, do:

$ cocoro <cmd> [options]

If you installed from source code, go to cocoro directory, then do:

$ poetry run cocoro <cmd> [options]

Available commands (<cmd>) are:

  • switch <target>: Control switch. Available targets: on, off.
  • humidification <target>: Control humidification. Available targets: on, off.
  • humi <target> : Alias of humidification.
  • mode <target> : Control mode. Available targets: auto, sleep, pollen, quiet, medium, high, recommendation, effective
  • info [key] : Show the appliance information. The available keys are: full(full echonetData), labelData, maker, model, deviceType, name, place, yomi, zipCd If no key is give, labelData is shown.
  • version: Show version.
  • help: Show help.

Other options:

  • --config_file <file>: Set configuration file. Default file path is ~/.config/cocoro/config.yml.
  • --appSecret <appSecret>: Set appSecret (overwrite the value of config_file).
  • --terminalAppIdKey <terminalAppIdKey>: Set terminalAppIdKey (overwrite the value of config_file).
  • --name <name>: Set name of the device. If no name is given, the first device is used.
  • --log_level <level>: Set log level. The available levels are: debug, info, warning fatal.

Examples

$ cocoro switch on
[INFO][Cocoro] Succeeded to control js50: switch on
$ cocoro humi off
[INFO][Cocoro] Succeeded to control js50: humidification off
$ cocoro mode auto
[INFO][Cocoro] Succeeded to control js50: mode auto


$ cocoro info
[INFO][Cocoro] Device information
{'id': 123456, 'place': 'リビング', 'name': 'my js50', 'deviceType': 'AIR_CLEANER', 'zipCd': '7890123', 'yomi': '', 'lSubInfo': '{"room_data":{"size": 10.0, "struct": "prefab", "unit": "tatami"}}'}
$ cocoro info model --log_level=warning
KIJS50
$ cocoro info maker --log_level=warning
SHARP

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

cocoro-0.1.5.tar.gz (9.5 kB view details)

Uploaded Source

Built Distribution

cocoro-0.1.5-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file cocoro-0.1.5.tar.gz.

File metadata

  • Download URL: cocoro-0.1.5.tar.gz
  • Upload date:
  • Size: 9.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/23.4.0

File hashes

Hashes for cocoro-0.1.5.tar.gz
Algorithm Hash digest
SHA256 46adb5890d120becb5fccb2ab7ff83d75ef69d28eab20d1c2df203089170381b
MD5 8b0a4fb8586aad0154afc9b6873b0ebc
BLAKE2b-256 5b8a46957c0c04951742dd8f88679b9bff74bcc9c7695a8cf4a8f5dab5f992fc

See more details on using hashes here.

File details

Details for the file cocoro-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: cocoro-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Darwin/23.4.0

File hashes

Hashes for cocoro-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 fddd9bfb8097f1ab80fa9cb5ef7042a7a71e3274273bc1f03b2c337ad6019a66
MD5 7382252fd0fe46f497b7de0b85e54809
BLAKE2b-256 d5152d6922190dd0782c081381d9fcd16fd1d676de94aa726ae0e2294647e847

See more details on using hashes here.

Supported by

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