get_connectivity_report
Identifies smart home devices that haven't reported in within a specified number of hours, helping you detect connectivity issues.
Instructions
Get a list of devices that haven't checked in/updated within the specified timeframe.
Args: hours: Number of hours threshold for considering a device 'unresponsive' (default: 24).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hours | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/domoticz_mcp/server.py:1074-1109 (handler)The handler function for get_connectivity_report tool. Fetches all devices, filters those whose LastUpdate is older than the specified hours threshold, and returns a sorted list of unresponsive devices.
@mcp.tool() async def get_connectivity_report(hours: int = 24) -> str: """Get a list of devices that haven't checked in/updated within the specified timeframe. Args: hours: Number of hours threshold for considering a device 'unresponsive' (default: 24). """ async with create_client() as client: devices = await _get_cached_data(client, _device_cache, f"{DOMOTICZ_API_URL}?type=command¶m=getdevices&filter=all&used=true") now = datetime.now() threshold_time = now - timedelta(hours=hours) results = [] for dev in devices: last_update_str = dev.get("LastUpdate") if not last_update_str: continue try: # Domoticz format: YYYY-MM-DD HH:MM:SS last_update = datetime.strptime(last_update_str, "%Y-%m-%d %H:%M:%S") if last_update < threshold_time: results.append({ "idx": dev.get("idx"), "Name": dev.get("Name"), "LastUpdate": last_update_str, "HardwareName": dev.get("HardwareName"), "Type": dev.get("Type"), "Data": dev.get("Data") }) except ValueError: continue # Sort by oldest update first results.sort(key=lambda x: x["LastUpdate"]) return json.dumps({"status": "OK", "result": results}) - src/domoticz_mcp/server.py:1074-1074 (registration)Registration of get_connectivity_report as an MCP tool via the @mcp.tool() decorator on line 1074.
@mcp.tool() - src/domoticz_mcp/server.py:1075-1080 (schema)Input schema for get_connectivity_report: accepts a single integer parameter 'hours' (default 24) representing the threshold for considering a device unresponsive.
async def get_connectivity_report(hours: int = 24) -> str: """Get a list of devices that haven't checked in/updated within the specified timeframe. Args: hours: Number of hours threshold for considering a device 'unresponsive' (default: 24). """ - src/domoticz_mcp/server.py:346-352 (helper)Helper function _get_cached_data used by get_connectivity_report to fetch and cache the device list from Domoticz API.
async def _get_cached_data(client: "httpx.AsyncClient", cache_obj: Dict[str, Any], api_url: str, key_path: str = "result") -> List[Dict[str, Any]]: now = time.time() if cache_obj["data"] is None or (now - cache_obj["timestamp"]) > CACHE_TTL: response = await _do_request(client, "GET", api_url) cache_obj["data"] = response.json().get(key_path, []) cache_obj["timestamp"] = now return cache_obj["data"]