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:
50
src/types/hass.ts
Normal file
50
src/types/hass.ts
Normal 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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user