Giter Site home page Giter Site logo

cocoro's Introduction

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

cocoro's People

Contributors

dependabot[bot] avatar rcmdnk avatar renovate-bot avatar renovate[bot] avatar swsoyee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cocoro's Issues

[FYI] Recent models are not supported

Hi, thanks for developing interesting module 😃

This is just for your information.

I have tried to automate KI-PX* series, but recent models cannot be operated from the COCORO AIR app and must use the COCORO HOME app: https://jp.sharp/support/cloud/air/air_purifier.html

The API endpoint for COCORO HOME app is https://cocoroplusapp.jp.sharp instead of https://hms.cloudlabs.sharp.co.jp, in addition, the whole process of issuing JSESSIONID seems to be different, therefore your module could not be used for recent models.

Fortunately, the COCORO HOME application is partially a Web application and can be operated from a browser on a PC, so we can easily inspect HTTP communications by developer tools: https://cocoroplusapp.jp.sharp/air/welcome

On my side, to automate my air purifier using Python, I wrote the code with Selenium and requests (It works well, but it is made in an unmannerly way that requires logging in with ID and password every time, so I will not make it available to the public 😞).

If you are interested, try COCORO HOME. Please feel free to close this issue. Thanks!

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/cocoro-test.yml
  • actions/checkout v4
  • actions/setup-python v5
pep621
pyproject.toml
  • poetry-core >=1.0.0
poetry
pyproject.toml
  • python ^3.8
  • fire ^0.6.0
  • requests ^2.25.1
  • PyYAML ^6.0.0
  • pytest ^8.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.