How to use the pyvera.__init__.VeraDevice function in pyvera

To help you get started, we’ve selected a few pyvera 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 pavoni / pyvera / pyvera / __init__.py View on Github external
_, _, pin, name = code_addrs[2:]
                    # And add them as a tuple to the list
                    codes.append((slot, name, pin))
            # pylint: disable=broad-except
            except Exception as ex:
                LOG.error("Problem parsing pin code string %s: %s", code, ex)

        return codes

    @property
    def should_poll(self) -> bool:
        """Determine if we should poll for data."""
        return True


class VeraThermostat(VeraDevice):
    """Class to represent a thermostat."""

    def set_temperature(self, temp: float) -> None:
        """Set current goal temperature / setpoint."""

        self.set_service_value(
            self.thermostat_setpoint, "CurrentSetpoint", "NewCurrentSetpoint", temp
        )

        self.set_cache_value("setpoint", temp)

    def get_current_goal_temperature(self, refresh: bool = False) -> Optional[float]:
        """Get current goal temperature / setpoint."""
        if refresh:
            self.refresh()
        try:
github pavoni / pyvera / pyvera / __init__.py View on Github external
def __init__(self) -> None:
        """Init subscription."""
        self._devices: DefaultDict[int, List[VeraDevice]] = collections.defaultdict(
            list
        )
        self._callbacks: DefaultDict[
            VeraDevice, List[SubscriptionCallback]
        ] = collections.defaultdict(list)
        self._last_updated = TIMESTAMP_NONE
        self._controller: Optional[VeraController] = None
github pavoni / pyvera / pyvera / __init__.py View on Github external
device = VeraBinarySensor(item, item_alerts, self)
            elif device_category in (
                CATEGORY_SENSOR,
                CATEGORY_HUMIDITY_SENSOR,
                CATEGORY_TEMPERATURE_SENSOR,
                CATEGORY_LIGHT_SENSOR,
                CATEGORY_POWER_METER,
                CATEGORY_UV_SENSOR,
            ):
                device = VeraSensor(item, item_alerts, self)
            elif device_category in (CATEGORY_SCENE_CONTROLLER, CATEGORY_REMOTE):
                device = VeraSceneController(item, item_alerts, self)
            elif device_category == CATEGORY_GARAGE_DOOR:
                device = VeraGarageDoor(item, item_alerts, self)
            else:
                device = VeraDevice(item, item_alerts, self)

            self.devices.append(device)

            if device.is_armable and device_category not in (
                CATEGORY_SWITCH,
                CATEGORY_VERA_SIREN,
                CATEGORY_CURTAIN,
                CATEGORY_GARAGE_DOOR,
            ):
                self.devices.append(VeraArmableDevice(item, item_alerts, self))

        return [
            device
            for device in self.devices
            if not category_filter
            or (
github pavoni / pyvera / pyvera / __init__.py View on Github external
self.refresh()
        return self.level

    def set_level(self, level: int) -> None:
        """Set open level of the curtains.

        Scale is 0-100
        """
        self.set_service_value(
            self.dimmer_service, "LoadLevelTarget", "newLoadlevelTarget", level
        )

        self.set_cache_value("level", level)


class VeraLock(VeraDevice):
    """Class to represent a door lock."""

    # target locked (state, time)
    # this is used since sdata does not return proper job status for locks
    lock_target = None

    def set_lock_state(self, state: int) -> None:
        """Set the lock state, also update local state."""
        self.set_service_value(self.lock_service, "Target", "newTargetValue", state)
        self.set_cache_value("locked", state)
        self.lock_target = (str(state), time.time())

    def lock(self) -> None:
        """Lock the door."""
        self.set_lock_state(1)
github pavoni / pyvera / pyvera / __init__.py View on Github external
"""Disarm the device."""
        self.set_armed_state(0)

    def is_switched_on(self, refresh: bool = False) -> bool:
        """Get armed state.

        Refresh data from Vera if refresh is True, otherwise use local cache.
        Refresh is only needed if you're not using subscriptions.
        """
        if refresh:
            self.refresh()
        val = self.get_value("Armed")
        return cast(str, val) == "1"


class VeraSensor(VeraDevice):
    """Class to represent a supported sensor."""


class VeraBinarySensor(VeraDevice):
    """Class to represent an on / off sensor."""

    def is_switched_on(self, refresh: bool = False) -> bool:
        """Get sensor on off state.

        Refresh data from Vera if refresh is True, otherwise use local cache.
        Refresh is only needed if you're not using subscriptions.
        """
        if refresh:
            self.refresh()
        val = self.get_value("Status")
        return cast(str, val) == "1"
github pavoni / pyvera / pyvera / __init__.py View on Github external
def comm_failure(self) -> bool:
        """Return the Communication Failure Flag."""
        return cast(str, self.get_strict_value("commFailure")) != "0"

    @property
    def vera_device_id(self) -> int:
        """Get the ID Vera uses to refer to the device."""
        return cast(int, self.device_id)

    @property
    def should_poll(self) -> bool:
        """Whether polling is needed if using subscriptions for this device."""
        return False


class VeraSwitch(VeraDevice):
    """Class to add switch functionality."""

    def set_switch_state(self, state: int) -> None:
        """Set the switch state, also update local state."""
        self.set_service_value(self.switch_service, "Target", "newTargetValue", state)
        self.set_cache_value("Status", state)

    def switch_on(self) -> None:
        """Turn the switch on, also update local state."""
        self.set_switch_state(1)

    def switch_off(self) -> None:
        """Turn the switch off, also update local state."""
        self.set_switch_state(0)

    def is_switched_on(self, refresh: bool = False) -> bool:
github pavoni / pyvera / pyvera / __init__.py View on Github external
def get_hvac_state(self, refresh: bool = False) -> Optional[str]:
        """Get current hvac state."""
        if refresh:
            self.refresh()
        return cast(str, self.get_value("hvacstate"))

    def fan_auto(self) -> None:
        """Set fan to automatic."""
        self.set_fan_mode("Auto")

    def fan_cycle(self) -> None:
        """Set fan to cycle."""
        self.set_fan_mode("PeriodicOn")


class VeraSceneController(VeraDevice):
    """Class to represent a scene controller."""

    def get_last_scene_id(self, refresh: bool = False) -> str:
        """Get last scene id.

        Refresh data from Vera if refresh is True, otherwise use local cache.
        Refresh is only needed if you're not using subscriptions.
        """
        if refresh:
            self.refresh_complex_value("LastSceneID")
            self.refresh_complex_value("sl_CentralScene")
        val = self.get_complex_value("LastSceneID") or self.get_complex_value(
            "sl_CentralScene"
        )
        return cast(str, val)
github pavoni / pyvera / pyvera / __init__.py View on Github external
"""Get armed state.

        Refresh data from Vera if refresh is True, otherwise use local cache.
        Refresh is only needed if you're not using subscriptions.
        """
        if refresh:
            self.refresh()
        val = self.get_value("Armed")
        return cast(str, val) == "1"


class VeraSensor(VeraDevice):
    """Class to represent a supported sensor."""


class VeraBinarySensor(VeraDevice):
    """Class to represent an on / off sensor."""

    def is_switched_on(self, refresh: bool = False) -> bool:
        """Get sensor on off state.

        Refresh data from Vera if refresh is True, otherwise use local cache.
        Refresh is only needed if you're not using subscriptions.
        """
        if refresh:
            self.refresh()
        val = self.get_value("Status")
        return cast(str, val) == "1"


class VeraCurtain(VeraSwitch):
    """Class to add curtains functionality."""