pyhive-integration 1.0.9.dev3__tar.gz → 2.0.0b2__tar.gz

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.
Files changed (88) hide show
  1. pyhive_integration-2.0.0b2/MANIFEST.in +5 -0
  2. pyhive_integration-2.0.0b2/PKG-INFO +228 -0
  3. pyhive_integration-2.0.0b2/README.md +185 -0
  4. pyhive_integration-2.0.0b2/pyhive_integration.egg-info/PKG-INFO +228 -0
  5. {pyhive_integration-1.0.9.dev3 → pyhive_integration-2.0.0b2}/pyhive_integration.egg-info/SOURCES.txt +25 -8
  6. pyhive_integration-2.0.0b2/pyhive_integration.egg-info/requires.txt +18 -0
  7. {pyhive_integration-1.0.9.dev3 → pyhive_integration-2.0.0b2}/pyhive_integration.egg-info/top_level.txt +1 -0
  8. pyhive_integration-2.0.0b2/pyproject.toml +162 -0
  9. pyhive_integration-2.0.0b2/setup.cfg +4 -0
  10. {pyhive_integration-1.0.9.dev3 → pyhive_integration-2.0.0b2}/setup.py +14 -19
  11. pyhive_integration-2.0.0b2/src/__init__.py +29 -0
  12. pyhive_integration-2.0.0b2/src/action.py +15 -0
  13. pyhive_integration-2.0.0b2/src/api/device_registration.py +339 -0
  14. pyhive_integration-2.0.0b2/src/api/hive_api.py +237 -0
  15. pyhive_integration-2.0.0b2/src/api/hive_async_api.py +239 -0
  16. {pyhive_integration-1.0.9.dev3 → pyhive_integration-2.0.0b2}/src/api/hive_auth.py +43 -39
  17. pyhive_integration-2.0.0b2/src/api/hive_auth_async.py +502 -0
  18. pyhive_integration-2.0.0b2/src/api/srp_crypto.py +89 -0
  19. pyhive_integration-2.0.0b2/src/boost.py +15 -0
  20. pyhive_integration-2.0.0b2/src/color.py +15 -0
  21. pyhive_integration-2.0.0b2/src/data/data.json +4064 -0
  22. pyhive_integration-2.0.0b2/src/device_attributes.py +15 -0
  23. pyhive_integration-2.0.0b2/src/devices/__init__.py +0 -0
  24. pyhive_integration-2.0.0b2/src/devices/action.py +122 -0
  25. pyhive_integration-2.0.0b2/src/devices/boost.py +47 -0
  26. pyhive_integration-2.0.0b2/src/devices/color.py +147 -0
  27. pyhive_integration-2.0.0b2/src/devices/heating.py +475 -0
  28. pyhive_integration-2.0.0b2/src/devices/hotwater.py +235 -0
  29. pyhive_integration-2.0.0b2/src/devices/hub.py +164 -0
  30. pyhive_integration-2.0.0b2/src/devices/light.py +225 -0
  31. pyhive_integration-2.0.0b2/src/devices/plug.py +175 -0
  32. pyhive_integration-2.0.0b2/src/devices/sensor.py +181 -0
  33. pyhive_integration-2.0.0b2/src/heating.py +15 -0
  34. pyhive_integration-2.0.0b2/src/helper/compat_aliases.py +145 -0
  35. pyhive_integration-2.0.0b2/src/helper/const.py +325 -0
  36. {pyhive_integration-1.0.9.dev3/src → pyhive_integration-2.0.0b2/src/helper}/device_attributes.py +11 -20
  37. pyhive_integration-2.0.0b2/src/helper/device_handler_base.py +78 -0
  38. pyhive_integration-2.0.0b2/src/helper/hive_exceptions.py +133 -0
  39. {pyhive_integration-1.0.9.dev3 → pyhive_integration-2.0.0b2}/src/helper/hive_helper.py +96 -80
  40. pyhive_integration-2.0.0b2/src/helper/hivedataclasses.py +113 -0
  41. pyhive_integration-2.0.0b2/src/helper/map.py +25 -0
  42. pyhive_integration-2.0.0b2/src/hive.py +65 -0
  43. pyhive_integration-2.0.0b2/src/hotwater.py +15 -0
  44. pyhive_integration-2.0.0b2/src/hub.py +15 -0
  45. pyhive_integration-2.0.0b2/src/light.py +15 -0
  46. pyhive_integration-2.0.0b2/src/plug.py +15 -0
  47. pyhive_integration-2.0.0b2/src/sensor.py +15 -0
  48. pyhive_integration-2.0.0b2/src/session/__init__.py +88 -0
  49. pyhive_integration-2.0.0b2/src/session/auth.py +380 -0
  50. pyhive_integration-2.0.0b2/src/session/discovery.py +345 -0
  51. pyhive_integration-2.0.0b2/src/session/polling.py +239 -0
  52. pyhive_integration-2.0.0b2/src/session_discovery.py +15 -0
  53. pyhive_integration-2.0.0b2/src/session_polling.py +15 -0
  54. pyhive_integration-2.0.0b2/src/session_tokens.py +15 -0
  55. pyhive_integration-1.0.9.dev3/MANIFEST.in +0 -4
  56. pyhive_integration-1.0.9.dev3/PKG-INFO +0 -34
  57. pyhive_integration-1.0.9.dev3/README.md +0 -21
  58. pyhive_integration-1.0.9.dev3/pyhive_integration.egg-info/PKG-INFO +0 -34
  59. pyhive_integration-1.0.9.dev3/pyhive_integration.egg-info/requires.txt +0 -13
  60. pyhive_integration-1.0.9.dev3/pyproject.toml +0 -3
  61. pyhive_integration-1.0.9.dev3/requirements.txt +0 -7
  62. pyhive_integration-1.0.9.dev3/requirements_test.txt +0 -4
  63. pyhive_integration-1.0.9.dev3/setup.cfg +0 -66
  64. pyhive_integration-1.0.9.dev3/src/__init__.py +0 -12
  65. pyhive_integration-1.0.9.dev3/src/action.py +0 -134
  66. pyhive_integration-1.0.9.dev3/src/alarm.py +0 -142
  67. pyhive_integration-1.0.9.dev3/src/api/hive_api.py +0 -366
  68. pyhive_integration-1.0.9.dev3/src/api/hive_async_api.py +0 -379
  69. pyhive_integration-1.0.9.dev3/src/api/hive_auth_async.py +0 -831
  70. pyhive_integration-1.0.9.dev3/src/camera.py +0 -200
  71. pyhive_integration-1.0.9.dev3/src/heating.py +0 -643
  72. pyhive_integration-1.0.9.dev3/src/helper/const.py +0 -171
  73. pyhive_integration-1.0.9.dev3/src/helper/debugger.py +0 -65
  74. pyhive_integration-1.0.9.dev3/src/helper/hive_exceptions.py +0 -99
  75. pyhive_integration-1.0.9.dev3/src/helper/hivedataclasses.py +0 -22
  76. pyhive_integration-1.0.9.dev3/src/helper/map.py +0 -15
  77. pyhive_integration-1.0.9.dev3/src/hive.py +0 -133
  78. pyhive_integration-1.0.9.dev3/src/hotwater.py +0 -309
  79. pyhive_integration-1.0.9.dev3/src/hub.py +0 -90
  80. pyhive_integration-1.0.9.dev3/src/light.py +0 -520
  81. pyhive_integration-1.0.9.dev3/src/plug.py +0 -239
  82. pyhive_integration-1.0.9.dev3/src/sensor.py +0 -169
  83. pyhive_integration-1.0.9.dev3/src/session.py +0 -1035
  84. pyhive_integration-1.0.9.dev3/tests/test_hub.py +0 -8
  85. {pyhive_integration-1.0.9.dev3 → pyhive_integration-2.0.0b2}/LICENSE +0 -0
  86. {pyhive_integration-1.0.9.dev3 → pyhive_integration-2.0.0b2}/pyhive_integration.egg-info/dependency_links.txt +0 -0
  87. {pyhive_integration-1.0.9.dev3 → pyhive_integration-2.0.0b2}/src/api/__init__.py +0 -0
  88. {pyhive_integration-1.0.9.dev3 → pyhive_integration-2.0.0b2}/src/helper/__init__.py +0 -0
@@ -0,0 +1,5 @@
1
+ recursive-include src *.py
2
+ recursive-include src/data *.json
3
+ include LICENSE README.md
4
+ global-exclude .DS_Store
5
+ global-exclude *.py[cod]
@@ -0,0 +1,228 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyhive-integration
3
+ Version: 2.0.0b2
4
+ Summary: A Python library to interface with the Hive API
5
+ Author-email: KJonline24 <53_galleys_snark@icloud.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Pyhass/Pyhive
8
+ Project-URL: Source, https://github.com/Pyhass/Pyhive
9
+ Project-URL: Issue Tracker, https://github.com/Pyhass/Pyhive/issues
10
+ Keywords: hive,home,api,library,smart-home,home-automation,IoT,async,integration
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Home Automation
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: boto3>=1.34
26
+ Requires-Dist: botocore>=1.34
27
+ Requires-Dist: requests
28
+ Requires-Dist: aiohttp
29
+ Requires-Dist: pyquery
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: pytest-asyncio; extra == "dev"
33
+ Requires-Dist: pytest-cov; extra == "dev"
34
+ Requires-Dist: pylint; extra == "dev"
35
+ Requires-Dist: ruff; extra == "dev"
36
+ Requires-Dist: mypy; extra == "dev"
37
+ Requires-Dist: bandit; extra == "dev"
38
+ Requires-Dist: pre-commit; extra == "dev"
39
+ Requires-Dist: graphifyy; extra == "dev"
40
+ Requires-Dist: unasync; extra == "dev"
41
+ Requires-Dist: tokenize-rt; extra == "dev"
42
+ Dynamic: license-file
43
+
44
+ # pyhive-integration
45
+
46
+ ![CI](https://github.com/Pyhass/Pyhive/actions/workflows/ci.yml/badge.svg) ![PyPI](https://img.shields.io/pypi/v/pyhive-integration) ![Python](https://img.shields.io/pypi/pyversions/pyhive-integration) ![License](https://img.shields.io/github/license/Pyhass/Pyhive)
47
+
48
+ A Python library for interfacing with the [Hive](https://www.hivehome.com/) smart home platform. Provides both async (`apyhiveapi`) and sync (`pyhiveapi`) APIs, and is designed primarily for use with [Home Assistant](https://www.home-assistant.io/) — though it works standalone too.
49
+
50
+ > **Package rename notice:** This package replaces the legacy `pyhiveapi` package. The module names, API, and functionality are identical — only the PyPI distribution name changed.
51
+
52
+ ---
53
+
54
+ ## Features
55
+
56
+ - Async-first design with a generated sync wrapper (no asyncio boilerplate needed in sync contexts)
57
+ - AWS Cognito SRP authentication with SMS two-factor authentication support
58
+ - Automatic token refresh at 90% of token lifetime with silent retry on expiry
59
+ - Polling-based device state with a smart cache to avoid stale reads during in-progress polls
60
+ - Full device discovery — returns a ready-to-use device list for Home Assistant entity creation
61
+ - File-based offline mode for development and testing without live credentials
62
+
63
+ ## Supported Devices
64
+
65
+ | Device Type | Capabilities |
66
+ | --- | --- |
67
+ | **Heating** (thermostat, TRV) | Current / target temperature, mode (schedule / manual / off), boost on/off, heat-on-demand, min/max range, schedule now/next/later |
68
+ | **Hot Water** | Mode (schedule / on / off), boost on/off, state |
69
+ | **Lights** | On/off, brightness, colour temperature, full RGB colour, colour mode |
70
+ | **Smart Plugs** | On/off, power usage |
71
+ | **Sensors** | Motion, contact (open/close), battery level, online status |
72
+ | **Hub / Sense** | Smoke, CO, dog bark, glass break detection |
73
+
74
+ ---
75
+
76
+ ## Installation
77
+
78
+ ```bash
79
+ pip install pyhive-integration
80
+ ```
81
+
82
+ Requires Python 3.10+.
83
+
84
+ ---
85
+
86
+ ## Quick Start
87
+
88
+ ### Async
89
+
90
+ ```python
91
+ import asyncio
92
+ from apyhiveapi import Auth, Hive
93
+
94
+ async def main():
95
+ auth = Auth(username="user@example.com", password="yourpassword")
96
+ tokens = await auth.login()
97
+
98
+ # If SMS 2FA is required:
99
+ # tokens = await auth.sms_2fa("123456", tokens)
100
+
101
+ hive = Hive(username="user@example.com", password="yourpassword")
102
+ await hive.startSession({"tokens": tokens})
103
+
104
+ for device in hive.session.data.devices.values():
105
+ print(device)
106
+
107
+ asyncio.run(main())
108
+ ```
109
+
110
+ ### Sync
111
+
112
+ ```python
113
+ from pyhiveapi import Auth, Hive
114
+
115
+ auth = Auth(username="user@example.com", password="yourpassword")
116
+ tokens = auth.login()
117
+
118
+ hive = Hive(username="user@example.com", password="yourpassword")
119
+ hive.startSession({"tokens": tokens})
120
+
121
+ for device in hive.session.data.devices.values():
122
+ print(device)
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Authentication
128
+
129
+ Authentication uses the AWS Cognito SRP flow. If your account has SMS two-factor authentication enabled, `login()` will raise `HiveSmsRequired` — call `sms_2fa(code, tokens)` with the code sent to your phone.
130
+
131
+ ```python
132
+ from apyhiveapi import Auth
133
+ from apyhiveapi.helper.hive_exceptions import HiveSmsRequired
134
+
135
+ auth = Auth(username="user@example.com", password="yourpassword")
136
+ try:
137
+ tokens = await auth.login()
138
+ except HiveSmsRequired:
139
+ code = input("SMS code: ")
140
+ tokens = await auth.sms_2fa(code, tokens)
141
+ ```
142
+
143
+ > **Note:** Only the Hive account owner is supported. Guest accounts cannot be used.
144
+
145
+ ---
146
+
147
+ ## Controlling Devices
148
+
149
+ After `startSession`, device modules are available directly on the `Hive` instance:
150
+
151
+ ```python
152
+ # Heating
153
+ await hive.heating.set_target_temperature(device, 21.0)
154
+ await hive.heating.set_mode(device, "SCHEDULE")
155
+ await hive.heating.set_boost_on(device, mins=30, temp=22.0)
156
+ await hive.heating.set_boost_off(device)
157
+
158
+ # Hot water
159
+ await hive.hotwater.set_mode(device, "ON")
160
+ await hive.hotwater.set_boost_on(device, mins=60)
161
+
162
+ # Lights
163
+ await hive.light.set_status_on(device)
164
+ await hive.light.set_brightness(device, 80)
165
+ await hive.light.set_color_temp(device, 4000)
166
+ await hive.light.set_color(device, [255, 100, 0])
167
+
168
+ # Smart plug
169
+ await hive.switch.turn_on(device)
170
+ await hive.switch.turn_off(device)
171
+
172
+ # Force a data refresh
173
+ await hive.force_update()
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Offline / File-Based Testing
179
+
180
+ Set `username="use@file.com"` to load device state from bundled JSON fixtures in `src/data/` instead of making live API calls. Useful for development without real Hive credentials.
181
+
182
+ ```python
183
+ hive = Hive(username="use@file.com", password="")
184
+ await hive.startSession({})
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Architecture
190
+
191
+ The library exposes two packages built from the same source:
192
+
193
+ - **`apyhiveapi`** — async package (source in `src/`)
194
+ - **`pyhiveapi`** — sync package (auto-generated from `src/` via `unasync` during build)
195
+
196
+ Never edit the generated sync files — edit the async source in `src/` only.
197
+
198
+ ---
199
+
200
+ ## Development
201
+
202
+ ```bash
203
+ # Install dev dependencies
204
+ pip install -e ".[dev]"
205
+
206
+ # Run linters
207
+ pre-commit run --all-files
208
+
209
+ # Run tests
210
+ pytest tests/
211
+
212
+ # Regenerate sync package
213
+ python setup.py build_py
214
+ ```
215
+
216
+ ---
217
+
218
+ ## Links
219
+
220
+ - [PyPI](https://pypi.org/project/pyhive-integration/)
221
+ - [Source](https://github.com/Pyhass/Pyhive)
222
+ - [Issue Tracker](https://github.com/Pyhass/Pyhive/issues)
223
+
224
+ ---
225
+
226
+ ## License
227
+
228
+ MIT License — see [LICENSE](https://github.com/Pyhass/Pyhive/blob/master/LICENSE) for details.
@@ -0,0 +1,185 @@
1
+ # pyhive-integration
2
+
3
+ ![CI](https://github.com/Pyhass/Pyhive/actions/workflows/ci.yml/badge.svg) ![PyPI](https://img.shields.io/pypi/v/pyhive-integration) ![Python](https://img.shields.io/pypi/pyversions/pyhive-integration) ![License](https://img.shields.io/github/license/Pyhass/Pyhive)
4
+
5
+ A Python library for interfacing with the [Hive](https://www.hivehome.com/) smart home platform. Provides both async (`apyhiveapi`) and sync (`pyhiveapi`) APIs, and is designed primarily for use with [Home Assistant](https://www.home-assistant.io/) — though it works standalone too.
6
+
7
+ > **Package rename notice:** This package replaces the legacy `pyhiveapi` package. The module names, API, and functionality are identical — only the PyPI distribution name changed.
8
+
9
+ ---
10
+
11
+ ## Features
12
+
13
+ - Async-first design with a generated sync wrapper (no asyncio boilerplate needed in sync contexts)
14
+ - AWS Cognito SRP authentication with SMS two-factor authentication support
15
+ - Automatic token refresh at 90% of token lifetime with silent retry on expiry
16
+ - Polling-based device state with a smart cache to avoid stale reads during in-progress polls
17
+ - Full device discovery — returns a ready-to-use device list for Home Assistant entity creation
18
+ - File-based offline mode for development and testing without live credentials
19
+
20
+ ## Supported Devices
21
+
22
+ | Device Type | Capabilities |
23
+ | --- | --- |
24
+ | **Heating** (thermostat, TRV) | Current / target temperature, mode (schedule / manual / off), boost on/off, heat-on-demand, min/max range, schedule now/next/later |
25
+ | **Hot Water** | Mode (schedule / on / off), boost on/off, state |
26
+ | **Lights** | On/off, brightness, colour temperature, full RGB colour, colour mode |
27
+ | **Smart Plugs** | On/off, power usage |
28
+ | **Sensors** | Motion, contact (open/close), battery level, online status |
29
+ | **Hub / Sense** | Smoke, CO, dog bark, glass break detection |
30
+
31
+ ---
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install pyhive-integration
37
+ ```
38
+
39
+ Requires Python 3.10+.
40
+
41
+ ---
42
+
43
+ ## Quick Start
44
+
45
+ ### Async
46
+
47
+ ```python
48
+ import asyncio
49
+ from apyhiveapi import Auth, Hive
50
+
51
+ async def main():
52
+ auth = Auth(username="user@example.com", password="yourpassword")
53
+ tokens = await auth.login()
54
+
55
+ # If SMS 2FA is required:
56
+ # tokens = await auth.sms_2fa("123456", tokens)
57
+
58
+ hive = Hive(username="user@example.com", password="yourpassword")
59
+ await hive.startSession({"tokens": tokens})
60
+
61
+ for device in hive.session.data.devices.values():
62
+ print(device)
63
+
64
+ asyncio.run(main())
65
+ ```
66
+
67
+ ### Sync
68
+
69
+ ```python
70
+ from pyhiveapi import Auth, Hive
71
+
72
+ auth = Auth(username="user@example.com", password="yourpassword")
73
+ tokens = auth.login()
74
+
75
+ hive = Hive(username="user@example.com", password="yourpassword")
76
+ hive.startSession({"tokens": tokens})
77
+
78
+ for device in hive.session.data.devices.values():
79
+ print(device)
80
+ ```
81
+
82
+ ---
83
+
84
+ ## Authentication
85
+
86
+ Authentication uses the AWS Cognito SRP flow. If your account has SMS two-factor authentication enabled, `login()` will raise `HiveSmsRequired` — call `sms_2fa(code, tokens)` with the code sent to your phone.
87
+
88
+ ```python
89
+ from apyhiveapi import Auth
90
+ from apyhiveapi.helper.hive_exceptions import HiveSmsRequired
91
+
92
+ auth = Auth(username="user@example.com", password="yourpassword")
93
+ try:
94
+ tokens = await auth.login()
95
+ except HiveSmsRequired:
96
+ code = input("SMS code: ")
97
+ tokens = await auth.sms_2fa(code, tokens)
98
+ ```
99
+
100
+ > **Note:** Only the Hive account owner is supported. Guest accounts cannot be used.
101
+
102
+ ---
103
+
104
+ ## Controlling Devices
105
+
106
+ After `startSession`, device modules are available directly on the `Hive` instance:
107
+
108
+ ```python
109
+ # Heating
110
+ await hive.heating.set_target_temperature(device, 21.0)
111
+ await hive.heating.set_mode(device, "SCHEDULE")
112
+ await hive.heating.set_boost_on(device, mins=30, temp=22.0)
113
+ await hive.heating.set_boost_off(device)
114
+
115
+ # Hot water
116
+ await hive.hotwater.set_mode(device, "ON")
117
+ await hive.hotwater.set_boost_on(device, mins=60)
118
+
119
+ # Lights
120
+ await hive.light.set_status_on(device)
121
+ await hive.light.set_brightness(device, 80)
122
+ await hive.light.set_color_temp(device, 4000)
123
+ await hive.light.set_color(device, [255, 100, 0])
124
+
125
+ # Smart plug
126
+ await hive.switch.turn_on(device)
127
+ await hive.switch.turn_off(device)
128
+
129
+ # Force a data refresh
130
+ await hive.force_update()
131
+ ```
132
+
133
+ ---
134
+
135
+ ## Offline / File-Based Testing
136
+
137
+ Set `username="use@file.com"` to load device state from bundled JSON fixtures in `src/data/` instead of making live API calls. Useful for development without real Hive credentials.
138
+
139
+ ```python
140
+ hive = Hive(username="use@file.com", password="")
141
+ await hive.startSession({})
142
+ ```
143
+
144
+ ---
145
+
146
+ ## Architecture
147
+
148
+ The library exposes two packages built from the same source:
149
+
150
+ - **`apyhiveapi`** — async package (source in `src/`)
151
+ - **`pyhiveapi`** — sync package (auto-generated from `src/` via `unasync` during build)
152
+
153
+ Never edit the generated sync files — edit the async source in `src/` only.
154
+
155
+ ---
156
+
157
+ ## Development
158
+
159
+ ```bash
160
+ # Install dev dependencies
161
+ pip install -e ".[dev]"
162
+
163
+ # Run linters
164
+ pre-commit run --all-files
165
+
166
+ # Run tests
167
+ pytest tests/
168
+
169
+ # Regenerate sync package
170
+ python setup.py build_py
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Links
176
+
177
+ - [PyPI](https://pypi.org/project/pyhive-integration/)
178
+ - [Source](https://github.com/Pyhass/Pyhive)
179
+ - [Issue Tracker](https://github.com/Pyhass/Pyhive/issues)
180
+
181
+ ---
182
+
183
+ ## License
184
+
185
+ MIT License — see [LICENSE](https://github.com/Pyhass/Pyhive/blob/master/LICENSE) for details.
@@ -0,0 +1,228 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyhive-integration
3
+ Version: 2.0.0b2
4
+ Summary: A Python library to interface with the Hive API
5
+ Author-email: KJonline24 <53_galleys_snark@icloud.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Pyhass/Pyhive
8
+ Project-URL: Source, https://github.com/Pyhass/Pyhive
9
+ Project-URL: Issue Tracker, https://github.com/Pyhass/Pyhive/issues
10
+ Keywords: hive,home,api,library,smart-home,home-automation,IoT,async,integration
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Home Automation
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: boto3>=1.34
26
+ Requires-Dist: botocore>=1.34
27
+ Requires-Dist: requests
28
+ Requires-Dist: aiohttp
29
+ Requires-Dist: pyquery
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest; extra == "dev"
32
+ Requires-Dist: pytest-asyncio; extra == "dev"
33
+ Requires-Dist: pytest-cov; extra == "dev"
34
+ Requires-Dist: pylint; extra == "dev"
35
+ Requires-Dist: ruff; extra == "dev"
36
+ Requires-Dist: mypy; extra == "dev"
37
+ Requires-Dist: bandit; extra == "dev"
38
+ Requires-Dist: pre-commit; extra == "dev"
39
+ Requires-Dist: graphifyy; extra == "dev"
40
+ Requires-Dist: unasync; extra == "dev"
41
+ Requires-Dist: tokenize-rt; extra == "dev"
42
+ Dynamic: license-file
43
+
44
+ # pyhive-integration
45
+
46
+ ![CI](https://github.com/Pyhass/Pyhive/actions/workflows/ci.yml/badge.svg) ![PyPI](https://img.shields.io/pypi/v/pyhive-integration) ![Python](https://img.shields.io/pypi/pyversions/pyhive-integration) ![License](https://img.shields.io/github/license/Pyhass/Pyhive)
47
+
48
+ A Python library for interfacing with the [Hive](https://www.hivehome.com/) smart home platform. Provides both async (`apyhiveapi`) and sync (`pyhiveapi`) APIs, and is designed primarily for use with [Home Assistant](https://www.home-assistant.io/) — though it works standalone too.
49
+
50
+ > **Package rename notice:** This package replaces the legacy `pyhiveapi` package. The module names, API, and functionality are identical — only the PyPI distribution name changed.
51
+
52
+ ---
53
+
54
+ ## Features
55
+
56
+ - Async-first design with a generated sync wrapper (no asyncio boilerplate needed in sync contexts)
57
+ - AWS Cognito SRP authentication with SMS two-factor authentication support
58
+ - Automatic token refresh at 90% of token lifetime with silent retry on expiry
59
+ - Polling-based device state with a smart cache to avoid stale reads during in-progress polls
60
+ - Full device discovery — returns a ready-to-use device list for Home Assistant entity creation
61
+ - File-based offline mode for development and testing without live credentials
62
+
63
+ ## Supported Devices
64
+
65
+ | Device Type | Capabilities |
66
+ | --- | --- |
67
+ | **Heating** (thermostat, TRV) | Current / target temperature, mode (schedule / manual / off), boost on/off, heat-on-demand, min/max range, schedule now/next/later |
68
+ | **Hot Water** | Mode (schedule / on / off), boost on/off, state |
69
+ | **Lights** | On/off, brightness, colour temperature, full RGB colour, colour mode |
70
+ | **Smart Plugs** | On/off, power usage |
71
+ | **Sensors** | Motion, contact (open/close), battery level, online status |
72
+ | **Hub / Sense** | Smoke, CO, dog bark, glass break detection |
73
+
74
+ ---
75
+
76
+ ## Installation
77
+
78
+ ```bash
79
+ pip install pyhive-integration
80
+ ```
81
+
82
+ Requires Python 3.10+.
83
+
84
+ ---
85
+
86
+ ## Quick Start
87
+
88
+ ### Async
89
+
90
+ ```python
91
+ import asyncio
92
+ from apyhiveapi import Auth, Hive
93
+
94
+ async def main():
95
+ auth = Auth(username="user@example.com", password="yourpassword")
96
+ tokens = await auth.login()
97
+
98
+ # If SMS 2FA is required:
99
+ # tokens = await auth.sms_2fa("123456", tokens)
100
+
101
+ hive = Hive(username="user@example.com", password="yourpassword")
102
+ await hive.startSession({"tokens": tokens})
103
+
104
+ for device in hive.session.data.devices.values():
105
+ print(device)
106
+
107
+ asyncio.run(main())
108
+ ```
109
+
110
+ ### Sync
111
+
112
+ ```python
113
+ from pyhiveapi import Auth, Hive
114
+
115
+ auth = Auth(username="user@example.com", password="yourpassword")
116
+ tokens = auth.login()
117
+
118
+ hive = Hive(username="user@example.com", password="yourpassword")
119
+ hive.startSession({"tokens": tokens})
120
+
121
+ for device in hive.session.data.devices.values():
122
+ print(device)
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Authentication
128
+
129
+ Authentication uses the AWS Cognito SRP flow. If your account has SMS two-factor authentication enabled, `login()` will raise `HiveSmsRequired` — call `sms_2fa(code, tokens)` with the code sent to your phone.
130
+
131
+ ```python
132
+ from apyhiveapi import Auth
133
+ from apyhiveapi.helper.hive_exceptions import HiveSmsRequired
134
+
135
+ auth = Auth(username="user@example.com", password="yourpassword")
136
+ try:
137
+ tokens = await auth.login()
138
+ except HiveSmsRequired:
139
+ code = input("SMS code: ")
140
+ tokens = await auth.sms_2fa(code, tokens)
141
+ ```
142
+
143
+ > **Note:** Only the Hive account owner is supported. Guest accounts cannot be used.
144
+
145
+ ---
146
+
147
+ ## Controlling Devices
148
+
149
+ After `startSession`, device modules are available directly on the `Hive` instance:
150
+
151
+ ```python
152
+ # Heating
153
+ await hive.heating.set_target_temperature(device, 21.0)
154
+ await hive.heating.set_mode(device, "SCHEDULE")
155
+ await hive.heating.set_boost_on(device, mins=30, temp=22.0)
156
+ await hive.heating.set_boost_off(device)
157
+
158
+ # Hot water
159
+ await hive.hotwater.set_mode(device, "ON")
160
+ await hive.hotwater.set_boost_on(device, mins=60)
161
+
162
+ # Lights
163
+ await hive.light.set_status_on(device)
164
+ await hive.light.set_brightness(device, 80)
165
+ await hive.light.set_color_temp(device, 4000)
166
+ await hive.light.set_color(device, [255, 100, 0])
167
+
168
+ # Smart plug
169
+ await hive.switch.turn_on(device)
170
+ await hive.switch.turn_off(device)
171
+
172
+ # Force a data refresh
173
+ await hive.force_update()
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Offline / File-Based Testing
179
+
180
+ Set `username="use@file.com"` to load device state from bundled JSON fixtures in `src/data/` instead of making live API calls. Useful for development without real Hive credentials.
181
+
182
+ ```python
183
+ hive = Hive(username="use@file.com", password="")
184
+ await hive.startSession({})
185
+ ```
186
+
187
+ ---
188
+
189
+ ## Architecture
190
+
191
+ The library exposes two packages built from the same source:
192
+
193
+ - **`apyhiveapi`** — async package (source in `src/`)
194
+ - **`pyhiveapi`** — sync package (auto-generated from `src/` via `unasync` during build)
195
+
196
+ Never edit the generated sync files — edit the async source in `src/` only.
197
+
198
+ ---
199
+
200
+ ## Development
201
+
202
+ ```bash
203
+ # Install dev dependencies
204
+ pip install -e ".[dev]"
205
+
206
+ # Run linters
207
+ pre-commit run --all-files
208
+
209
+ # Run tests
210
+ pytest tests/
211
+
212
+ # Regenerate sync package
213
+ python setup.py build_py
214
+ ```
215
+
216
+ ---
217
+
218
+ ## Links
219
+
220
+ - [PyPI](https://pypi.org/project/pyhive-integration/)
221
+ - [Source](https://github.com/Pyhass/Pyhive)
222
+ - [Issue Tracker](https://github.com/Pyhass/Pyhive/issues)
223
+
224
+ ---
225
+
226
+ ## License
227
+
228
+ MIT License — see [LICENSE](https://github.com/Pyhass/Pyhive/blob/master/LICENSE) for details.
@@ -2,9 +2,6 @@ LICENSE
2
2
  MANIFEST.in
3
3
  README.md
4
4
  pyproject.toml
5
- requirements.txt
6
- requirements_test.txt
7
- setup.cfg
8
5
  setup.py
9
6
  pyhive_integration.egg-info/PKG-INFO
10
7
  pyhive_integration.egg-info/SOURCES.txt
@@ -13,8 +10,8 @@ pyhive_integration.egg-info/requires.txt
13
10
  pyhive_integration.egg-info/top_level.txt
14
11
  src/__init__.py
15
12
  src/action.py
16
- src/alarm.py
17
- src/camera.py
13
+ src/boost.py
14
+ src/color.py
18
15
  src/device_attributes.py
19
16
  src/heating.py
20
17
  src/hive.py
@@ -23,17 +20,37 @@ src/hub.py
23
20
  src/light.py
24
21
  src/plug.py
25
22
  src/sensor.py
26
- src/session.py
23
+ src/session_discovery.py
24
+ src/session_polling.py
25
+ src/session_tokens.py
27
26
  src/api/__init__.py
27
+ src/api/device_registration.py
28
28
  src/api/hive_api.py
29
29
  src/api/hive_async_api.py
30
30
  src/api/hive_auth.py
31
31
  src/api/hive_auth_async.py
32
+ src/api/srp_crypto.py
33
+ src/data/data.json
34
+ src/devices/__init__.py
35
+ src/devices/action.py
36
+ src/devices/boost.py
37
+ src/devices/color.py
38
+ src/devices/heating.py
39
+ src/devices/hotwater.py
40
+ src/devices/hub.py
41
+ src/devices/light.py
42
+ src/devices/plug.py
43
+ src/devices/sensor.py
32
44
  src/helper/__init__.py
45
+ src/helper/compat_aliases.py
33
46
  src/helper/const.py
34
- src/helper/debugger.py
47
+ src/helper/device_attributes.py
48
+ src/helper/device_handler_base.py
35
49
  src/helper/hive_exceptions.py
36
50
  src/helper/hive_helper.py
37
51
  src/helper/hivedataclasses.py
38
52
  src/helper/map.py
39
- tests/test_hub.py
53
+ src/session/__init__.py
54
+ src/session/auth.py
55
+ src/session/discovery.py
56
+ src/session/polling.py