How to use the xknx.devices.device.Device function in xknx

To help you get started, we’ve selected a few xknx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github XKNX / xknx / xknx / devices / binary_sensor.py View on Github external
from xknx.exceptions import CouldNotParseTelegram
from xknx.telegram import GroupAddress

from .action import Action
from .device import Device


# pylint: disable=invalid-name
class BinarySensorState(Enum):
    """Enum class for the state of a binary sensor."""

    ON = 1
    OFF = 2


class BinarySensor(Device):
    """Class for binary sensor."""

    # pylint: disable=too-many-instance-attributes

    CONTEXT_TIMEOUT = 1

    def __init__(self,
                 xknx,
                 name,
                 group_address_state=None,
                 sync_state=True,
                 ignore_internal_state=False,
                 device_class=None,
                 significant_bit=1,
                 reset_after=None,
                 actions=None,
github XKNX / xknx / xknx / devices / climate.py View on Github external
async def set(self, value):
        """Set new value from Kelvin."""
        if value > self.max_temp_delta:
            self.xknx.logger.warning("setpoint_shift_max exceeded at %s: %s",
                                     self.device_name, value)
            value = self.max_temp_delta
        if value < self.min_temp_delta:
            self.xknx.logger.warning("setpoint_shift_min exceeded at %s: %s",
                                     self.device_name, value)
            value = self.min_temp_delta
        steps = int(value / self.setpoint_shift_step)
        await super().set(steps)


class Climate(Device):
    """Class for managing the climate."""

    # pylint: disable=too-many-instance-attributes,invalid-name
    def __init__(self,
                 xknx,
                 name,
                 group_address_temperature=None,
                 group_address_target_temperature=None,
                 group_address_target_temperature_state=None,
                 group_address_setpoint_shift=None,
                 group_address_setpoint_shift_state=None,
                 setpoint_shift_step=DEFAULT_SETPOINT_SHIFT_STEP,
                 setpoint_shift_max=DEFAULT_SETPOINT_SHIFT_MAX,
                 setpoint_shift_min=DEFAULT_SETPOINT_SHIFT_MIN,
                 group_address_on_off=None,
                 group_address_on_off_state=None,
github XKNX / xknx / xknx / devices / notification.py View on Github external
"""Module for managing a notification via KNX."""
from xknx.remote_value import RemoteValueString

from .device import Device


class Notification(Device):
    """Class for managing a notification."""

    def __init__(self,
                 xknx,
                 name,
                 group_address=None,
                 group_address_state=None,
                 device_updated_cb=None):
        """Initialize notification class."""
        # pylint: disable=too-many-arguments
        super().__init__(xknx, name, device_updated_cb)

        self._message = RemoteValueString(xknx,
                                          group_address=group_address,
                                          group_address_state=group_address_state,
                                          device_name=name,
github XKNX / xknx / xknx / devices / cover.py View on Github external
Module for managing a cover via KNX.

It provides functionality for

* moving cover up/down or to a specific position
* reading the current state from KNX bus.
* Cover will also predict the current position.
"""
from xknx.remote_value import (
    RemoteValueScaling, RemoteValueStep, RemoteValueUpDown)

from .device import Device
from .travelcalculator import TravelCalculator


class Cover(Device):
    """Class for managing a cover."""

    # pylint: disable=too-many-instance-attributes
    # pylint: disable=too-many-public-methods
    # pylint: disable=too-many-locals

    # Average typical travel time of a cover
    DEFAULT_TRAVEL_TIME_DOWN = 22
    DEFAULT_TRAVEL_TIME_UP = 22

    def __init__(self,
                 xknx,
                 name,
                 group_address_long=None,
                 group_address_short=None,
                 group_address_position=None,
github XKNX / xknx / xknx / devices / devices.py View on Github external
def add(self, device):
        """Add device to devices vector."""
        if not isinstance(device, Device):
            raise TypeError()
        device.register_device_updated_cb(self.device_updated)
        self.__devices.append(device)
github XKNX / xknx / xknx / devices / scene.py View on Github external
"""Module for managing a KNX scene."""
from xknx.remote_value import RemoteValueSceneNumber

from .device import Device


class Scene(Device):
    """Class for managing a scene."""

    def __init__(self,
                 xknx,
                 name,
                 group_address=None,
                 scene_number=1,
                 device_updated_cb=None):
        """Initialize Sceneclass."""
        # pylint: disable=too-many-arguments
        super().__init__(xknx, name, device_updated_cb)

        self.scene_value = RemoteValueSceneNumber(
            xknx,
            group_address,
            device_name=self.name,
github XKNX / xknx / xknx / devices / fan.py View on Github external
"""
Module for managing a fan via KNX.

It provides functionality for

* setting fan to specific speed
* reading the current speed from KNX bus.
"""
from xknx.remote_value import RemoteValueScaling

from .device import Device


class Fan(Device):
    """Class for managing a fan."""

    # pylint: disable=too-many-instance-attributes
    # pylint: disable=too-many-public-methods

    def __init__(self,
                 xknx,
                 name,
                 group_address_speed=None,
                 group_address_speed_state=None,
                 device_updated_cb=None):
        """Initialize fan class."""
        # pylint: disable=too-many-arguments
        Device.__init__(self, xknx, name, device_updated_cb)

        self.speed = RemoteValueScaling(
github XKNX / xknx / xknx / devices / switch.py View on Github external
"""
Module for managing a switch via KNX.

It provides functionality for

* switching 'on' and 'off'.
* reading the current state from KNX bus.
"""
from xknx.remote_value import RemoteValueSwitch

from .device import Device


class Switch(Device):
    """Class for managing a switch."""

    def __init__(self,
                 xknx,
                 name,
                 group_address=None,
                 group_address_state=None,
                 device_updated_cb=None):
        """Initialize Switch class."""
        # pylint: disable=too-many-arguments
        super().__init__(xknx, name, device_updated_cb)

        self.switch = RemoteValueSwitch(
            xknx,
            group_address,
            group_address_state,
github XKNX / xknx / xknx / devices / light.py View on Github external
* switching light 'on' and 'off'.
* setting the brightness.
* setting the color.
* setting the relative color temperature (tunable white).
* setting the absolute color temperature.
* reading the current state from KNX bus.
"""
from .device import Device
from .remote_value_color_rgb import RemoteValueColorRGB
from .remote_value_dpt_2_byte_unsigned import RemoteValueDpt2ByteUnsigned
from .remote_value_scaling import RemoteValueScaling
from .remote_value_switch import RemoteValueSwitch
from .remote_value_dpt_2_byte_unsigned import RemoteValueDpt2ByteUnsigned


class Light(Device):
    """Class for managing a light."""

    # pylint: disable=too-many-locals

    def __init__(self,
                 xknx,
                 name,
                 group_address_switch=None,
                 group_address_switch_state=None,
                 group_address_brightness=None,
                 group_address_brightness_state=None,
                 group_address_color=None,
                 group_address_color_state=None,
                 group_address_tunable_white=None,
                 group_address_tunable_white_state=None,
                 group_address_color_temperature=None,
github XKNX / xknx / xknx / devices / fan.py View on Github external
def __init__(self,
                 xknx,
                 name,
                 group_address_speed=None,
                 group_address_speed_state=None,
                 device_updated_cb=None):
        """Initialize fan class."""
        # pylint: disable=too-many-arguments
        Device.__init__(self, xknx, name, device_updated_cb)

        self.speed = RemoteValueScaling(
            xknx,
            group_address_speed,
            group_address_speed_state,
            device_name=self.name,
            after_update_cb=self.after_update,
            range_from=0,
            range_to=100)