UNPKG

@sanlim/home-assistant-switch-mcp-server

Version:
16 lines (15 loc) 607 B
import { formatResponse } from "../helpers/format.js"; export class HomeAssistantSwitchService { requestService; constructor(requestService) { this.requestService = requestService; } async callSwitchService({ entity_id, service }) { const data = await this.requestService.callSwitchService({ entity_id, service }); if (!data) { return `Failed to ${service} switch ${entity_id}`; } const action = service === 'turn_on' ? 'turned on' : 'turned off'; return formatResponse(`Successfully ${action} switch ${entity_id}`, data); } }