Skip to main content

Control Shelly Home Automation Devices

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

Switch Control

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)

Device Discovery

from ishelly.client import ShellyDiscovery
discovery = ShellyDiscovery("10.0.0.0/24")
discovery.discover_devices()

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.6.tar.gz (92.9 kB view details)

Uploaded Source

Built Distribution

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

ishelly-0.1.6-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ishelly-0.1.6.tar.gz
  • Upload date:
  • Size: 92.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.20

File hashes

Hashes for ishelly-0.1.6.tar.gz
Algorithm Hash digest
SHA256 dd712d28383f4b549ee73aa9dc5ce27ef55a4ace314ff58e41ddbf8f58266fb0
MD5 ca79fd9433b0cbef463c76caadd87b40
BLAKE2b-256 2e18047b04959c30f284ce599206bbe0d9ca2274c7d49e8cc58503733fd0e895

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ishelly-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.20

File hashes

Hashes for ishelly-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 90d010e11328d7d8c4f7196b68ef73d1d6b281620331f9d8d81f23dc1d9c3374
MD5 30c6b23f0693335ea23bd1a71e3a4085
BLAKE2b-256 39119e624a37c7199cca462e50a65a10bcf706798671c1c7c9ea6cb1abf76225

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