Exceptions
HassetteError
Bases: Exception
Base exception for all Hassette errors.
Source code in src/hassette/exceptions.py
11 12 | |
FatalError
Bases: HassetteError
Custom exception to indicate a fatal error in the application.
Exceptions that indicate that the service should not be restarted should inherit from this class.
Source code in src/hassette/exceptions.py
15 16 17 18 19 | |
BaseUrlRequiredError
Bases: FatalError
Custom exception to indicate that the base_url configuration is required.
Source code in src/hassette/exceptions.py
22 23 | |
IPV6NotSupportedError
Bases: FatalError
Custom exception to indicate that IPv6 addresses are not supported in base_url.
Source code in src/hassette/exceptions.py
26 27 | |
SchemeRequiredInBaseUrlError
Bases: FatalError
Custom exception to indicate that the base_url must include a scheme (http:// or https://).
Source code in src/hassette/exceptions.py
30 31 | |
ConnectionClosedError
Bases: HassetteError
Custom exception to indicate that the WebSocket connection was closed unexpectedly.
Source code in src/hassette/exceptions.py
34 35 | |
SchemaVersionError
Bases: HassetteError
Raised when the on-disk database schema version is ahead of the code's expected head.
This indicates the database was created by a newer binary. The service should not auto-delete the database in this case; manual intervention is required.
Listed in DatabaseService.restart_spec.fatal_error_names so the ServiceWatcher
triggers immediate shutdown (FAILED path) rather than retrying.
Source code in src/hassette/exceptions.py
38 39 40 41 42 43 44 45 46 | |
CouldNotFindHomeAssistantError
Bases: FatalError
Custom exception to indicate that the Home Assistant instance could not be found.
Source code in src/hassette/exceptions.py
49 50 51 52 53 54 55 56 57 | |
RetryableConnectionClosedError
Bases: ConnectionClosedError
Custom exception to indicate that the WebSocket connection was closed but can be retried.
Source code in src/hassette/exceptions.py
60 61 62 63 64 65 | |
FailedMessageError
Bases: HassetteError
Custom exception to indicate that a message sent to the WebSocket failed.
Exposes HA's structured error surface as instance attributes so callers can react programmatically::
try:
await api.update_input_boolean(
"vacation_mode",
UpdateInputBooleanParams(initial=False),
)
except FailedMessageError as e:
if e.code == "not_found":
# Helper was deleted between list and update — recreate it
...
code is populated when the error originates from an HA error envelope
(see FailedMessageError.from_error_response). It is None for
locally-synthesized failures such as transport timeouts.
Source code in src/hassette/exceptions.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
InvalidAuthError
Bases: FatalError
Custom exception to indicate that the authentication token is invalid.
Source code in src/hassette/exceptions.py
111 112 | |
InvalidInheritanceError
Bases: TypeError, HassetteError
Raised when a class inherits from App incorrectly.
Source code in src/hassette/exceptions.py
115 116 | |
UndefinedUserConfigError
Bases: TypeError, HassetteError
Raised when a class does not define a user_config_class.
Source code in src/hassette/exceptions.py
119 120 | |
EntityNotFoundError
Bases: ValueError, HassetteError
Custom error for handling 404 in the Api
Source code in src/hassette/exceptions.py
123 124 | |
ResourceNotReadyError
Bases: HassetteError
Custom exception to indicate that a resource is not ready for use.
Source code in src/hassette/exceptions.py
127 128 | |
AppPrecheckFailedError
Bases: HassetteError
Custom exception to indicate that one or more prechecks for an app failed.
Source code in src/hassette/exceptions.py
131 132 | |
CannotOverrideFinalError
Bases: TypeError, HassetteError
Custom exception to indicate that a final method or class cannot be overridden.
Source code in src/hassette/exceptions.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
DependencyError
Bases: HassetteError
Base class for dependency-related errors.
Source code in src/hassette/exceptions.py
157 158 | |
DependencyInjectionError
Bases: DependencyError
Raised when dependency injection fails due to invalid handler signature or annotations.
This exception indicates a user error in handler definition, such as: - Using invalid parameter types (*args, positional-only) - Missing required type annotations - Incompatible annotation types
These errors should be fixed by updating the handler signature.
Source code in src/hassette/exceptions.py
161 162 163 164 165 166 167 168 169 170 | |
DependencyResolutionError
Bases: DependencyError
Raised when dependency injection fails during runtime extraction or conversion.
This exception indicates a runtime issue with: - Extracting parameter values from events - Converting values to expected types - Type mismatches between extracted values and annotations
These errors may indicate issues with event data, converter logic, or type registry.
Source code in src/hassette/exceptions.py
173 174 175 176 177 178 179 180 181 182 | |
StateRegistryError
Bases: HassetteError
Base exception for state registry errors.
Source code in src/hassette/exceptions.py
185 186 | |
RegistryNotReadyError
Bases: StateRegistryError
Raised when attempting to use the registry before any classes are registered.
Source code in src/hassette/exceptions.py
189 190 191 192 193 194 195 196 197 | |
NoDomainAnnotationError
Bases: StateRegistryError
Raised when a state class does not define a domain annotation or the annotation is empty.
Generally ignored, this indicates that the class is a base class and not intended to be registered.
Source code in src/hassette/exceptions.py
200 201 202 203 204 205 206 207 208 209 210 211 | |
DomainNotFoundError
Bases: StateRegistryError
Raised when no state class is found for a given domain.
Source code in src/hassette/exceptions.py
214 215 216 217 218 219 | |
HassetteNotInitializedError
Bases: RuntimeError
Exception raised when Hassette is not initialized in the current context.
Source code in src/hassette/exceptions.py
222 223 | |
InvalidDataForStateConversionError
Bases: StateRegistryError
Raised when the data provided for state conversion is invalid or malformed.
Source code in src/hassette/exceptions.py
226 227 228 229 230 231 | |
UnableToConvertStateError
Bases: StateRegistryError
Raised when a state dictionary cannot be converted to a specific state class.
Source code in src/hassette/exceptions.py
234 235 236 237 238 239 240 | |
ConvertedTypeDoesNotMatchError
Bases: StateRegistryError
Raised when a converted state does not match the expected type.
Source code in src/hassette/exceptions.py
243 244 245 246 247 248 249 250 251 252 253 | |
InvalidEntityIdError
Bases: StateRegistryError
Raised when an entity ID is invalid or malformed.
Source code in src/hassette/exceptions.py
256 257 258 259 260 261 | |
UnableToConvertValueError
Bases: HassetteError
Raised when a raw value cannot be converted from one type to another via the TypeRegistry.
Source code in src/hassette/exceptions.py
264 265 | |
InvalidLifecycleTransitionError
Bases: HassetteError
Raised when a ResourceStatus transition is invalid in strict lifecycle mode.
Only raised when HassetteConfig.strict_lifecycle is True. In non-strict
mode the same condition logs a WARNING instead.
Attributes:
| Name | Type | Description |
|---|---|---|
from_status |
The status the resource was in before the attempted transition. |
|
to_status |
The status the resource was attempting to transition to. |
|
resource_name |
The unique_name of the resource that made the invalid transition. |
Source code in src/hassette/exceptions.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 | |
ListenerNameRequiredError
Bases: HassetteError
Raised at call time when name= is omitted on a DB-registered listener.
Attributes:
| Name | Type | Description |
|---|---|---|
handler_method |
Fully-qualified name of the handler function. |
|
topic |
The event topic the listener was being registered for. |
Source code in src/hassette/exceptions.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
DuplicateListenerError
Bases: HassetteError
Raised at call time when a second listener with the same (name, topic) is
registered within the same app instance in the same session.
Detected in-memory by the Bus before any database write. Cross-session duplicates are handled by upsert and are not an error.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
The stable name that collided. |
|
topic |
The event topic both listeners were registered for. |
|
existing_handler |
Fully-qualified name of the already-registered handler. |
|
duplicate_handler |
Fully-qualified name of the handler that triggered the error. |
Source code in src/hassette/exceptions.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |
RegistryValidationError
Bases: HassetteError
Raised when startup registry validation finds error-level issues.
Raised by validate_registries(strict=True) after collecting all issues.
Hassette.wire_services() passes strict=config.strict_lifecycle, so in
production this only fires when the user explicitly enables strict mode.
Attributes:
| Name | Type | Description |
|---|---|---|
issues |
The full list of validation issues found. Always contains at least one error-severity issue when this exception is raised. |
Source code in src/hassette/exceptions.py
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |