Skip to main content

A Python SDK for the Cocoro API

Project description

Sharp Cocoro Air SDK in python

Basically a quick and dirty conversion of https://github.com/dvcrn/cocoro-sdk/ into python. Probably some bugs along the way.

Installation

uv add sharp-cocoro

Or install from source:

git clone https://github.com/dvcrn/sharp-cocoro
cd sharp-cocoro
uv sync

Usage:

For auth, read: https://github.com/dvcrn/cocoro-sdk/tree/master?tab=readme-ov-file#authentication

async def main():
    app_secret = ''
    app_key = ''
    # iClub is the default service name, you can also leave it out
    async with Cocoro(app_secret=app_secret, app_key=app_key) as cocoro:
        await cocoro.login()
        devices = await cocoro.query_devices()
        device = devices[0]


        all_props = device.get_all_properties()
        for prop in all_props:
            print(prop)

        if isinstance(device, Aircon):
            aircon = device

            print("power state")
            print(device.get_power_status())

            device.queue_temperature_update(23.5)
            aircon.queue_power_on()
            device.queue_property_status_update(aircon.get_property_status(StatusCode.OPERATION_MODE))

            print(await cocoro.execute_queued_updates(aircon))
        else:
            print("The first device is not an Aircon")

# Run the async function
asyncio.run(main())

To get a property:

# example: get the operation mode
status = device.get_property_status(StatusCode.OPERATION_MODE.value)
assert isinstance(status, SinglePropertyStatus)
print(ValueSingle(status.valueSingle['code'])) # returns the operation mode

To set it:

device.queue_property_status_update(ValueSingle.OPERATION_COOL)
await cocoro.execute_queued_updates(device)

To get an overview of all properties available

device.dump_all_properties()

# 動作状態 (80): ON (30), set=True get=True options=['ON', 'OFF']
# 冷房モード時温度設定値 (B5): None, set=True get=True
# ...

Each property also includes information on

  • It's type (binary, single, range)
  • Whether it is settable or gettable
  • And options that are allowed. In the example above, we can set the power mode only to ON or OFF

License

MIT

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

sharp_cocoro-0.2.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sharp_cocoro-0.2.0-py3-none-any.whl (2.1 kB view details)

Uploaded Python 3

File details

Details for the file sharp_cocoro-0.2.0.tar.gz.

File metadata

  • Download URL: sharp_cocoro-0.2.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.12

File hashes

Hashes for sharp_cocoro-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1b4db94b46fb5e44511fafe0d98ea4e54d66f45d4d5e2f0d23d8f86bdd32b425
MD5 a7954c559411aee08d100cfb905824cc
BLAKE2b-256 6a140442b8ef391510355f081e50c25d8d48b8292254fd71b98fbdfe3906055a

See more details on using hashes here.

File details

Details for the file sharp_cocoro-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sharp_cocoro-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c60737e8754ae2553c566f275b1a2c2f2710f304f6e64a26a58a2a2012d999e6
MD5 1716c3269a0a20c3270cabe73932ca06
BLAKE2b-256 35a8d1b552d123f1783d7f76ec5d80b195e2c3a500579a3a78d693be14cf997e

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