Skip to main content

API wrapper for controlling the Sber smart bulb A60.

Project description

Sber Bulb API

Описание / Description

Эта библиотека предоставляет API-обертку для управления умной лампочкой от Сбера A60. Возможность работы с другими моделями не проверялась. Для использования данной библиотеки необходимо быть зарегистрированным пользователем в приложении Салют!, а также иметь лампочку, добавленную в это приложение.

This library provides an API wrapper for controlling the Sber A60 smart bulb. Compatibility with other models has not been tested. To use this library, you must be a registered user of the Salute! app and have the bulb added to your account.

Установка / Installation

pip install sber-bulb-api

Авторизация / Authorization

Авторизация через код / Authorization via code

Этот метод предназначен только для первичной авторизации. Чрезмерное использование может привести к блокировке или ограничению сервером. Получите refresh token и используйте метод авторизации через него.

This method is only intended for initial authorization. Excessive use may result in server blocking or restrictions. Obtain a refresh token and use the refresh token authorization method instead.

import asyncio

from sber_smart_bulb_api import SberSmartBulbAPI

PHONE = '79998887766'

async def auth():
    sber_api = SberSmartBulbAPI()
    response = await sber_api.authenticate(phone=PHONE)
    await asyncio.sleep(1)
    sms = input('SMS: ').strip()
    response = await sber_api.verify(ouid=response.ouid, sms_otp=sms)
    await sber_api.get_access_token(authcode=response.authcode)
    print(sber_api.refresh_token)  # Save refresh token

Авторизация через refresh token / Authorization via refresh token

Внимание: Refresh token одноразовый!

Warning: The refresh token is single-use!

from sber_smart_bulb_api import SberSmartBulbAPI

refresh_token = 'your_refresh_token'

async def main():
    sber_api = SberSmartBulbAPI(refresh_token=refresh_token)
    await sber_api.get_device_groups()
    print(sber_api.refresh_token)  # Save new refresh token

Использование / Usage

import asyncio

from sber_smart_bulb_api import SberSmartBulbAPI
from sber_smart_bulb_api.models import DeviceSceneEnum

refresh_token = 'your_refresh_token'

async def main():
    sber_api = SberSmartBulbAPI(refresh_token=refresh_token)
    groups = await sber_api.get_device_groups()
    print(sber_api.refresh_token)  # Save new refresh token
    group_id = groups.result[0].id
    devices = await sber_api.get_device_group_tree(group_id=group_id)
    device_id = [d.id for d in devices.devices if d.device_info.model == 'smart bulb a60'][0]
    device = await sber_api.get_device(device_id=device_id)
    states = await sber_api.get_device_states(device_id=device_id)
    print(
        f'Device: {device}',
        f'Status (on/off): {states.on_off}',
        f'Work Mode: {states.work_mode}',
        f'Online status: {states.online}',
        f'Scene: {states.light_scene}',
        f'White bright: {states.bright_value_v2}',
        f'White temp: {states.temp_value_v2}',
        f'Colour data: {states.colour_data_v2}',
        f'Sleep timer (minutes): {states.sleep_timer}',
        sep='\n'
    )
    await sber_api.set_on_off(device_id=device_id, value=True)
    await sber_api.set_white(device_id=device_id, brightness=50, temp=50)
    await asyncio.sleep(3)
    await sber_api.set_color(device_id=device_id, h=180, s=50, v=50)
    await asyncio.sleep(3)
    await sber_api.set_scene(device_id=device_id, scene=DeviceSceneEnum.candle)
    await asyncio.sleep(3)
    await sber_api.set_timer(device_id=device_id, minutes=30)
    await sber_api.set_on_off(device_id=device_id, value=False)
    await sber_api.close()

if __name__ == '__main__':
    asyncio.run(main())

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

sber_bulb_api-0.0.7.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

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

sber_bulb_api-0.0.7-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file sber_bulb_api-0.0.7.tar.gz.

File metadata

  • Download URL: sber_bulb_api-0.0.7.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for sber_bulb_api-0.0.7.tar.gz
Algorithm Hash digest
SHA256 9581983a5d1d8be8a3e5c0d20db542733b790c199df5baf58da45b19d6ad9d3d
MD5 f46c09373eca8e5f2f403b85e1f9fb40
BLAKE2b-256 e67c13b0baa9c8b859c1da099b797146d496adcc63df164d0625f12c0d5c36b9

See more details on using hashes here.

File details

Details for the file sber_bulb_api-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: sber_bulb_api-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for sber_bulb_api-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 9885f1e783032821e63bdbb9febc948d04b57931c1afbb7fd1e4d5fb2528ae4a
MD5 c23c7f16e2811aca32d1a99642871d37
BLAKE2b-256 48f075ce703ada077bd7a5923321c2e5f610ead5c581e398396ad618bb758976

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