How to use the pysmartthings.device.Command 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 andrewsayre / pysmartthings / pysmartthings / device.py View on Github external
async def execute(
        self, command: str, args: Dict = None, *, component_id: str = "main"
    ):
        """Call the execute command."""
        command_args = [command]
        if args:
            command_args.append(args)
        return await self.command(
            component_id, Capability.execute, Command.execute, command_args
        )
github andrewsayre / pysmartthings / pysmartthings / device.py View on Github external
async def set_thermostat_mode(
        self, mode: str, set_status: bool = False, *, component_id: str = "main"
    ) -> bool:
        """Call the setThermostatMode deivce command."""
        capability = self.get_capability(
            Capability.thermostat_mode, Capability.thermostat
        )
        result = await self.command(
            component_id, capability, Command.set_thermostat_mode, [mode]
        )
        if result and set_status:
            self.status.thermostat_mode = mode
        return result
github andrewsayre / pysmartthings / pysmartthings / device.py View on Github external
async def lock(
        self, set_status: bool = False, *, component_id: str = "main"
    ) -> bool:
        """Call the lock device command."""
        result = await self.command(component_id, Capability.lock, Command.lock)
        if result and set_status:
            self.status.update_attribute_value(Attribute.lock, "locked")
        return result
github andrewsayre / pysmartthings / pysmartthings / device.py View on Github external
async def open(
        self, set_status: bool = False, *, component_id: str = "main"
    ) -> bool:
        """Call the open device command."""
        capability = self.get_capability(
            Capability.door_control,
            Capability.window_shade,
            Capability.garage_door_control,
        )
        result = await self.command(component_id, capability, Command.open)
        if result and set_status:
            attribute = (
                Attribute.window_shade
                if capability == Capability.window_shade
                else Attribute.door
            )
            self.status.update_attribute_value(attribute, "opening")
        return result
github andrewsayre / pysmartthings / pysmartthings / device.py View on Github external
async def set_fan_mode(
        self, mode: str, *, set_status: bool = False, component_id: str = "main"
    ):
        """Call the setFanMode command."""
        result = await self.command(
            component_id,
            Capability.air_conditioner_fan_mode,
            Command.set_fan_mode,
            [mode],
        )
        if result and set_status:
            self.status.update_attribute_value(Attribute.fan_mode, mode)
        return result
github andrewsayre / pysmartthings / pysmartthings / device.py View on Github external
async def unlock(
        self, set_status: bool = False, *, component_id: str = "main"
    ) -> bool:
        """Call the unlock device command."""
        result = await self.command(component_id, Capability.lock, Command.unlock)
        if result and set_status:
            self.status.update_attribute_value(Attribute.lock, "unlocked")
        return result
github andrewsayre / pysmartthings / pysmartthings / device.py View on Github external
async def set_air_flow_direction(
        self, direction: str, *, set_status: bool = False, component_id: str = "main"
    ):
        """Call the setAirFlowDirection command."""
        result = await self.command(
            component_id,
            Capability.air_flow_direction,
            Command.set_air_flow_direction,
            [direction],
        )
        if result and set_status:
            self.status.update_attribute_value(Attribute.air_flow_direction, direction)
        return result
github andrewsayre / pysmartthings / pysmartthings / device.py View on Github external
async def set_thermostat_fan_mode(
        self, mode: str, set_status: bool = False, *, component_id: str = "main"
    ) -> bool:
        """Call the setThermostatFanMode device command."""
        capability = self.get_capability(
            Capability.thermostat_fan_mode, Capability.thermostat
        )
        result = await self.command(
            component_id, capability, Command.set_thermostat_fan_mode, [mode]
        )
        if result and set_status:
            self.status.thermostat_fan_mode = mode
        return result
github andrewsayre / pysmartthings / pysmartthings / device.py View on Github external
drlc_level: int,
        start: str,
        duration: int,
        reporting_period: int = None,
        *,
        set_status: bool = False,
        component_id: str = "main"
    ):
        """Call the drlc action command."""
        args = [drlc_type, drlc_level, start, duration]
        if reporting_period is not None:
            args.append(reporting_period)
        result = await self.command(
            component_id,
            Capability.demand_response_load_control,
            Command.request_drlc_action,
            args,
        )
        if result and set_status:
            data = {
                "duration": duration,
                "drlcLevel": drlc_level,
                "start": start,
                "override": False,
            }
            self.status.apply_attribute_update(
                component_id,
                Capability.demand_response_load_control,
                Attribute.drlc_status,
                data,
            )
        return result
github andrewsayre / pysmartthings / pysmartthings / device.py View on Github external
async def set_color_temperature(
        self, temperature: int, set_status: bool = False, *, component_id: str = "main"
    ) -> bool:
        """Call the color temperature device command."""
        if not 1 <= temperature <= 30000:
            raise ValueError("temperature must be scaled between 1-30000.")

        result = await self.command(
            component_id,
            Capability.color_temperature,
            Command.set_color_temperature,
            [temperature],
        )
        if result and set_status:
            self.status.color_temperature = temperature
        return result