diff --git a/pyproject.toml b/pyproject.toml index 22e5f132..3f01cf7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -122,6 +122,7 @@ max-attributes = 8 [tool.pylint."MESSAGES CONTROL"] disable= [ + "duplicate-code", "format", "unsubscriptable-object", ] diff --git a/src/elgato/elgato.py b/src/elgato/elgato.py index 1979bb66..0cc29a0e 100644 --- a/src/elgato/elgato.py +++ b/src/elgato/elgato.py @@ -135,6 +135,10 @@ async def identify(self) -> None: """Identify this Elgato Light device by making it blink.""" await self._request("identify", method=METH_POST) + async def restart(self) -> None: + """Restart the Elgato Light device.""" + await self._request("restart", method=METH_POST) + async def display_name(self, name: str) -> None: """Change the display name of an Elgato Light device. diff --git a/tests/test_restart.py b/tests/test_restart.py new file mode 100644 index 00000000..1f69c57c --- /dev/null +++ b/tests/test_restart.py @@ -0,0 +1,24 @@ +"""Tests for restarting the Elgato Light device.""" + +from aiohttp import ClientSession +from aresponses import ResponsesMockServer + +from elgato import Elgato + + +async def test_restart(aresponses: ResponsesMockServer) -> None: + """Test restarting the Elgato Light.""" + aresponses.add( + "example.com:9123", + "/elgato/restart", + "POST", + aresponses.Response( + status=200, + headers={"Content-Type": "application/json"}, + text="", + ), + ) + + async with ClientSession() as session: + elgato = Elgato("example.com", session=session) + await elgato.restart()