get_hardware
Returns all hardware and gateways configured in Domoticz, allowing you to monitor connected smart home devices and their configurations.
Instructions
Get all hardware/gateways configured in Domoticz.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/domoticz_mcp/server.py:880-884 (handler)The actual handler for the 'get_hardware' tool. It sends a request to the Domoticz API with param=gethardware and returns the raw response text.
async def get_hardware() -> str: """Get all hardware/gateways configured in Domoticz.""" async with create_client() as client: response = await _do_request(client, "GET", f"{DOMOTICZ_API_URL}?type=command¶m=gethardware") return response.text - src/domoticz_mcp/server.py:879-879 (registration)Registration of 'get_hardware' as an MCP tool via the @mcp.tool() decorator.
@mcp.tool() - src/domoticz_mcp/server.py:880-884 (helper)The docstring for the function describes it: 'Get all hardware/gateways configured in Domoticz.'
async def get_hardware() -> str: """Get all hardware/gateways configured in Domoticz.""" async with create_client() as client: response = await _do_request(client, "GET", f"{DOMOTICZ_API_URL}?type=command¶m=gethardware") return response.text - tests/test_server.py:327-351 (helper)Test that exercises the get_hardware tool by importing it, mocking the API response, and calling the function.
from domoticz_mcp.server import get_scenes, switch_scene, get_rooms, get_hardware # get_scenes respx.get(f"{DOMOTICZ_API_URL}?type=command¶m=getscenes").mock( return_value=Response(200, json={"result": [{"idx": "1", "Name": "Scene1"}]}) ) await get_scenes() # switch_scene respx.get(f"{DOMOTICZ_API_URL}?type=command¶m=switchscene&idx=1&switchcmd=On").mock( return_value=Response(200, json={"status": "OK"}) ) await switch_scene("On", idx=1) # get_rooms respx.get(f"{DOMOTICZ_API_URL}?type=command¶m=getplans&order=name&used=true").mock( return_value=Response(200, json=PLANS_MOCK_RESPONSE) ) await get_rooms() # get_hardware respx.get(f"{DOMOTICZ_API_URL}?type=command¶m=gethardware").mock( return_value=Response(200, json={"result": [{"idx": "1", "Name": "Dummy"}]}) ) await get_hardware() - tests/test_server.py:494-497 (helper)Mock setup for gethardware API used in test_get_overview, demonstrating the API endpoint used.
# Mock hardware respx.get(f"{DOMOTICZ_API_URL}?type=command¶m=gethardware").mock( return_value=Response(200, json={"result": [{"idx": "1"}]}) )