@sanlim/home-assistant-switch-mcp-server
Version:
A MCP server for Home Assistant switch services.
19 lines (18 loc) • 597 B
JavaScript
export class HomeAssistantStateRequestService {
client;
constructor(client) {
this.client = client;
}
async getAllStates() {
return this.client.makeRequest("states");
}
async getEntityState(entity_id) {
return this.client.makeRequest(`states/${entity_id}`);
}
async searchByFriendlyName(friendly_name) {
const allStates = await this.getAllStates();
if (!allStates)
return null;
return allStates.filter(state => state.attributes.friendly_name?.toLowerCase().includes(friendly_name.toLowerCase()));
}
}