Skip to main content

No project description provided

Project description

ishelly

A shelly api wrapper library which uses pydantic models to use the api and as much of the shelly v2 features as possible. No shelly v1 support planned.

This library was built with the support of the LightningSpore open-source mushroom growing project:

Supported Devices

Available Devices

  • Shelly Plug US
  • Shelly 2PM
  • Shelly Pro 4PM

Install

pip install ishelly

Usage

from ishelly.components.switch import *
from ishelly.components.schedule import *
from ishelly.components.shelly import *
from ishelly.client import ShellyPlug, Shelly2PM, ShellyPro4PM

# Initialize a Shelly Pro 4PM device object
plug_pro = ShellyPro4PM("http://192.168.1.125")

# Switch IDs for the high power outlets
switch_id_high_power_1 = 0
switch_id_high_power_2 = 3

# Step 1: Create a schedule to turn on the high power outlet 1 every 5 minutes
timespec_on = "0 */5 * * * *"
turn_on = SwitchSetRequest(
    id=1,
    params=SwitchSetParams(id=switch_id_high_power_1, toggle_after=90, on=True),
)

# Step 2: Add the scheduled task to the device
plug_pro.schedule.create(enable=True, timespec=timespec_on, calls=[turn_on])


# Step 3: Print the current schedules on the device
current_schedule = plug_pro.schedule.list()
for task in current_schedule.jobs:
    print(task)


# Step 4: Update an existing schedule (ID 4) to turn on the high power outlet 1 every 5 minutes
plug_pro.schedule.update(4, False, "0 */5 * * * *", calls=[turn_on])

# Step 5: Delete the schedule with ID 4
plug_pro.schedule.delete(4)

Example

The above example code, and more is located at: examples

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

ishelly-0.1.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

ishelly-0.1.2-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file ishelly-0.1.2.tar.gz.

File metadata

  • Download URL: ishelly-0.1.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for ishelly-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c8f7711c2bd456098d05e37b0ffb0a01b6827f2e9e87575346eec91e01812894
MD5 e75db203ab30e0119c44171f1df402c5
BLAKE2b-256 724d1088a60c74b62b2658750ddf1e6d342aef87e16289ab6a191c85a060149b

See more details on using hashes here.

File details

Details for the file ishelly-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: ishelly-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for ishelly-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5f4d57203ec821d1283ca575d36ad9f708a44e4a6a3cbab8576aabddf83eec81
MD5 2d3416d3feaa532adf05e500bcab3122
BLAKE2b-256 5f299e2e8997aa6965552e7f6b0f02f5934c5a818f01cdffa5014c9a95efab57

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