Skip to main content

python-selve-new

PyPI version License: GPL v2+ Python 3.9+

Python library for interfacing with Selve devices (roller shutters, awnings, blinds) via the USB-RF Gateway. This is a complete rewrite of the original library with improved async support, comprehensive testing, and production-ready stability.

Description

This library provides a Python interface to control Selve devices through their USB-RF Gateway. It implements the complete Selve protocol for communication with:

  • Devices: Roller shutters, awnings, and blinds with individual or group control
  • Sensors: Temperature, wind, and light sensors for automated control
  • Iveo Controllers: Wall-mounted and remote controllers
  • Transmitters: RF transmitters for integration with other systems

The library features full async/await support, automatic device discovery, event handling, and robust error recovery. It's designed for integration into home automation systems like Home Assistant.

Features

  • Async Architecture: Built on asyncio for non-blocking operation
  • Auto-Discovery: Automatically finds USB-RF Gateway and configured devices
  • Device Management: Control individual devices or groups
  • Position Control: Precise positioning with percentage-based commands
  • Event System: Subscribe to device state changes and sensor readings
  • Error Handling: Robust error recovery and connection management
  • Comprehensive API: Full coverage of Selve protocol commands
  • Type Safety: Fully typed for better IDE support and fewer errors
  • Well Tested: 350+ unit and integration tests for production stability

Supported Device Types

  • Roller shutters (Commeo, Iveo)
  • Awnings
  • Venetian blinds
  • Group controls
  • senSim sensors (wind, sun, temperature)
  • Iveo remote controllers
  • RF transmitters

Installation

pip install python-selve-new

Usage

Basic Example

import asyncio
from selve import Selve

async def main():
    # Initialize and discover devices
    gateway = Selve()
    await gateway.setup()
    
    # Get all devices
    devices = gateway.discover_devices()
    print(f"Found {len(devices)} devices")
    
    # Control a device
    device = gateway.device(0)  # Get device by ID
    await device.open()         # Fully open
    await asyncio.sleep(5)
    await device.set_position(50)  # Move to 50%
    await asyncio.sleep(5)
    await device.close()        # Fully close
    
    # Cleanup
    await gateway.stopWorker()

asyncio.run(main())

Advanced Usage

import asyncio
from selve import Selve

async def on_state_change(device):
    """Callback when device state changes"""
    print(f"Device {device.id} changed to position {device.target_value}")

async def main():
    # Initialize with specific port
    gateway = Selve(port="/dev/ttyUSB0")
    await gateway.setup()
    
    # Register callback for state changes
    gateway.register_callback(on_state_change)
    
    # Discover all device types
    devices = gateway.discover_devices()
    groups = gateway.discover_groups()
    sensors = gateway.discover_sensors()
    
    print(f"Devices: {len(devices)}")
    print(f"Groups: {len(groups)}")
    print(f"Sensors: {len(sensors)}")
    
    # Control a group of devices
    if groups:
        group = gateway.group(0)
        await group.set_position(75)
    
    # Read sensor values
    for sensor in sensors:
        print(f"Sensor {sensor.id}: {sensor.value}")
    
    # Keep running to receive events
    try:
        await asyncio.sleep(3600)  # Run for 1 hour
    finally:
        await gateway.stopWorker()

asyncio.run(main())

Device Control Methods

# Position control
await device.open()              # Fully open (0%)
await device.close()             # Fully close (100%)
await device.stop()              # Stop movement
await device.set_position(50)    # Move to 50%

# State queries
position = device.target_value   # Current target position
state = device.state            # Current state (IDLE, MOVING, etc.)

# Device info
name = device.name              # Device name
device_type = device.type       # Device type

Gateway & Firmware Methods

# Firmware
version = await controller.firmwareGetVersion()  # Gateway firmware version

# Gateway parameters
await controller.setDuty(mode)         # Set duty cycle mode
await controller.setRF(addr)           # Set RF base address
temp = await controller.getTemperature() # Internal gateway temperature

Home Assistant Integration

This library is used by the homeassistant-selve integration to provide native Selve device support in Home Assistant.

Features in Home Assistant:

  • Automatic device discovery
  • Cover entities for shutters, awnings, and blinds
  • Position control with slider
  • Sensor entities for environmental data
  • Group control support
  • Event-driven updates

To use in Home Assistant, install the custom integration:

  1. Install via HACS (recommended) or manually copy the integration
  2. Add to configuration.yaml:
    selve:
      port: /dev/ttyUSB0  # or auto-detect
    
  3. Restart Home Assistant
  4. Devices appear as cover entities

See homeassistant-selve for full documentation.

Development

Running Tests

# Install development dependencies
pip install -e ".[dev]"

# Run all tests
pytest

# Run unit tests only
pytest tests/unit/

# Run integration tests (requires hardware or mocks)
pytest tests/integration/ -m "not hardware"

# Run with coverage
pytest --cov=selve --cov-report=html

Project Structure

selve/
├── __init__.py          # Main Selve class
├── device.py            # Device control
├── group.py             # Group control
├── sensor.py            # Sensor handling
├── gateway.py           # Gateway communication
├── commands/            # Protocol command implementations
└── util/                # Utilities and protocol handling

tests/
├── unit/                # Unit tests (337 tests)
└── integration/         # Integration tests (24 tests)

Requirements

  • Python 3.9 or higher
  • pyserial >= 3.4
  • untangle >= 1.1.1

License

This project is licensed under the GNU General Public License v2.0 or later (GPLv2+).

