Refactor Home Assistant API and schema validation

- Completely rewrote HassInstance class with fetch-based API methods
- Updated Home Assistant schemas to be more precise and flexible
- Removed deprecated test environment configuration file
- Enhanced WebSocket client implementation
- Improved test coverage for Home Assistant API and schema validation
- Simplified type definitions and error handling
This commit is contained in:
jango-blockchained
2025-01-30 10:51:25 +01:00
parent 732a727d27
commit 8152313f52
8 changed files with 561 additions and 200 deletions

50
src/types/hass.ts Normal file
View File

@@ -0,0 +1,50 @@
export interface AuthMessage {
type: 'auth';
access_token: string;
}
export interface ResultMessage {
id: number;
type: 'result';
success: boolean;
result?: any;
}
export interface WebSocketError {
code: string;
message: string;
}
export interface Event {
event_type: string;
data: any;
origin: string;
time_fired: string;
context: {
id: string;
parent_id: string | null;
user_id: string | null;
};
}
export interface Entity {
entity_id: string;
state: string;
attributes: Record<string, any>;
last_changed: string;
last_updated: string;
context: {
id: string;
parent_id: string | null;
user_id: string | null;
};
}
export interface StateChangedEvent extends Event {
event_type: 'state_changed';
data: {
entity_id: string;
new_state: Entity | null;
old_state: Entity | null;
};
}