Skip to main content

Switcher Python Integration.

Project description

Switcher Python Integration
pypi-version pypi-downloads license-badge

gh-build-status gh-pages-status codecov

PyPi module integrating with various Switcher devices.
Check out the wiki pages for a list of supported devices.

pip install aioswitcher
Documentation Wiki Contributing Code of Conduct

Example Usage

State Bridge
async def print_devices(delay):
    def on_device_found_callback(device):
        # a switcher device will broadcast a state message approximately every 4 seconds
        print(asdict(device))

    async with SwitcherBridge(on_device_found_callback):
        await asyncio.sleep(delay)

# run the bridge for 60 seconds
asyncio.get_event_loop().run_until_complete(print_devices(60))
Power Plug API
async def control_power_plug(device_ip, device_id) :
    # for connecting to a device we need its id and ip address
    async with SwitcherType1Api(device_ip, device_id) as api:
        # get the device current state
        await api.get_state()
        # turn the device on
        await api.control_device(Command.ON)
        # turn the device off
        await api.control_device(Command.OFF)
        # set the device name to 'my new name'
        await api.set_device_name("my new name")

asyncio.get_event_loop().run_until_complete(control_power_plug("111.222.11.22", "ab1c2d"))
Water Heater API
async def control_water_heater(device_ip, device_id) :
    # for connecting to a device we need its id and ip address
    async with SwitcherType1Api(device_ip, device_id) as api:
        # get the device current state
        await api.get_state()
        # turn the device on for 15 minutes
        await api.control_device(Command.ON, 15)
        # turn the device off
        await api.control_device(Command.OFF)
        # set the device name to 'my new name'
        await api.set_device_name("my new name")
        # configure the device for 02:30 auto shutdown
        await api.set_auto_shutdown(timedelta(hours=2, minutes=30))
        # get the schedules from the device
        await api.get_schedules()
        # delete and existing schedule with id 1
        await api.delete_schedule("1")
        # create a new recurring schedule for 13:00-14:30
        # executing on sunday and friday
        await api.create_schedule("13:00", "14:30", {Days.SUNDAY, Days.FRIDAY})

asyncio.get_event_loop().run_until_complete(control_water_heater("111.222.11.22", "ab1c2d"))
Runner API
async def control_runner(device_ip, device_id) :
    # for connecting to a device we need its id and ip address
    async with SwitcherType2Api(device_ip, device_id) as api:
        # get the device current state
        await api.get_shutter_state()
        # open the shutter to 30%
        await api.set_position(30)
        # stop the shutter if currently rolling
        await api.stop()

asyncio.get_event_loop().run_until_complete(control_runner("111.222.11.22", "ab1c2d"))
Breeze API
async def control_breeze(device_ip, device_id, remote_manager, remote_id) :
    # for connecting to a device we need its id and ip address
    async with SwitcherType2Api(device_ip, device_id) as api:
        # get the device current state
        await api.get_breeze_state()
        # initialize the Breeze RemoteManager and get the remote
        remote = remote_manager.get_remote(remote_id)
        # prepare a control command that turns on the Breeze
        # set to 24 degree (Celsius) cooling with vertical swing
        # and keep the current Fan Level
        command: SwitcherBreezeCommand = remote.get_command(
            DeviceState.ON,
            ThermostatMode.COOL,
            24,
            resp.fan_level,
            ThermostatSwing.ON,
            response.state
        )
        # send command to the device
        await api.control_breeze_device(command)

# create the remote manager outside the context for re-using
remote_manager = SwitcherBreezeRemoteManager()
asyncio.get_event_loop().run_until_complete(control_breeze("111.222.11.22", "ab1c2d", remote_manager, "DLK65863"))

Command Line Helper Scripts

Disclaimer

This is NOT an official module and it is NOT officially supported by the vendor.
That said, thanks are in order to all the people at Switcher for their cooperation and general support.

Contributors

Thanks goes to these wonderful people (emoji key):


Aviad Golan

🔣

Dolev Ben Aharon

📖

Fabian Affolter

💻

Or Bin

💻

Shai rod

🔣

Shay Levy

💻 🤔 🚧

dmatik

📝 🤔 📓

jafar-atili

💻 📖

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

aioswitcher-3.0.1.tar.gz (519.0 kB view details)

Uploaded Source

Built Distribution

aioswitcher-3.0.1-py3-none-any.whl (556.3 kB view details)

Uploaded Python 3

File details

Details for the file aioswitcher-3.0.1.tar.gz.

File metadata

  • Download URL: aioswitcher-3.0.1.tar.gz
  • Upload date:
  • Size: 519.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.10.6 Linux/5.15.0-1019-azure

File hashes

Hashes for aioswitcher-3.0.1.tar.gz
Algorithm Hash digest
SHA256 71da88c5ba355b6eedcb9fbd00f79ab560bebed4a732f017e9bc90dc7a124bcb
MD5 a1d204cb55037876f986efc6335aa11d
BLAKE2b-256 0c558ad8efebafea54ba9787b143d17081c6a0a885518e4c13c97361e0296295

See more details on using hashes here.

File details

Details for the file aioswitcher-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: aioswitcher-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 556.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0 CPython/3.10.6 Linux/5.15.0-1019-azure

File hashes

Hashes for aioswitcher-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 52d044c98171c5872514adbf6b40470a44d14a1ff12ff3566b4e02b5edcfda4b
MD5 aff731fb5e20a5d87ef33de6b468962d
BLAKE2b-256 af959e6c50dad074ea2aa14358d86699246c2977330f9e8ce6c59ca473629b0b

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