refactor: optimize configuration and tool implementations

- Standardized error handling across tool implementations
- Improved return type consistency for tool execution results
- Simplified configuration parsing and type definitions
- Enhanced type safety for various configuration schemas
- Cleaned up and normalized tool response structures
- Updated SSE and event subscription tool implementations
This commit is contained in:
jango-blockchained
2025-02-04 00:56:45 +01:00
parent 9a02bdaf11
commit bc1dc8278a
65 changed files with 7094 additions and 7675 deletions

142
src/types/hass.d.ts vendored
View File

@@ -1,81 +1,81 @@
declare namespace HomeAssistant {
interface Entity {
entity_id: string;
state: string;
attributes: Record<string, any>;
last_changed: string;
last_updated: string;
context: {
id: string;
parent_id?: string;
user_id?: string;
};
}
interface Entity {
entity_id: string;
state: string;
attributes: Record<string, any>;
last_changed: string;
last_updated: string;
context: {
id: string;
parent_id?: string;
user_id?: string;
};
}
interface Service {
domain: string;
service: string;
target?: {
entity_id?: string | string[];
device_id?: string | string[];
area_id?: string | string[];
};
service_data?: Record<string, any>;
}
interface Service {
domain: string;
service: string;
target?: {
entity_id?: string | string[];
device_id?: string | string[];
area_id?: string | string[];
};
service_data?: Record<string, any>;
}
interface WebsocketMessage {
type: string;
id?: number;
[key: string]: any;
}
interface WebsocketMessage {
type: string;
id?: number;
[key: string]: any;
}
interface AuthMessage extends WebsocketMessage {
type: 'auth';
access_token: string;
}
interface AuthMessage extends WebsocketMessage {
type: "auth";
access_token: string;
}
interface SubscribeEventsMessage extends WebsocketMessage {
type: 'subscribe_events';
event_type?: string;
}
interface SubscribeEventsMessage extends WebsocketMessage {
type: "subscribe_events";
event_type?: string;
}
interface StateChangedEvent {
event_type: 'state_changed';
data: {
entity_id: string;
new_state: Entity | null;
old_state: Entity | null;
};
origin: string;
time_fired: string;
context: {
id: string;
parent_id?: string;
user_id?: string;
};
}
interface StateChangedEvent {
event_type: "state_changed";
data: {
entity_id: string;
new_state: Entity | null;
old_state: Entity | null;
};
origin: string;
time_fired: string;
context: {
id: string;
parent_id?: string;
user_id?: string;
};
}
interface Config {
latitude: number;
longitude: number;
elevation: number;
unit_system: {
length: string;
mass: string;
temperature: string;
volume: string;
};
location_name: string;
time_zone: string;
components: string[];
version: string;
}
interface Config {
latitude: number;
longitude: number;
elevation: number;
unit_system: {
length: string;
mass: string;
temperature: string;
volume: string;
};
location_name: string;
time_zone: string;
components: string[];
version: string;
}
interface ApiError {
code: string;
message: string;
details?: Record<string, any>;
}
interface ApiError {
code: string;
message: string;
details?: Record<string, any>;
}
}
export = HomeAssistant;
export = HomeAssistant;