cocoro


Namecocoro JSON
Version 0.1.5 PyPI version JSON
download
home_pagehttps://github.com/rcmdnk/cocoro
SummaryUtilities to use Sharp, COCORO API
upload_time2024-05-23 00:25:14
maintainerNone
docs_urlNone
authorrcmdnk
requires_python<4.0,>=3.8
licenseApache-2.0
keywords sharp api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # cocoro

[![PyPI version](https://badge.fury.io/py/cocoro.svg)](https://badge.fury.io/py/cocoro)
[![COCORO test](https://github.com/rcmdnk/cocoro/actions/workflows/cocoro-test.yml/badge.svg)](https://github.com/rcmdnk/cocoro/actions/workflows/cocoro-test.yml)

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 加湿空気清浄機/空気清浄機:シャープ](https://jp.sharp/kuusei/products/kijs50/)).

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](https://mitmproxy.org/).

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](https://github.com/rcmdnk/cocoro/blob/main/pic/getcookie.jpg?raw=true)


    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**:

```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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/rcmdnk/cocoro",
    "name": "cocoro",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "Sharp, API",
    "author": "rcmdnk",
    "author_email": "rcmdnk@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/5b/8a/46957c0c04951742dd8f88679b9bff74bcc9c7695a8cf4a8f5dab5f992fc/cocoro-0.1.5.tar.gz",
    "platform": null,
    "description": "# cocoro\n\n[![PyPI version](https://badge.fury.io/py/cocoro.svg)](https://badge.fury.io/py/cocoro)\n[![COCORO test](https://github.com/rcmdnk/cocoro/actions/workflows/cocoro-test.yml/badge.svg)](https://github.com/rcmdnk/cocoro/actions/workflows/cocoro-test.yml)\n\nTools for COCORO API (SHARP products).\n\n## Install and Usage\n\n### Using pip\n\n    $ pip install cocoro\n\n### Using source code\n\nUse poetry to setup the environment.\n\n    $ pip install poetry\n    $ git clone https://github.com/rcmdnk/cocoro.git\n    $ cd cocoro\n    $ poetry install\n\n## Appliances\n\nAPI commands were taken for Sharp, KI-JS50 (humidifying air purifier, [KI-JS50 \u52a0\u6e7f\u7a7a\u6c17\u6e05\u6d44\u6a5f/\u7a7a\u6c17\u6e05\u6d44\u6a5f\uff1a\u30b7\u30e3\u30fc\u30d7](https://jp.sharp/kuusei/products/kijs50/)).\n\nIt may work for other (humidifying) air purifiers.\n\n## Requirement\n\nYou need to get `appSecret` and `terminalAppIdKey` to control appliances.\n\nTo get them, you can use [mitmproxy](https://mitmproxy.org/).\n\nBy using mitmproxy, you will see following `POST` command while you are controlling COCORO in your smart phone:\n\n\n    POST https://hms.cloudlabs.sharp.co.jp/hems/pfApi/ta/setting/login/?appSecret=XXXXXXXXX\u2026\n           \u2190 200 application/json 38b 308ms\n\nOpen this command and you will see following in `Request tab:\n\n![pic](https://github.com/rcmdnk/cocoro/blob/main/pic/getcookie.jpg?raw=true)\n\n\n    2021-02-21 21:55:40 POST https://hms.cloudlabs.sharp.co.jp/hems/pfApi/ta/setting/login/?app\n                             Secret=<*************appSecret**********************>&serviceName=\n                             iClub\n                             \u2190 200 OK application/json 38b 308ms\n                Request                         Response                        Detail\n    Host:             hms.cloudlabs.sharp.co.jp\n    Content-Type:     application/json; charset=utf-8\n    Connection:       keep-alive\n    Accept:           */*\n    User-Agent:       smartlink_v200i Mozilla/5.0 (iPhone; CPU iPhone OS 14_4 like Mac OS X)\n                      AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148\n    Content-Length:   110\n    Accept-Language:  ja-jp\n    Accept-Encoding:  gzip, deflate, br\n    JSON                                                                                  [m:auto]\n    {\n        \"terminalAppId\":\n    \"https://db.cloudlabs.sharp.co.jp/clpf/key/<************terminalAppIdKey*************>\"\n    }\n\nFind `appSecret` and `terminalAppIdKey` values from above details.\n\nThen, make following configuration file as **~/.config/cocoro/config.yml**:\n\n```yml\n---\nappSecret: <*************appSecret**********************>\nterminalAppIdKey: <************terminalAppIdKey*************>\n```\n\n## Usage\n\nIf you installed cocoro by `pip`, do:\n\n    $ cocoro <cmd> [options]\n\nIf you installed from source code, go to cocoro directory, then do:\n\n    $ poetry run cocoro <cmd> [options]\n\nAvailable commands (`<cmd>`) are:\n\n* `switch <target>`: Control switch. Available targets: `on`, `off`.\n* `humidification <target>`: Control humidification. Available targets: `on`, `off`.\n* `humi <target>`  : Alias of humidification.\n* `mode <target>`  : Control mode. Available targets: `auto`, `sleep`, `pollen`,\n                     `quiet`, `medium`, `high`, `recommendation`, `effective`\n* `info [key]`     : Show the appliance information. The available keys are:\n                     `full`(full echonetData), `labelData`, `maker`, `model`,\n                     `deviceType`, `name`, `place`, `yomi`, `zipCd`\n                     If no key is give, labelData is shown.\n* `version`: Show   version.\n* `help`: Show help.\n\nOther options:\n\n* `--config_file <file>`: Set configuration file. Default file path is `~/.config/cocoro/config.yml`.\n* `--appSecret <appSecret>`: Set appSecret (overwrite the value of config_file).\n* `--terminalAppIdKey <terminalAppIdKey>`: Set terminalAppIdKey (overwrite the value of config_file).\n* `--name <name>`: Set name of the device. If no name is given, the first device is used.\n* `--log_level <level>`: Set log level. The available levels are: `debug`, `info`, `warning` `fatal`.\n\n\n## Examples\n\n    $ cocoro switch on\n    [INFO][Cocoro] Succeeded to control js50: switch on\n    $ cocoro humi off\n    [INFO][Cocoro] Succeeded to control js50: humidification off\n    $ cocoro mode auto\n    [INFO][Cocoro] Succeeded to control js50: mode auto\n\n\n    $ cocoro info\n    [INFO][Cocoro] Device information\n    {'id': 123456, 'place': '\u30ea\u30d3\u30f3\u30b0', 'name': 'my js50', 'deviceType': 'AIR_CLEANER', 'zipCd': '7890123', 'yomi': '', 'lSubInfo': '{\"room_data\":{\"size\": 10.0, \"struct\": \"prefab\", \"unit\": \"tatami\"}}'}\n    $ cocoro info model --log_level=warning\n    KIJS50\n    $ cocoro info maker --log_level=warning\n    SHARP\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Utilities to use Sharp, COCORO API",
    "version": "0.1.5",
    "project_urls": {
        "Homepage": "https://github.com/rcmdnk/cocoro",
        "Repository": "https://github.com/rcmdnk/cocoro"
    },
    "split_keywords": [
        "sharp",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d5152d6922190dd0782c081381d9fcd16fd1d676de94aa726ae0e2294647e847",
                "md5": "7382252fd0fe46f497b7de0b85e54809",
                "sha256": "fddd9bfb8097f1ab80fa9cb5ef7042a7a71e3274273bc1f03b2c337ad6019a66"
            },
            "downloads": -1,
            "filename": "cocoro-0.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7382252fd0fe46f497b7de0b85e54809",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 11161,
            "upload_time": "2024-05-23T00:25:12",
            "upload_time_iso_8601": "2024-05-23T00:25:12.565157Z",
            "url": "https://files.pythonhosted.org/packages/d5/15/2d6922190dd0782c081381d9fcd16fd1d676de94aa726ae0e2294647e847/cocoro-0.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5b8a46957c0c04951742dd8f88679b9bff74bcc9c7695a8cf4a8f5dab5f992fc",
                "md5": "8b0a4fb8586aad0154afc9b6873b0ebc",
                "sha256": "46adb5890d120becb5fccb2ab7ff83d75ef69d28eab20d1c2df203089170381b"
            },
            "downloads": -1,
            "filename": "cocoro-0.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "8b0a4fb8586aad0154afc9b6873b0ebc",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 9518,
            "upload_time": "2024-05-23T00:25:14",
            "upload_time_iso_8601": "2024-05-23T00:25:14.403462Z",
            "url": "https://files.pythonhosted.org/packages/5b/8a/46957c0c04951742dd8f88679b9bff74bcc9c7695a8cf4a8f5dab5f992fc/cocoro-0.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-23 00:25:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "rcmdnk",
    "github_project": "cocoro",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "cocoro"
}
        
Elapsed time: 0.24460s