How to use the pysmartthings.Capability function in pysmartthings

To help you get started, we’ve selected a few pysmartthings 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 home-assistant / home-assistant / tests / components / smartthings / test_switch.py View on Github external
async def test_unload_config_entry(hass, device_factory):
    """Test the switch is removed when the config entry is unloaded."""
    # Arrange
    device = device_factory("Switch 1", [Capability.switch], {Attribute.switch: "on"})
    config_entry = await setup_platform(hass, SWITCH_DOMAIN, devices=[device])
    # Act
    await hass.config_entries.async_forward_entry_unload(config_entry, "switch")
    # Assert
    assert not hass.states.get("switch.switch_1")
github home-assistant / home-assistant / tests / components / smartthings / test_climate.py View on Github external
def legacy_thermostat_fixture(device_factory):
    """Fixture returns a legacy thermostat."""
    device = device_factory(
        "Legacy Thermostat",
        capabilities=[Capability.thermostat],
        status={
            Attribute.cooling_setpoint: 74,
            Attribute.heating_setpoint: 68,
            Attribute.thermostat_fan_mode: "auto",
            Attribute.supported_thermostat_fan_modes: ["auto", "on"],
            Attribute.thermostat_mode: "auto",
            Attribute.supported_thermostat_modes: climate.MODE_TO_STATE.keys(),
            Attribute.thermostat_operating_state: "idle",
        },
    )
    device.status.attributes[Attribute.temperature] = Status(70, "F", None)
    return device
github home-assistant / home-assistant / homeassistant / components / smartthings / climate.py View on Github external
def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]:
    """Return all capabilities supported if minimum required are present."""
    supported = [
        Capability.air_conditioner_mode,
        Capability.demand_response_load_control,
        Capability.air_conditioner_fan_mode,
        Capability.power_consumption_report,
        Capability.relative_humidity_measurement,
        Capability.switch,
        Capability.temperature_measurement,
        Capability.thermostat,
        Capability.thermostat_cooling_setpoint,
        Capability.thermostat_fan_mode,
        Capability.thermostat_heating_setpoint,
        Capability.thermostat_mode,
        Capability.thermostat_operating_state,
    ]
    # Can have this legacy/deprecated capability
    if Capability.thermostat in capabilities:
        return supported
    # Or must have all of these thermostat capabilities
    thermostat_capabilities = [
        Capability.temperature_measurement,
        Capability.thermostat_cooling_setpoint,
        Capability.thermostat_heating_setpoint,
        Capability.thermostat_mode,
    ]
    if all(capability in capabilities for capability in thermostat_capabilities):
        return supported
    # Or must have all of these A/C capabilities
    ac_capabilities = [
github home-assistant / home-assistant / homeassistant / components / smartthings / light.py View on Github external
def _determine_features(self):
        """Get features supported by the device."""
        features = 0
        # Brightness and transition
        if Capability.switch_level in self._device.capabilities:
            features |= SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
        # Color Temperature
        if Capability.color_temperature in self._device.capabilities:
            features |= SUPPORT_COLOR_TEMP
        # Color
        if Capability.color_control in self._device.capabilities:
            features |= SUPPORT_COLOR

        return features
github home-assistant / home-assistant / homeassistant / components / smartthings / lock.py View on Github external
def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]:
    """Return all capabilities supported if minimum required are present."""
    if Capability.lock in capabilities:
        return [Capability.lock]
    return None
github home-assistant / home-assistant / homeassistant / components / smartthings / cover.py View on Github external
def __init__(self, device):
        """Initialize the cover class."""
        super().__init__(device)
        self._device_class = None
        self._state = None
        self._state_attrs = None
        self._supported_features = SUPPORT_OPEN | SUPPORT_CLOSE
        if Capability.switch_level in device.capabilities:
            self._supported_features |= SUPPORT_SET_POSITION