Credits

  • Author: Stefan Altheimer (me@stefan-altheimer.de)
  • Original Library: Based on concepts from the original python-selve
  • Protocol: Implements the Selve USB-RF Gateway protocol

Support

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_selve_new-2.5.15.tar.gz (122.1 kB view details)

Uploaded Source

Built Distribution

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

python_selve_new-2.5.15-py3-none-any.whl (127.4 kB view details)

Uploaded Python 3

File details

Details for the file python_selve_new-2.5.15.tar.gz.

File metadata

  • Download URL: python_selve_new-2.5.15.tar.gz
  • Upload date:
  • Size: 122.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for python_selve_new-2.5.15.tar.gz
Algorithm Hash digest
SHA256 924bc70cf7737b4017709b5a001101b334fa9d7a76f3c006c81c8c8c90c78c7c
MD5 416963a1022fdd421093ac1fcd742777
BLAKE2b-256 c36c0ee18e8bf69c935bbf5d89c37abc3673394baa83c1016f3332cc4caefbdf

See more details on using hashes here.

File details

Details for the file python_selve_new-2.5.15-py3-none-any.whl.

File metadata

File hashes

Hashes for python_selve_new-2.5.15-py3-none-any.whl
Algorithm Hash digest
SHA256 6cd91f7433289cf70f941e54850f98019d54538879850622f956422fbf6d884b
MD5 9a7e15cd5efb12d2ff261adb932d15c0
BLAKE2b-256 478cf10d473439bf81a17af0b30a3f1f4ee1f89cebe6a7162f241de8d6e6d538

See more details on using hashes here.

Release history Release notifications | RSS feed

2.5.17

2 files

2.5.16

2 files

This release

2.5.15 This release

2 files

2.5.14

2 files

2.5.13

2 files

2.5.12

2 files

2.5.11

2 files

2.5.10

2 files

2.5.9

2 files

2.5.8

2 files

2.5.7

2 files

2.5.6

2 files

2.5.5

2 files

2.5.4

2 files

2.5.3

2 files

2.5.2

2 files

2.5.1

2 files

2.4.0

2 files

2.3.6

2 files

2.3.4

2 files

2.3.3

2 files

2.3.2

2 files

2.3.1

2 files

2.3.0

2 files

2.2.22

2 files

2.2.21

2 files

2.2.20

2 files

2.2.19

2 files

2.2.18

2 files

2.2.17

2 files

2.2.16

2 files

2.2.15

2 files

2.2.14

2 files

2.2.13

1 file

2.2.12

1 file

2.2.11

1 file

2.2.10

1 file

2.2.9

1 file

2.2.8

1 file

2.2.7

1 file

2.2.6

1 file

2.2.5

1 file

2.2.4

1 file

2.2.3

1 file

2.2.2

1 file

2.2.1

1 file

2.2.0

1 file

2.1.13

1 file

2.1.12

1 file

2.1.11

1 file

2.1.10

1 file

2.1.9

1 file

2.1.8

1 file

2.1.7

1 file

2.1.6

1 file

2.1.5

1 file

2.1.4

1 file

2.1.3

1 file

2.1.2

1 file

2.1.1

1 file

2.1.0

1 file

2.0.57

1 file

2.0.56

1 file

2.0.55

1 file

2.0.54

1 file

2.0.53

1 file

2.0.52

1 file

2.0.51

1 file

2.0.50

1 file

2.0.49

1 file

2.0.48

1 file

2.0.47

1 file

2.0.46

1 file

2.0.45

1 file

2.0.44

1 file

2.0.43

1 file

2.0.42

1 file

2.0.41

1 file

2.0.40

1 file

2.0.39

1 file

2.0.38

1 file

2.0.37

1 file

2.0.36

1 file

2.0.35

1 file

2.0.34

1 file

2.0.33

1 file

2.0.32

1 file

2.0.31

1 file

2.0.30

1 file

2.0.29

1 file

2.0.28

1 file

2.0.27

1 file

2.0.26

1 file

2.0.25

1 file

2.0.24

1 file

2.0.23

1 file

2.0.22

1 file

2.0.21

1 file

2.0.20

1 file

2.0.19

1 file

2.0.18

1 file

2.0.17

1 file

2.0.16

1 file

2.0.15

1 file

2.0.14

1 file

2.0.13

1 file

2.0.12

1 file

2.0.11

1 file

2.0.10

1 file

2.0.9

1 file

2.0.8

1 file

2.0.7

1 file

2.0.6

1 file

2.0.5

1 file

2.0.4

1 file

2.0.3

1 file

2.0.2

1 file

2.0.1

1 file

1.1.6

2 files

1.1.5

1 file

1.1.4

1 file

1.1.3

1 file

1.1.2

1 file

1.1.1

1 file

1.1.0

1 file

1.0.29

1 file

1.0.28

1 file

1.0.27

1 file

1.0.25

2 files

1.0.24

2 files

1.0.23

2 files

1.0.22

2 files

1.0.21

2 files

1.0.20

2 files

1.0.19

2 files

1.0.18

2 files

1.0.17

2 files

1.0.16

2 files

1.0.15

2 files

1.0.14

2 files

1.0.13

2 files

1.0.12

2 files

1.0.11

2 files

1.0.10

2 files

1.0.9

2 files

1.0.8

2 files

1.0.7

2 files

1.0.6

2 files

1.0.5

2 files

1.0.4

2 files

1.0.3

2 files

1.0.2

1 file

1.0.1.10

1 file

1.0.1.9

1 file

1.0.1.8

1 file

1.0.1.7

1 file

1.0.1.6

1 file

1.0.1.5

1 file

1.0.1.4

1 file

1.0.1.3

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page