How to use the pysmartthings.device.DeviceStatus 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 / tests / test_device.py View on Github external
def test_init():
        """Tests the init method."""
        # Arrange/Act
        status = DeviceStatus(None, device_id=DEVICE_ID)
        # Assert
        assert status.device_id == DEVICE_ID
        assert status.attributes == {}
        assert not status.switch
        assert not status.motion
        assert status.level == 0
        assert status.component_id == 'main'
github andrewsayre / pysmartthings / tests / test_device.py View on Github external
def test_attributes_default():
        """Test the attributes property."""
        # Arrange
        data = get_json('device_status.json')
        status = DeviceStatus(None, DEVICE_ID, data)
        # Act/Assert
        assert status.attributes['thermostatSetpoint'] == (None, None, None)
github andrewsayre / pysmartthings / tests / test_device.py View on Github external
def test_attributes():
        """Test the attributes property."""
        # Arrange
        data = get_json('device_status.json')
        status = DeviceStatus(None, DEVICE_ID, data)
        # Act/Assert
        assert status.attributes == {
            'button': (None, None, None),
            'numberOfButtons': (None, None, None),
            'supportedButtonValues': (None, None, None),
            'indicatorStatus': ('when off', None, None),
            'switch': ('on', None, None),
            'checkInterval': (1920, 's', {"protocol": "zwave",
                                          "hubHardwareId": "000F"}),
            'healthStatus': (None, None, {}),
            'DeviceWatch-DeviceStatus': (None, None, {}),
            'level': (100, '%', None)
        }
github andrewsayre / pysmartthings / tests / test_device.py View on Github external
def test_values():
        """Test the values property."""
        # Arrange
        data = get_json('device_status.json')
        status = DeviceStatus(None, DEVICE_ID, data)
        # Act/Assert
        assert status.values == {
            'button': None,
            'numberOfButtons': None,
            'supportedButtonValues': None,
            'indicatorStatus': 'when off',
            'switch': 'on',
            'checkInterval': 1920,
            'healthStatus': None,
            'DeviceWatch-DeviceStatus': None,
            'level': 100
        }
github andrewsayre / pysmartthings / tests / test_device.py View on Github external
def test_apply_attribute_update():
        """Tests the apply_attribute_update method."""
        # Arrange
        data = get_json('device_status.json')
        device = DeviceStatus(None, DEVICE_ID, data)
        # Act
        device.apply_attribute_update(
            'main', Capability.switch_level, Attribute.level, 50, '%',
            {'test': 'test'})
        # Assert
        status = device.attributes[Attribute.level]
        assert status.value == 50
        assert status.unit == '%'
        assert status.data == {'test': 'test'}
github andrewsayre / pysmartthings / tests / test_device.py View on Github external
def test_level():
        """Tests the level property."""
        # Arrange
        status = DeviceStatus(None, device_id=DEVICE_ID)
        # Act
        status.level = 50
        # Assert
        assert status.level == 50
github andrewsayre / pysmartthings / tests / test_device.py View on Github external
def test_color_temperature_range():
        """Tests the hue property's range."""
        # Arrange
        status = DeviceStatus(None, device_id=DEVICE_ID)
        # Act/Assert
        values = [0, 30001]
        for value in values:
            with pytest.raises(ValueError):
                status.color_temperature = value
github andrewsayre / pysmartthings / tests / test_device.py View on Github external
def test_hue_range():
        """Tests the hue property's range."""
        # Arrange
        status = DeviceStatus(None, device_id=DEVICE_ID)
        # Act/Assert
        values = [-1, 101]
        for value in values:
            with pytest.raises(ValueError):
                status.hue = value
github andrewsayre / pysmartthings / tests / test_device.py View on Github external
def test_saturation_range():
        """Tests the hue property's range."""
        # Arrange
        status = DeviceStatus(None, device_id=DEVICE_ID)
        # Act/Assert
        values = [-1, 101]
        for value in values:
            with pytest.raises(ValueError):
                status.saturation = value
github andrewsayre / pysmartthings / pysmartthings / device.py View on Github external
def __init__(
        self, api: Api, data: Optional[dict] = None, device_id: Optional[str] = None
    ):
        """Create a new instance of the DeviceEntity class."""
        Entity.__init__(self, api)
        Device.__init__(self)
        if data:
            self.apply_data(data)
        if device_id:
            self._device_id = device_id
        self._status = DeviceStatus(api, self._device_id)