diff --git a/kasa/smartcam/modules/pantilt.py b/kasa/smartcam/modules/pantilt.py index 52b2db0d..d6268e25 100644 --- a/kasa/smartcam/modules/pantilt.py +++ b/kasa/smartcam/modules/pantilt.py @@ -35,7 +35,7 @@ class PanTilt(SmartCamModule): "pan_right", "Pan right", container=self, - attribute_setter=lambda: self.pan(self._pan_step * -1), + attribute_setter=lambda: self.pan(self._pan_step), type=Feature.Type.Action, ) ) @@ -45,7 +45,7 @@ class PanTilt(SmartCamModule): "pan_left", "Pan left", container=self, - attribute_setter=lambda: self.pan(self._pan_step), + attribute_setter=lambda: self.pan(self._pan_step * -1), type=Feature.Type.Action, ) ) diff --git a/tests/smartcam/modules/test_pantilt.py b/tests/smartcam/modules/test_pantilt.py index 626ac333..8c88df5a 100644 --- a/tests/smartcam/modules/test_pantilt.py +++ b/tests/smartcam/modules/test_pantilt.py @@ -210,3 +210,25 @@ async def test_pantilt_no_presets_in_data(dev: Device, mocker: MockerFixture) -> assert pantilt_mod._presets == {} assert pantilt_mod.presets == {} + + +@pantilt +@pytest.mark.parametrize( + ("feature_id", "x_coord", "y_coord"), + [ + ("pan_right", "30", "0"), + ("pan_left", "-30", "0"), + ("tilt_up", "0", "10"), + ("tilt_down", "0", "-10"), + ], +) +async def test_pantilt_direction_features( + dev: Device, mocker: MockerFixture, feature_id: str, x_coord: str, y_coord: str +) -> None: + mock_protocol_query = mocker.patch.object(dev.protocol, "query", return_value={}) + + await dev.features[feature_id].set_value(None) + + mock_protocol_query.assert_called_with( + request={"do": {"motor": {"move": {"x_coord": x_coord, "y_coord": y_coord}}}} + )