python-casahome 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,272 @@
1
+ Metadata-Version: 2.5
2
+ Name: python-casahome
3
+ Version: 0.2.0
4
+ Summary: Unofficial async client for the Casa (getcasa.com) member API
5
+ Author: Borski
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Framework :: AsyncIO
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Typing :: Typed
12
+ Requires-Python: >=3.11
13
+ Requires-Dist: aiohttp>=3.9
14
+ Requires-Dist: pydantic>=2.5
15
+ Description-Content-Type: text/markdown
16
+
17
+ # python-casahome
18
+
19
+ Async Python client for the [Casa](https://getcasa.com) home membership API.
20
+
21
+ Unofficial. Not affiliated with or endorsed by Casa.
22
+
23
+ ## Status
24
+
25
+ Version 0.2.0, alpha.
26
+
27
+ - The library is read-heavy. Most methods are GETs, and most of those have been
28
+ confirmed against live traffic.
29
+ - A few write methods exist. They are unverified and haven't been exercised
30
+ against the real backend. Treat them as experimental.
31
+ - Endpoint shapes were inferred from the iOS app and confirmed against live
32
+ traffic where marked. Casa can change its private API at any time.
33
+
34
+ ## Install
35
+
36
+ PyPI isn't set up yet. Install from GitHub:
37
+
38
+ ```
39
+ pip install "python-casahome @ git+https://github.com/borski/python-casahome@v0.2.0"
40
+ ```
41
+
42
+ Requires Python 3.11 or newer.
43
+
44
+ ## Authentication
45
+
46
+ Casa signs members in with Firebase phone auth, and SMS sign-in only works from
47
+ the real app. This library starts from a Firebase refresh token instead and
48
+ exchanges it for short-lived ID tokens.
49
+
50
+ Casa offers no official way to export that token. You obtain your own refresh
51
+ token from your own Casa app session, for example by inspecting your own app's
52
+ traffic during login and reading `refreshToken` from the Firebase token
53
+ response.
54
+
55
+ Treat the refresh token like a password. Anyone holding it can act as you.
56
+ Keep it in a password manager or secret store, never in source control.
57
+
58
+ The token doesn't expire on a timer, but Firebase can rotate it. Pass
59
+ `on_refresh_token_rotated` to `FirebaseAuth` (sync or async) and persist the new
60
+ value when it fires.
61
+
62
+ ## Quick start
63
+
64
+ ```python
65
+ import asyncio
66
+
67
+ from casahome import CasaApi
68
+
69
+
70
+ async def main() -> None:
71
+ async with CasaApi.create("YOUR_REFRESH_TOKEN") as api:
72
+ me = await api.bootstrap()
73
+ for home in me.homes:
74
+ print(home.display_address, home.status)
75
+ weather = await api.weather(home.id)
76
+ print(weather)
77
+
78
+
79
+ asyncio.run(main())
80
+ ```
81
+
82
+ If you already own an `aiohttp.ClientSession` (for example in Home Assistant),
83
+ build the pieces yourself:
84
+
85
+ ```python
86
+ from casahome import CasaApi, CasaClient, FirebaseAuth
87
+
88
+ auth = FirebaseAuth(session, refresh_token, on_refresh_token_rotated=save_token)
89
+ api = CasaApi(
90
+ CasaClient(session, auth),
91
+ device_id=stored_device_id,
92
+ timezone="America/Los_Angeles",
93
+ )
94
+ ```
95
+
96
+ `bootstrap` registers a device with Casa. Long-lived callers should persist
97
+ `api.device_id` and pass it back on the next start. Otherwise every restart adds
98
+ a new device to the account.
99
+
100
+ A runnable example lives in `examples/bootstrap.py`:
101
+
102
+ ```
103
+ CASA_REFRESH_TOKEN=... uv run examples/bootstrap.py
104
+ ```
105
+
106
+ ## Coverage
107
+
108
+ Each method's docstring starts with `VERIFIED` or `UNVERIFIED`.
109
+ `casahome.is_unverified(api.some_method)` reports the same thing at runtime.
110
+
111
+ The "Live-confirmed" column means:
112
+
113
+ - **yes**: the path, method, response envelope and list item shapes were seen
114
+ in live traffic.
115
+ - **partial**: the path, method and envelope were seen, but lists came back
116
+ empty or items are kept as opaque JSON. Item models are inferred.
117
+ - **no**: inferred from the app only. Not seen working live.
118
+
119
+ The envelope is the top-level response keys. Item shape is the structure of
120
+ elements inside lists. All live confirmation dates from 2026-10.
121
+
122
+ ### Reads
123
+
124
+ | Method | Live-confirmed | Notes |
125
+ |---|---|---|
126
+ | `bootstrap` | yes | Profile, homes, badge counts, app update info. |
127
+ | `onboarding_details` | yes | Raw dict, or `None` on 304. |
128
+ | `onboarding_details_typed` | yes | Typed version of the above. |
129
+ | `onboarding_availability` | yes | |
130
+ | `home_details` | yes | Stories, rooms, inventory entities. |
131
+ | `inventory_item` | yes | One entity. |
132
+ | `inventory_makes` | yes | |
133
+ | `inventory_enums` | yes | Takes a property's `enum_type` key, such as `light_fixture_type`. |
134
+ | `inventory_paint_matches` | yes | |
135
+ | `inventory_service_history` | partial | Room and home targets seen. Entity target untested. |
136
+ | `room_types` | yes | |
137
+ | `room_image_options` | yes | |
138
+ | `room_image_candidates` | yes | |
139
+ | `matterport_images` | yes | |
140
+ | `badge_counts` | yes | |
141
+ | `weather` | yes | |
142
+ | `credits_summary` | yes | |
143
+ | `home_feed` | yes | `props` varies by card template and stays a JSON dict. |
144
+ | `home_members` | yes | |
145
+ | `schedule_preferences` | yes | |
146
+ | `notification_settings` | yes | |
147
+ | `access_preferences` | partial | Option values not seen populated. |
148
+ | `autopilot_plans` | yes | |
149
+ | `paint_brands`, `paint_collections`, `paint_colors`, `paint_search` | yes | |
150
+ | `suggested_todos` | yes | Question rounds and destination stay opaque. |
151
+ | `todo_details` | yes | Same caveat. |
152
+ | `document_types` | yes | |
153
+ | `help_center_bundle` | yes | Only `member_ios` tested. |
154
+ | `release_notes` | yes | |
155
+ | `release_notes_diff` | yes | |
156
+ | `casa_ai_bootstrap` | partial | Messages not seen populated. |
157
+ | `casa_ai_messages` | partial | |
158
+ | `requests_tab` | partial | |
159
+ | `completed_requests` | partial | |
160
+ | `calendar` | partial | Bounds sent as epoch seconds. |
161
+ | `calendar_busy` | partial | |
162
+ | `calendar_sync` | partial | |
163
+ | `mailbox`, `mail_items`, `packages` | partial | |
164
+ | `documents` | partial | Query parameters untested. |
165
+ | `work_document_source` | partial | Only the `todo_id` selector tested. |
166
+ | `vehicles` | partial | |
167
+ | `utilities_insights` | partial | |
168
+ | `purchases` | partial | |
169
+ | `property_taxes` | partial | |
170
+ | `recurring_vendor_categories` | yes | |
171
+ | `recurring_vendors` | partial | |
172
+ | `bookable_handyman_tasks` | partial | Items stay opaque JSON. |
173
+ | `referral_code` | partial | `display` and `referred_homes` stay opaque JSON. |
174
+ | `request_details` | no | |
175
+ | `membership_info` | no | Returned 404 in testing. |
176
+ | `membership_savings` | no | Returned 404 in testing. |
177
+ | `availability_request_details` | no | |
178
+ | `document_details` | no | |
179
+ | `document_suggestions` | no | |
180
+ | `document_structure_suggestions` | no | |
181
+ | `request_purchases` | no | |
182
+ | `task_details` | no | |
183
+ | `vendor_visit_details` | no | |
184
+ | `vendor_visit_autopilot_plan` | no | |
185
+ | `vendor_visit_calls` | no | |
186
+ | `vendor_visit_conversation` | no | |
187
+ | `vendor_visit_purchases` | no | |
188
+ | `casa_ai_events` | partial | Opt-in SSE stream. Transport confirmed, event payloads untested. |
189
+
190
+ ### Writes
191
+
192
+ | Method | Live-confirmed |
193
+ |---|---|
194
+ | `create_todo_result` | no |
195
+ | `create_todo` | no |
196
+ | `send_request_message` | no |
197
+ | `update_entity_properties` | no |
198
+
199
+ ## Models
200
+
201
+ Import models from `casahome.models`. Unknown response fields are kept in
202
+ `model_extra` rather than dropped, so new server fields don't break parsing.
203
+ A response that doesn't match the expected shape raises `CasaResponseError`.
204
+
205
+ Identifier arguments are checked before any request. They must be nonempty
206
+ path-safe segments (letters, digits, `.`, `_`, `~`, `-`). IDs aren't trimmed,
207
+ lowercased or forced to UUIDs.
208
+
209
+ Responses can contain personal data: names, contact details, messages,
210
+ documents and purchase info. Avoid logging whole models. URLs in responses are
211
+ returned as data. The library never follows them.
212
+
213
+ ## Writes
214
+
215
+ The write methods are unverified. Their request bodies were inferred from the
216
+ app and have not been exercised against the live backend. Nothing is sent until
217
+ you await a write method.
218
+
219
+ - Each write is sent exactly once. There is no retry, including on 401. The ID
220
+ token is refreshed before the request, and a 401 raises `CasaAuthError`.
221
+ Deciding whether to repeat is up to you.
222
+ - If the response fails to parse, the server may still have performed the
223
+ action. Don't assume a parse error means it's safe to repeat.
224
+ - Request bodies are strict Pydantic models. Unknown fields and invalid values
225
+ raise `CasaRequestError` before any I/O. Free-text fields are capped at
226
+ 10,000 characters.
227
+ - Optional fields set to `None` are omitted from the JSON. Empty strings and
228
+ empty lists are sent as given.
229
+ - `send_request_message` only allows the `member` sender role.
230
+ - `create_todo_result` returns the full envelope, including
231
+ `needs_support_confirmation`. `create_todo` is the older helper that returns
232
+ just the todo.
233
+
234
+ ## CasaAI event stream
235
+
236
+ `api.casa_ai_events(home_id, after=None)` is an opt-in async generator over the
237
+ CasaAI server-sent event stream. It doesn't reconnect on its own. Close it with
238
+ `contextlib.aclosing` if you stop early:
239
+
240
+ ```python
241
+ from contextlib import aclosing
242
+
243
+ from casahome.streaming import CasaAIResyncRequiredEvent, CasaAIThreadUpdateEvent
244
+
245
+ async with aclosing(api.casa_ai_events(home_id, after=saved_cursor)) as events:
246
+ async for event in events:
247
+ saved_cursor = event.id
248
+ if isinstance(event, CasaAIResyncRequiredEvent):
249
+ break # Reload state, then subscribe again.
250
+ if isinstance(event, CasaAIThreadUpdateEvent):
251
+ update = event.payload # Opaque JSON.
252
+ ```
253
+
254
+ Lines are capped at 64 KiB and events at 256 KiB. A 401 refreshes the token and
255
+ retries the GET once.
256
+
257
+ ## Development
258
+
259
+ ```
260
+ uv sync
261
+ uv run pytest -q
262
+ uv run ruff check .
263
+ uv run ruff format --check .
264
+ uv run mypy src tests
265
+ ```
266
+
267
+ Tests use synthetic data and a loopback test server. They make no network calls
268
+ and need no credentials.
269
+
270
+ ## License
271
+
272
+ MIT. See `LICENSE`.
@@ -0,0 +1,42 @@
1
+ casahome/__init__.py,sha256=FUrxuSt6SCLRCNM1nKgjkc7Y9brDHEu4EiFGUkqmM5g,623
2
+ casahome/_base_http.py,sha256=6dO3aEUx0u1JrNSH1HKlCLH2RWmv3ym1aENB3R1Jfjw,615
3
+ casahome/api.py,sha256=31d8xVmjWacQ_IP-GPdoeOFYlCYLOaoz4K5EWaCXBos,49295
4
+ casahome/auth.py,sha256=dzDQ7mDT9HhPlDQDVvQPMlWA1ixlr7duFSfxYf-X9yY,7024
5
+ casahome/client.py,sha256=eD57CrlrEMfE9lqaD8oT7f4mzOodO_xIQM59nZLlUzg,6423
6
+ casahome/const.py,sha256=2LapgPjdsyNr6p5Eu6COmoxoYxmxdpq6EwlvPy7PcQo,1530
7
+ casahome/exceptions.py,sha256=biNTiSergZrNJpHjb1ovwhlmdeoKw2FDcIbk2PQ12Ck,1526
8
+ casahome/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
+ casahome/streaming.py,sha256=osvR7e700QreJGiXu_4_tLEMd6iQD2PxBSwPLf2RtRQ,10600
10
+ casahome/models/__init__.py,sha256=r9WhPcoVe6HL4qdn8JjIgJ7Pn-8zxVexIMpXtqrUjfc,11887
11
+ casahome/models/_base.py,sha256=lk8610B1lWgSHkx7bJmgp1Lv5w0hotag4aF38FiY7Mw,702
12
+ casahome/models/ai.py,sha256=IoLnkBK76_L3On1JrA_JCtX5uXNmr0LZWRVfjcQIbQA,1623
13
+ casahome/models/assets.py,sha256=x_RaOKmubnJ-tDQQi8THyyuNIN4wgpgZYSDwjv590cU,3380
14
+ casahome/models/availability.py,sha256=0DxhWB1_oYEswlex4rLhiicVERerb0aPZY22kKNT4a4,1016
15
+ casahome/models/bootstrap.py,sha256=dQG147w8g8TLPk58KVRBWnIKaa7K9Uxb-i_C6tpEbxM,4010
16
+ casahome/models/calendar.py,sha256=MfUy1PSzaMv-4qUkDcp3MT6X2QvPjBUiD9fOAgo5bcM,803
17
+ casahome/models/catalogs.py,sha256=pvNGP0Os5APtDECQJ3EK41J8Sw5UD64YIwef4HLww_w,1960
18
+ casahome/models/credits.py,sha256=z8vZ33z_UEjGjWr4tfTsfA0bAz2f3Lt-m8AoThGmays,632
19
+ casahome/models/documents.py,sha256=MQKx_KN6W6gQ6_iJSS--0sqqWk7zf3G9P0VjNIWSMAs,3182
20
+ casahome/models/enums.py,sha256=Z_yXKDRdNDGrw03tu8k98e5C140xMuaCRT8UKv_gmh0,5313
21
+ casahome/models/feed.py,sha256=TT72bsuoCkXGHNH6oum0vTflyj3hyQaCy87pUo88uko,1032
22
+ casahome/models/help_center.py,sha256=WGbUNlnX14OnWnlBi0I47EDu3_GCUN8RLFMZZ4esfao,1318
23
+ casahome/models/home.py,sha256=u3Tv4nt7XIzfdSFOiMvnnFQTneKcR5Hf1bbg-SYOTgw,5191
24
+ casahome/models/images.py,sha256=kfRMFbITk7b88jKsEk8uqzvUVPGv2wVyrfDueCUVgso,1077
25
+ casahome/models/mailbox.py,sha256=hRw4hyNEr6RRPoa3VmnJHuwSL3vHhc69sJ9qPfuI9H4,4414
26
+ casahome/models/maintenance.py,sha256=_nO-Gb2IVyobtDRVScpB8RbQy3Z8u_mc2tmq2J21P40,5473
27
+ casahome/models/membership.py,sha256=ZEpp-ph3yKJoNos56iw0-pXranEWwBQKC3ymAvFDIaU,1542
28
+ casahome/models/paint.py,sha256=-Uz8mRh7NbqxIYEedG7oHSk9xHqdjN_057E7kKCNxq4,1218
29
+ casahome/models/preferences.py,sha256=08LKOmQn_23HbzKPWCP4IyugtXL9KKqE7CBjUFfwcJw,2491
30
+ casahome/models/purchases.py,sha256=GPg67Ezz1Hb5ro8H6MYbmuO-RyB8bFoSvjFoVCqt2e8,3324
31
+ casahome/models/read_todos.py,sha256=FdXthUhOigzg00IhLFU_pHiMZSHbJnmCZ8gzpN2y6zk,632
32
+ casahome/models/referral.py,sha256=KqJ0-CBLutVelZI2FyCiBIXGKSMiCXGjzHW8cZ_j49I,580
33
+ casahome/models/requests.py,sha256=Jie3VKXEFvpzmJ4RIPyhN0TzhWRm6DCLH6CVJIsLgtw,3955
34
+ casahome/models/tasks.py,sha256=P52NlcKP8tNRaQhVElBpJmkpXaUdowY1Vx8v2Obsveo,1887
35
+ casahome/models/taxes.py,sha256=yYoL43bMpxoyN0DjWiAnnnX7rQXHLFwaw4HMTxRo0uE,1421
36
+ casahome/models/todos.py,sha256=RxJqlGAUmEtluP3y8brPcIK57Q_wv9i70QT0CZpXdbg,1151
37
+ casahome/models/visits.py,sha256=h4kugiOb5eppF8mFZIlkvuE9EURskrjdXM-tc1UUjNc,4027
38
+ casahome/models/write_contracts.py,sha256=_kM2wMtlG8semmZ2ANnhjL2kf-iqdD0PRlxEv3_3Z9U,5217
39
+ python_casahome-0.2.0.dist-info/METADATA,sha256=jBzjHVHJRto7-g8urWYpUsN9dpflgfOV_tNTioJUb40,9549
40
+ python_casahome-0.2.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
41
+ python_casahome-0.2.0.dist-info/licenses/LICENSE,sha256=Dvy3ioQ2BYi_o6pnuNBrn8xYHudZ6q7-THRl0E9NeCY,1063
42
+ python_casahome-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.4
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Borski
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.