How to use the pysmartthings.Capability.switch 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_fan.py View on Github external
async def test_unload_config_entry(hass, device_factory):
    """Test the fan is removed when the config entry is unloaded."""
    # Arrange
    device = device_factory(
        "Fan 1",
        capabilities=[Capability.switch, Capability.fan_speed],
        status={Attribute.switch: "off", Attribute.fan_speed: 0},
    )
    config_entry = await setup_platform(hass, FAN_DOMAIN, devices=[device])
    # Act
    await hass.config_entries.async_forward_entry_unload(config_entry, "fan")
    # Assert
    assert not hass.states.get("fan.fan_1")
github home-assistant / home-assistant / tests / components / smartthings / test_switch.py View on Github external
async def test_turn_on(hass, device_factory):
    """Test the switch turns of successfully."""
    # Arrange
    device = device_factory(
        "Switch_1",
        [Capability.switch, Capability.power_meter, Capability.energy_meter],
        {Attribute.switch: "off", Attribute.power: 355, Attribute.energy: 11.422},
    )
    await setup_platform(hass, SWITCH_DOMAIN, devices=[device])
    # Act
    await hass.services.async_call(
        "switch", "turn_on", {"entity_id": "switch.switch_1"}, blocking=True
    )
    # Assert
    state = hass.states.get("switch.switch_1")
    assert state is not None
    assert state.state == "on"
    assert state.attributes[ATTR_CURRENT_POWER_W] == 355
    assert state.attributes[ATTR_TODAY_ENERGY_KWH] == 11.422
github home-assistant / home-assistant / tests / components / smartthings / test_climate.py View on Github external
def air_conditioner_fixture(device_factory):
    """Fixture returns a air conditioner."""
    device = device_factory(
        "Air Conditioner",
        capabilities=[
            Capability.air_conditioner_mode,
            Capability.demand_response_load_control,
            Capability.air_conditioner_fan_mode,
            Capability.power_consumption_report,
            Capability.switch,
            Capability.temperature_measurement,
            Capability.thermostat_cooling_setpoint,
        ],
        status={
            Attribute.air_conditioner_mode: "auto",
            Attribute.supported_ac_modes: [
                "cool",
                "dry",
                "wind",
                "auto",
                "heat",
                "fanOnly",
            ],
            Attribute.drlc_status: {
                "duration": 0,
                "drlcLevel": -1,
github home-assistant / home-assistant / tests / components / smartthings / test_smartapp.py View on Github external
async def test_smartapp_sync_subscriptions_up_to_date(
        hass, smartthings_mock, device_factory, subscription_factory):
    """Test synchronization does nothing when current."""
    smartthings_mock.subscriptions.return_value = [
        subscription_factory(Capability.battery),
        subscription_factory(Capability.switch),
        subscription_factory(Capability.switch_level)
    ]
    devices = [
        device_factory('', [Capability.battery, 'ping']),
        device_factory('', [Capability.switch, Capability.switch_level]),
        device_factory('', [Capability.switch])
    ]

    await smartapp.smartapp_sync_subscriptions(
        hass, str(uuid4()), str(uuid4()), str(uuid4()), devices)

    assert smartthings_mock.subscriptions.call_count == 1
    assert smartthings_mock.delete_subscription.call_count == 0
    assert smartthings_mock.create_subscription.call_count == 0
github home-assistant / home-assistant / tests / components / smartthings / test_light.py View on Github external
async def test_update_from_signal(hass, device_factory):
    """Test the light updates when receiving a signal."""
    # Arrange
    device = device_factory(
        "Color Dimmer 2",
        capabilities=[
            Capability.switch,
            Capability.switch_level,
            Capability.color_control,
            Capability.color_temperature,
        ],
        status={
            Attribute.switch: "off",
            Attribute.level: 100,
            Attribute.hue: 76.0,
            Attribute.saturation: 55.0,
            Attribute.color_temperature: 4500,
        },
    )
    await setup_platform(hass, LIGHT_DOMAIN, devices=[device])
    await device.switch_on(True)
    # Act
    async_dispatcher_send(hass, SIGNAL_SMARTTHINGS_UPDATE, [device.device_id])
github home-assistant / home-assistant / homeassistant / components / smartthings / switch.py View on Github external
def get_capabilities(capabilities: Sequence[str]) -> Optional[Sequence[str]]:
    """Return all capabilities supported if minimum required are present."""
    # Must be able to be turned on/off.
    if Capability.switch in capabilities:
        return [Capability.switch, Capability.energy_meter, Capability.power_meter]
    return None
github home-assistant / home-assistant / homeassistant / components / smartthings / light.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.switch,
        Capability.switch_level,
        Capability.color_control,
        Capability.color_temperature,
    ]
    # Must be able to be turned on/off.
    if Capability.switch not in capabilities:
        return None
    # Must have one of these
    light_capabilities = [
        Capability.color_control,
        Capability.color_temperature,
        Capability.switch_level,
    ]
    if any(capability in capabilities for capability in light_capabilities):
        return supported
    return None
github home-assistant / home-assistant / homeassistant / components / smartthings / fan.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.switch, Capability.fan_speed]
    # Must have switch and fan_speed
    if all(capability in capabilities for capability in supported):
        return supported
github home-assistant / home-assistant / homeassistant / components / smartthings / climate.py View on Github external
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 = [
        Capability.air_conditioner_mode,
        Capability.air_conditioner_fan_mode,
        Capability.switch,
        Capability.temperature_measurement,
        Capability.thermostat_cooling_setpoint,
    ]
    if all(capability in capabilities for capability in ac_capabilities):
        return supported
    return None