Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for restarting an Elgato device (#693 #693

Merged
merged 2 commits into from
Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ max-attributes = 8

[tool.pylint."MESSAGES CONTROL"]
disable= [
"duplicate-code",
"format",
"unsubscriptable-object",
]
Expand Down
4 changes: 4 additions & 0 deletions src/elgato/elgato.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
24 changes: 24 additions & 0 deletions tests/test_restart.py
Original file line number Diff line number Diff line change
@@ -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()