ovos-phal-plugin-ha-link 0.1.0a1__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.
- ovos_phal_plugin_ha_link-0.1.0a1/LICENSE +202 -0
- ovos_phal_plugin_ha_link-0.1.0a1/PKG-INFO +107 -0
- ovos_phal_plugin_ha_link-0.1.0a1/README.md +85 -0
- ovos_phal_plugin_ha_link-0.1.0a1/ovos_phal_plugin_ha_link/__init__.py +118 -0
- ovos_phal_plugin_ha_link-0.1.0a1/ovos_phal_plugin_ha_link/link.py +183 -0
- ovos_phal_plugin_ha_link-0.1.0a1/ovos_phal_plugin_ha_link.egg-info/PKG-INFO +107 -0
- ovos_phal_plugin_ha_link-0.1.0a1/ovos_phal_plugin_ha_link.egg-info/SOURCES.txt +11 -0
- ovos_phal_plugin_ha_link-0.1.0a1/ovos_phal_plugin_ha_link.egg-info/dependency_links.txt +1 -0
- ovos_phal_plugin_ha_link-0.1.0a1/ovos_phal_plugin_ha_link.egg-info/entry_points.txt +2 -0
- ovos_phal_plugin_ha_link-0.1.0a1/ovos_phal_plugin_ha_link.egg-info/requires.txt +4 -0
- ovos_phal_plugin_ha_link-0.1.0a1/ovos_phal_plugin_ha_link.egg-info/top_level.txt +1 -0
- ovos_phal_plugin_ha_link-0.1.0a1/pyproject.toml +35 -0
- ovos_phal_plugin_ha_link-0.1.0a1/setup.cfg +4 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ovos-phal-plugin-ha-link
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: OpenVoiceOS PHAL plugin: links the device to Home Assistant - it connects itself and carries its bus to the OpenVoiceOS integration
|
|
5
|
+
Author: Andreas Lorensen
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/andlo/ovos-phal-plugin-ha-link
|
|
8
|
+
Project-URL: Issues, https://github.com/andlo/ovos-phal-plugin-ha-link/issues
|
|
9
|
+
Project-URL: Home Assistant integration, https://github.com/andlo/ha-ovos-integration
|
|
10
|
+
Keywords: ovos,openvoiceos,plugin,phal,home-assistant,homeassistant,assist
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: ovos-plugin-manager>=0.0.26
|
|
18
|
+
Requires-Dist: ovos-utils>=0.0.38
|
|
19
|
+
Requires-Dist: ovos-bus-client>=0.0.8
|
|
20
|
+
Requires-Dist: aiohttp>=3.9
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# ovos-phal-plugin-ha-link
|
|
24
|
+
|
|
25
|
+
An [OpenVoiceOS](https://openvoiceos.org) PHAL plugin that links the device to
|
|
26
|
+
[Home Assistant](https://www.home-assistant.io).
|
|
27
|
+
|
|
28
|
+
The device connects to Home Assistant itself and carries its message bus both
|
|
29
|
+
ways to the [OpenVoiceOS integration](https://github.com/andlo/ha-ovos-integration).
|
|
30
|
+
In Home Assistant it shows up as a device, with what the bus can see and set:
|
|
31
|
+
|
|
32
|
+
- volume, mute and listening on/off: automations can turn listening off at night
|
|
33
|
+
- its state (idle, listening, thinking, speaking), the last question and the last answer
|
|
34
|
+
- **Say** (`notify.send_message`) and **Ask** (`ovos.ask`)
|
|
35
|
+
- the device's own sensors, when a plugin reports them (`ovos.phal.sensor`)
|
|
36
|
+
|
|
37
|
+
No port is opened on the device and nothing has to reach it from outside, so it
|
|
38
|
+
also works behind NAT. Any OVOS install can use it: ovos-installer, raspOVOS,
|
|
39
|
+
a Mark II, an OVOS in a VM.
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install --pre ovos-phal-plugin-ha-link
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
In Home Assistant, install the [OpenVoiceOS integration](https://github.com/andlo/ha-ovos-integration)
|
|
48
|
+
(0.3.0 or newer), add it, and choose **An OpenVoiceOS device**. That lets
|
|
49
|
+
devices connect. Then make a long-lived access token: your profile → Security.
|
|
50
|
+
|
|
51
|
+
## Configure
|
|
52
|
+
|
|
53
|
+
In `mycroft.conf`:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"PHAL": {
|
|
58
|
+
"ovos-phal-plugin-ha-link": {
|
|
59
|
+
"url": "http://homeassistant.local:8123",
|
|
60
|
+
"token": "<the long-lived access token>",
|
|
61
|
+
"name": "Kitchen"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
| Setting | |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `url` | Home Assistant's address |
|
|
70
|
+
| `token` | a long-lived access token |
|
|
71
|
+
| `name` | the device's name in Home Assistant (default: the host name) |
|
|
72
|
+
| `model` | shown on the device page (default: `OpenVoiceOS`) |
|
|
73
|
+
| `panel_url` | the device's [ovos-control-panel](https://github.com/OpenVoiceOS/ovos-control-panel), reached here on the device (default `http://127.0.0.1:8500`; `false` for none) |
|
|
74
|
+
| `panel_token` | its access token (default: `webui.access_token` from `mycroft.conf`) |
|
|
75
|
+
| `panel_public_url` | where a browser can open the panel, for "Open control panel" in Home Assistant (optional) |
|
|
76
|
+
|
|
77
|
+
Restart OVOS' PHAL service. The device then appears in Home Assistant under
|
|
78
|
+
**Settings → Devices & services → Discovered**. Add it there, once. The plugin
|
|
79
|
+
keeps the device's id in `~/.local/state/ovos-phal-plugin-ha-link/device_id`,
|
|
80
|
+
so it stays the same device.
|
|
81
|
+
|
|
82
|
+
## How it works
|
|
83
|
+
|
|
84
|
+
It uses the integration's protocol ([docs/protocol.md](https://github.com/andlo/ha-ovos-integration/blob/master/docs/protocol.md)):
|
|
85
|
+
`ovos/connect` over Home Assistant's WebSocket API, then bus messages both
|
|
86
|
+
ways. What Home Assistant sends goes on the bus as it is. Of the device's own
|
|
87
|
+
messages, only the types Home Assistant asks for (the `forward` list) are
|
|
88
|
+
sent. It connects again by itself when Home Assistant restarts.
|
|
89
|
+
|
|
90
|
+
## The control panel
|
|
91
|
+
|
|
92
|
+
When [ovos-control-panel](https://github.com/OpenVoiceOS/ovos-control-panel)
|
|
93
|
+
runs on the device, Home Assistant also gets what it can set: language, units,
|
|
94
|
+
voice, speech to text, wake word, skills on and off, updates, restart and
|
|
95
|
+
reboot ([ha-ovos-integration#15](https://github.com/andlo/ha-ovos-integration/issues/15)).
|
|
96
|
+
Home Assistant's requests come through this link, and the plugin calls the
|
|
97
|
+
panel here on the device, so the panel never has to be opened on the network.
|
|
98
|
+
Restart and reboot need the panel's access token (`webui.access_token`).
|
|
99
|
+
|
|
100
|
+
## Coming
|
|
101
|
+
|
|
102
|
+
- What the device sends out on the network ([#16](https://github.com/andlo/ha-ovos-integration/issues/16)).
|
|
103
|
+
- The device as an Assist satellite ([#13](https://github.com/andlo/ha-ovos-integration/issues/13)).
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
Apache-2.0
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# ovos-phal-plugin-ha-link
|
|
2
|
+
|
|
3
|
+
An [OpenVoiceOS](https://openvoiceos.org) PHAL plugin that links the device to
|
|
4
|
+
[Home Assistant](https://www.home-assistant.io).
|
|
5
|
+
|
|
6
|
+
The device connects to Home Assistant itself and carries its message bus both
|
|
7
|
+
ways to the [OpenVoiceOS integration](https://github.com/andlo/ha-ovos-integration).
|
|
8
|
+
In Home Assistant it shows up as a device, with what the bus can see and set:
|
|
9
|
+
|
|
10
|
+
- volume, mute and listening on/off: automations can turn listening off at night
|
|
11
|
+
- its state (idle, listening, thinking, speaking), the last question and the last answer
|
|
12
|
+
- **Say** (`notify.send_message`) and **Ask** (`ovos.ask`)
|
|
13
|
+
- the device's own sensors, when a plugin reports them (`ovos.phal.sensor`)
|
|
14
|
+
|
|
15
|
+
No port is opened on the device and nothing has to reach it from outside, so it
|
|
16
|
+
also works behind NAT. Any OVOS install can use it: ovos-installer, raspOVOS,
|
|
17
|
+
a Mark II, an OVOS in a VM.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install --pre ovos-phal-plugin-ha-link
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
In Home Assistant, install the [OpenVoiceOS integration](https://github.com/andlo/ha-ovos-integration)
|
|
26
|
+
(0.3.0 or newer), add it, and choose **An OpenVoiceOS device**. That lets
|
|
27
|
+
devices connect. Then make a long-lived access token: your profile → Security.
|
|
28
|
+
|
|
29
|
+
## Configure
|
|
30
|
+
|
|
31
|
+
In `mycroft.conf`:
|
|
32
|
+
|
|
33
|
+
```json
|
|
34
|
+
{
|
|
35
|
+
"PHAL": {
|
|
36
|
+
"ovos-phal-plugin-ha-link": {
|
|
37
|
+
"url": "http://homeassistant.local:8123",
|
|
38
|
+
"token": "<the long-lived access token>",
|
|
39
|
+
"name": "Kitchen"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
| Setting | |
|
|
46
|
+
|---|---|
|
|
47
|
+
| `url` | Home Assistant's address |
|
|
48
|
+
| `token` | a long-lived access token |
|
|
49
|
+
| `name` | the device's name in Home Assistant (default: the host name) |
|
|
50
|
+
| `model` | shown on the device page (default: `OpenVoiceOS`) |
|
|
51
|
+
| `panel_url` | the device's [ovos-control-panel](https://github.com/OpenVoiceOS/ovos-control-panel), reached here on the device (default `http://127.0.0.1:8500`; `false` for none) |
|
|
52
|
+
| `panel_token` | its access token (default: `webui.access_token` from `mycroft.conf`) |
|
|
53
|
+
| `panel_public_url` | where a browser can open the panel, for "Open control panel" in Home Assistant (optional) |
|
|
54
|
+
|
|
55
|
+
Restart OVOS' PHAL service. The device then appears in Home Assistant under
|
|
56
|
+
**Settings → Devices & services → Discovered**. Add it there, once. The plugin
|
|
57
|
+
keeps the device's id in `~/.local/state/ovos-phal-plugin-ha-link/device_id`,
|
|
58
|
+
so it stays the same device.
|
|
59
|
+
|
|
60
|
+
## How it works
|
|
61
|
+
|
|
62
|
+
It uses the integration's protocol ([docs/protocol.md](https://github.com/andlo/ha-ovos-integration/blob/master/docs/protocol.md)):
|
|
63
|
+
`ovos/connect` over Home Assistant's WebSocket API, then bus messages both
|
|
64
|
+
ways. What Home Assistant sends goes on the bus as it is. Of the device's own
|
|
65
|
+
messages, only the types Home Assistant asks for (the `forward` list) are
|
|
66
|
+
sent. It connects again by itself when Home Assistant restarts.
|
|
67
|
+
|
|
68
|
+
## The control panel
|
|
69
|
+
|
|
70
|
+
When [ovos-control-panel](https://github.com/OpenVoiceOS/ovos-control-panel)
|
|
71
|
+
runs on the device, Home Assistant also gets what it can set: language, units,
|
|
72
|
+
voice, speech to text, wake word, skills on and off, updates, restart and
|
|
73
|
+
reboot ([ha-ovos-integration#15](https://github.com/andlo/ha-ovos-integration/issues/15)).
|
|
74
|
+
Home Assistant's requests come through this link, and the plugin calls the
|
|
75
|
+
panel here on the device, so the panel never has to be opened on the network.
|
|
76
|
+
Restart and reboot need the panel's access token (`webui.access_token`).
|
|
77
|
+
|
|
78
|
+
## Coming
|
|
79
|
+
|
|
80
|
+
- What the device sends out on the network ([#16](https://github.com/andlo/ha-ovos-integration/issues/16)).
|
|
81
|
+
- The device as an Assist satellite ([#13](https://github.com/andlo/ha-ovos-integration/issues/13)).
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
Apache-2.0
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""ovos-phal-plugin-ha-link: links an OpenVoiceOS device to Home Assistant.
|
|
2
|
+
|
|
3
|
+
The device connects to Home Assistant itself (Home Assistant's WebSocket
|
|
4
|
+
API, the OpenVoiceOS integration's ovos/connect) and carries its bus both
|
|
5
|
+
ways, so it shows up in Home Assistant as a device: volume, listening on/off,
|
|
6
|
+
state, last question and answer, its sensors, "say" and "ask". No port is
|
|
7
|
+
opened on the device, and it works behind NAT.
|
|
8
|
+
|
|
9
|
+
Configuration, in mycroft.conf:
|
|
10
|
+
|
|
11
|
+
"PHAL": {
|
|
12
|
+
"ovos-phal-plugin-ha-link": {
|
|
13
|
+
"url": "http://homeassistant.local:8123",
|
|
14
|
+
"token": "<a long-lived access token>",
|
|
15
|
+
"name": "Kitchen"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
The first time, Home Assistant shows the device under Settings -> Devices &
|
|
20
|
+
services -> Discovered; add it there.
|
|
21
|
+
"""
|
|
22
|
+
from __future__ import annotations
|
|
23
|
+
|
|
24
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
25
|
+
import json
|
|
26
|
+
from pathlib import Path
|
|
27
|
+
import socket
|
|
28
|
+
import uuid
|
|
29
|
+
|
|
30
|
+
from ovos_bus_client.message import Message
|
|
31
|
+
from ovos_plugin_manager.phal import PHALPlugin
|
|
32
|
+
from ovos_utils.log import LOG
|
|
33
|
+
from ovos_utils.xdg_utils import xdg_state_home
|
|
34
|
+
|
|
35
|
+
from .link import HALink
|
|
36
|
+
|
|
37
|
+
PLUGIN = "ovos-phal-plugin-ha-link"
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _version(package: str) -> str | None:
|
|
41
|
+
try:
|
|
42
|
+
return version(package)
|
|
43
|
+
except PackageNotFoundError:
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def device_id() -> str:
|
|
48
|
+
"""Stable per device: made once, kept in the XDG state folder."""
|
|
49
|
+
path = Path(xdg_state_home()) / PLUGIN / "device_id"
|
|
50
|
+
if path.exists():
|
|
51
|
+
return path.read_text().strip()
|
|
52
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
53
|
+
new = f"ovos-{uuid.uuid4()}"
|
|
54
|
+
path.write_text(new)
|
|
55
|
+
return new
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class HALinkPlugin(PHALPlugin):
|
|
59
|
+
def __init__(self, bus=None, config=None):
|
|
60
|
+
super().__init__(bus=bus, name=PLUGIN, config=config)
|
|
61
|
+
url, token = self.config.get("url"), self.config.get("token")
|
|
62
|
+
if not url or not token:
|
|
63
|
+
LOG.warning(f"{PLUGIN}: set url and token in mycroft.conf (PHAL -> {PLUGIN}) "
|
|
64
|
+
"to link this device to Home Assistant")
|
|
65
|
+
self.link = None
|
|
66
|
+
return
|
|
67
|
+
lang = None
|
|
68
|
+
try:
|
|
69
|
+
from ovos_config import Configuration
|
|
70
|
+
lang = Configuration().get("lang")
|
|
71
|
+
except Exception: # noqa: BLE001 - the language is nice to have
|
|
72
|
+
pass
|
|
73
|
+
info = {
|
|
74
|
+
"device_id": self.config.get("device_id") or device_id(),
|
|
75
|
+
"name": self.config.get("name") or socket.gethostname(),
|
|
76
|
+
"model": self.config.get("model") or "OpenVoiceOS",
|
|
77
|
+
"manufacturer": "OpenVoiceOS",
|
|
78
|
+
"sw_version": _version("ovos-core") or _version(PLUGIN),
|
|
79
|
+
}
|
|
80
|
+
if lang:
|
|
81
|
+
info["lang"] = lang
|
|
82
|
+
# the control panel on this device, offered to HA through the link
|
|
83
|
+
panel_url = self.config.get("panel_url", "http://127.0.0.1:8500")
|
|
84
|
+
panel_token = self.config.get("panel_token")
|
|
85
|
+
if not panel_token:
|
|
86
|
+
try:
|
|
87
|
+
from ovos_config import Configuration
|
|
88
|
+
panel_token = (Configuration().get("webui") or {}).get("access_token")
|
|
89
|
+
except Exception: # noqa: BLE001
|
|
90
|
+
panel_token = None
|
|
91
|
+
if self.config.get("panel_public_url"):
|
|
92
|
+
info["panel_url"] = self.config["panel_public_url"]
|
|
93
|
+
self.link = HALink(url, token, info, on_bus=self._from_ha,
|
|
94
|
+
panel_url=panel_url or None, panel_token=panel_token)
|
|
95
|
+
# every bus message; the link sends HA only the types it asked for
|
|
96
|
+
self.bus.on("message", self._from_bus)
|
|
97
|
+
self.link.start()
|
|
98
|
+
|
|
99
|
+
def _from_bus(self, raw) -> None:
|
|
100
|
+
try:
|
|
101
|
+
message = json.loads(raw) if isinstance(raw, str) else raw
|
|
102
|
+
except ValueError:
|
|
103
|
+
return
|
|
104
|
+
if isinstance(message, dict) and message.get("type"):
|
|
105
|
+
self.link.send(message)
|
|
106
|
+
|
|
107
|
+
def _from_ha(self, message: dict) -> None:
|
|
108
|
+
"""What Home Assistant asks of the device, put on its bus as it is: no
|
|
109
|
+
session, so OVOS treats it as the device's own."""
|
|
110
|
+
if message.get("type"):
|
|
111
|
+
self.bus.emit(Message(message["type"], message.get("data") or {},
|
|
112
|
+
message.get("context") or {}))
|
|
113
|
+
|
|
114
|
+
def shutdown(self):
|
|
115
|
+
if self.link is not None:
|
|
116
|
+
self.bus.remove("message", self._from_bus)
|
|
117
|
+
self.link.stop()
|
|
118
|
+
super().shutdown()
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
"""The connection to Home Assistant: its WebSocket API, with the OpenVoiceOS
|
|
2
|
+
integration's ovos/* commands (andlo/ha-ovos-integration, docs/protocol.md).
|
|
3
|
+
|
|
4
|
+
Runs its own asyncio loop in a thread; the plugin hands it bus messages with
|
|
5
|
+
send() (thread-safe) and gets HA's with on_bus. Connects again by itself
|
|
6
|
+
when HA restarts or the network drops.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import asyncio
|
|
11
|
+
from collections.abc import Callable
|
|
12
|
+
import itertools
|
|
13
|
+
import json
|
|
14
|
+
import threading
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
import aiohttp
|
|
18
|
+
from ovos_utils.log import LOG
|
|
19
|
+
|
|
20
|
+
PROTOCOL = 1
|
|
21
|
+
RETRY_SECONDS = 10
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class HALink:
|
|
25
|
+
def __init__(self, url: str, token: str, device: dict[str, Any],
|
|
26
|
+
on_bus: Callable[[dict], None],
|
|
27
|
+
on_event: Callable[[dict], None] | None = None,
|
|
28
|
+
panel_url: str | None = None, panel_token: str | None = None) -> None:
|
|
29
|
+
self.url = url.rstrip("/").replace("http", "ws", 1) + "/api/websocket"
|
|
30
|
+
self.token = token
|
|
31
|
+
self.device = device # what ovos/connect says about the device
|
|
32
|
+
self.on_bus = on_bus # a bus message from HA, for the device
|
|
33
|
+
self.on_event = on_event or (lambda e: None)
|
|
34
|
+
self.forward: set[str] = set() # the types HA wants (ready event)
|
|
35
|
+
self.ready = False
|
|
36
|
+
self._ws: aiohttp.ClientWebSocketResponse | None = None
|
|
37
|
+
self._ids = itertools.count(1)
|
|
38
|
+
self._connect_id: int | None = None
|
|
39
|
+
self._loop = asyncio.new_event_loop()
|
|
40
|
+
self._thread = threading.Thread(target=self._run, name="ha-link", daemon=True)
|
|
41
|
+
self._stopping = False
|
|
42
|
+
# the device's ovos-control-panel, which HA reaches through this link
|
|
43
|
+
self.panel_url = panel_url.rstrip("/") if panel_url else None
|
|
44
|
+
self.panel_token = panel_token
|
|
45
|
+
self._session: aiohttp.ClientSession | None = None
|
|
46
|
+
|
|
47
|
+
# --- the plugin's side ------------------------------------------------
|
|
48
|
+
|
|
49
|
+
def start(self) -> None:
|
|
50
|
+
self._thread.start()
|
|
51
|
+
|
|
52
|
+
def stop(self) -> None:
|
|
53
|
+
self._stopping = True
|
|
54
|
+
if self._ws is not None:
|
|
55
|
+
asyncio.run_coroutine_threadsafe(self._ws.close(), self._loop)
|
|
56
|
+
self._loop.call_soon_threadsafe(self._loop.stop)
|
|
57
|
+
|
|
58
|
+
def send(self, message: dict[str, Any]) -> None:
|
|
59
|
+
"""A bus message for HA, if HA asked for this type (thread-safe)."""
|
|
60
|
+
if self.ready and message.get("type") in self.forward:
|
|
61
|
+
self._loop.call_soon_threadsafe(self._send_bus, message)
|
|
62
|
+
|
|
63
|
+
def command(self, msg: dict[str, Any]) -> None:
|
|
64
|
+
"""Any other command for HA (thread-safe), e.g. the control panel's answers."""
|
|
65
|
+
self._loop.call_soon_threadsafe(self._send, msg)
|
|
66
|
+
|
|
67
|
+
# --- the loop ---------------------------------------------------------
|
|
68
|
+
|
|
69
|
+
def _run(self) -> None:
|
|
70
|
+
asyncio.set_event_loop(self._loop)
|
|
71
|
+
self._loop.create_task(self._keep_connected())
|
|
72
|
+
self._loop.run_forever()
|
|
73
|
+
|
|
74
|
+
async def _keep_connected(self) -> None:
|
|
75
|
+
while not self._stopping:
|
|
76
|
+
try:
|
|
77
|
+
await self._connect_once()
|
|
78
|
+
if not self._stopping:
|
|
79
|
+
LOG.warning("ha-link: Home Assistant closed the connection")
|
|
80
|
+
except (aiohttp.ClientError, OSError) as e:
|
|
81
|
+
LOG.warning(f"ha-link: can't reach Home Assistant: {e}")
|
|
82
|
+
except PermissionError as e:
|
|
83
|
+
LOG.error(f"ha-link: {e}")
|
|
84
|
+
self.ready = False
|
|
85
|
+
await asyncio.sleep(RETRY_SECONDS)
|
|
86
|
+
|
|
87
|
+
async def _connect_once(self) -> None:
|
|
88
|
+
async with aiohttp.ClientSession() as session, \
|
|
89
|
+
session.ws_connect(self.url, heartbeat=30) as ws:
|
|
90
|
+
self._ws, self._session = ws, session
|
|
91
|
+
device = dict(self.device)
|
|
92
|
+
if await self._panel_answers():
|
|
93
|
+
device["panel"] = True
|
|
94
|
+
hello = await ws.receive_json()
|
|
95
|
+
if hello.get("type") != "auth_required":
|
|
96
|
+
raise aiohttp.ClientError(f"not Home Assistant: {hello}")
|
|
97
|
+
await ws.send_json({"type": "auth", "access_token": self.token})
|
|
98
|
+
auth = await ws.receive_json()
|
|
99
|
+
if auth.get("type") != "auth_ok":
|
|
100
|
+
raise PermissionError(f"Home Assistant refused the token: {auth.get('message')}")
|
|
101
|
+
LOG.info(f"ha-link: logged in to Home Assistant {auth.get('ha_version')}")
|
|
102
|
+
self._connect_id = next(self._ids)
|
|
103
|
+
await ws.send_json({"id": self._connect_id, "type": "ovos/connect",
|
|
104
|
+
"protocol": PROTOCOL, **device})
|
|
105
|
+
async for raw in ws:
|
|
106
|
+
if raw.type != aiohttp.WSMsgType.TEXT:
|
|
107
|
+
continue
|
|
108
|
+
msg = json.loads(raw.data)
|
|
109
|
+
if msg.get("id") != self._connect_id:
|
|
110
|
+
if msg.get("type") == "result" and not msg.get("success"):
|
|
111
|
+
LOG.debug(f"ha-link: HA refused a command: {msg.get('error')}")
|
|
112
|
+
continue
|
|
113
|
+
if msg.get("type") == "result" and not msg.get("success"):
|
|
114
|
+
raise PermissionError(f"Home Assistant refused the device: {msg.get('error')}")
|
|
115
|
+
if msg.get("type") == "event":
|
|
116
|
+
self._on_connect_event(msg["event"])
|
|
117
|
+
self._ws = None
|
|
118
|
+
|
|
119
|
+
def _on_connect_event(self, event: dict[str, Any]) -> None:
|
|
120
|
+
match event.get("type"):
|
|
121
|
+
case "pending":
|
|
122
|
+
self.ready = False
|
|
123
|
+
LOG.info("ha-link: waiting to be added in Home Assistant "
|
|
124
|
+
"(Settings -> Devices & services -> Discovered)")
|
|
125
|
+
case "ready":
|
|
126
|
+
self.forward = set(event.get("forward", []))
|
|
127
|
+
self.ready = True
|
|
128
|
+
LOG.info(f"ha-link: ready, {len(self.forward)} message types go to Home Assistant")
|
|
129
|
+
case "bus":
|
|
130
|
+
self.on_bus(event.get("message") or {})
|
|
131
|
+
case "panel":
|
|
132
|
+
self._loop.create_task(self._panel(event))
|
|
133
|
+
case "displaced" | "removed":
|
|
134
|
+
self.ready = False
|
|
135
|
+
LOG.warning(f"ha-link: device {event['type']} in Home Assistant")
|
|
136
|
+
self.on_event(event)
|
|
137
|
+
|
|
138
|
+
# --- the control panel (ha-ovos-integration#15) ----------------------------
|
|
139
|
+
|
|
140
|
+
async def _panel_answers(self) -> bool:
|
|
141
|
+
"""Is there a control panel on this device to offer HA?"""
|
|
142
|
+
if not self.panel_url:
|
|
143
|
+
return False
|
|
144
|
+
try:
|
|
145
|
+
async with self._session.get(f"{self.panel_url}/healthz",
|
|
146
|
+
timeout=aiohttp.ClientTimeout(total=5)) as r:
|
|
147
|
+
return r.status == 200
|
|
148
|
+
except (aiohttp.ClientError, OSError, TimeoutError):
|
|
149
|
+
LOG.info(f"ha-link: no control panel at {self.panel_url}")
|
|
150
|
+
return False
|
|
151
|
+
|
|
152
|
+
async def _panel(self, event: dict[str, Any]) -> None:
|
|
153
|
+
"""One request from HA to the panel's API, made here on the device."""
|
|
154
|
+
method = str(event.get("method", "GET")).upper()
|
|
155
|
+
path = str(event.get("path", ""))
|
|
156
|
+
status, body = 400, {"detail": "bad request"}
|
|
157
|
+
if method in ("GET", "POST", "PUT", "DELETE") and path.startswith("/") \
|
|
158
|
+
and ".." not in path and "://" not in path:
|
|
159
|
+
headers = {"Authorization": f"Bearer {self.panel_token}"} if self.panel_token else {}
|
|
160
|
+
try:
|
|
161
|
+
async with self._session.request(
|
|
162
|
+
method, f"{self.panel_url}/api{path}", headers=headers,
|
|
163
|
+
json=event.get("body") if method != "GET" else None,
|
|
164
|
+
timeout=aiohttp.ClientTimeout(total=25)) as r:
|
|
165
|
+
status = r.status
|
|
166
|
+
try:
|
|
167
|
+
body = await r.json(content_type=None)
|
|
168
|
+
except ValueError:
|
|
169
|
+
body = {"detail": (await r.text())[:500]}
|
|
170
|
+
except (aiohttp.ClientError, OSError, TimeoutError) as e:
|
|
171
|
+
status, body = 502, {"detail": f"the control panel did not answer: {e}"}
|
|
172
|
+
self._send({"type": "ovos/panel/response", "device_id": self.device["device_id"],
|
|
173
|
+
"request_id": event.get("id"), "status": status, "body": body})
|
|
174
|
+
|
|
175
|
+
def _send(self, msg: dict[str, Any]) -> None:
|
|
176
|
+
if self._ws is not None and not self._ws.closed:
|
|
177
|
+
self._loop.create_task(self._ws.send_json({"id": next(self._ids), **msg}))
|
|
178
|
+
|
|
179
|
+
def _send_bus(self, message: dict[str, Any]) -> None:
|
|
180
|
+
self._send({"type": "ovos/bus", "device_id": self.device["device_id"],
|
|
181
|
+
"message": {"type": message["type"],
|
|
182
|
+
"data": message.get("data") or {},
|
|
183
|
+
"context": message.get("context") or {}}})
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ovos-phal-plugin-ha-link
|
|
3
|
+
Version: 0.1.0a1
|
|
4
|
+
Summary: OpenVoiceOS PHAL plugin: links the device to Home Assistant - it connects itself and carries its bus to the OpenVoiceOS integration
|
|
5
|
+
Author: Andreas Lorensen
|
|
6
|
+
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/andlo/ovos-phal-plugin-ha-link
|
|
8
|
+
Project-URL: Issues, https://github.com/andlo/ovos-phal-plugin-ha-link/issues
|
|
9
|
+
Project-URL: Home Assistant integration, https://github.com/andlo/ha-ovos-integration
|
|
10
|
+
Keywords: ovos,openvoiceos,plugin,phal,home-assistant,homeassistant,assist
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Requires-Python: >=3.10
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
License-File: LICENSE
|
|
17
|
+
Requires-Dist: ovos-plugin-manager>=0.0.26
|
|
18
|
+
Requires-Dist: ovos-utils>=0.0.38
|
|
19
|
+
Requires-Dist: ovos-bus-client>=0.0.8
|
|
20
|
+
Requires-Dist: aiohttp>=3.9
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# ovos-phal-plugin-ha-link
|
|
24
|
+
|
|
25
|
+
An [OpenVoiceOS](https://openvoiceos.org) PHAL plugin that links the device to
|
|
26
|
+
[Home Assistant](https://www.home-assistant.io).
|
|
27
|
+
|
|
28
|
+
The device connects to Home Assistant itself and carries its message bus both
|
|
29
|
+
ways to the [OpenVoiceOS integration](https://github.com/andlo/ha-ovos-integration).
|
|
30
|
+
In Home Assistant it shows up as a device, with what the bus can see and set:
|
|
31
|
+
|
|
32
|
+
- volume, mute and listening on/off: automations can turn listening off at night
|
|
33
|
+
- its state (idle, listening, thinking, speaking), the last question and the last answer
|
|
34
|
+
- **Say** (`notify.send_message`) and **Ask** (`ovos.ask`)
|
|
35
|
+
- the device's own sensors, when a plugin reports them (`ovos.phal.sensor`)
|
|
36
|
+
|
|
37
|
+
No port is opened on the device and nothing has to reach it from outside, so it
|
|
38
|
+
also works behind NAT. Any OVOS install can use it: ovos-installer, raspOVOS,
|
|
39
|
+
a Mark II, an OVOS in a VM.
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
pip install --pre ovos-phal-plugin-ha-link
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
In Home Assistant, install the [OpenVoiceOS integration](https://github.com/andlo/ha-ovos-integration)
|
|
48
|
+
(0.3.0 or newer), add it, and choose **An OpenVoiceOS device**. That lets
|
|
49
|
+
devices connect. Then make a long-lived access token: your profile → Security.
|
|
50
|
+
|
|
51
|
+
## Configure
|
|
52
|
+
|
|
53
|
+
In `mycroft.conf`:
|
|
54
|
+
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"PHAL": {
|
|
58
|
+
"ovos-phal-plugin-ha-link": {
|
|
59
|
+
"url": "http://homeassistant.local:8123",
|
|
60
|
+
"token": "<the long-lived access token>",
|
|
61
|
+
"name": "Kitchen"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
| Setting | |
|
|
68
|
+
|---|---|
|
|
69
|
+
| `url` | Home Assistant's address |
|
|
70
|
+
| `token` | a long-lived access token |
|
|
71
|
+
| `name` | the device's name in Home Assistant (default: the host name) |
|
|
72
|
+
| `model` | shown on the device page (default: `OpenVoiceOS`) |
|
|
73
|
+
| `panel_url` | the device's [ovos-control-panel](https://github.com/OpenVoiceOS/ovos-control-panel), reached here on the device (default `http://127.0.0.1:8500`; `false` for none) |
|
|
74
|
+
| `panel_token` | its access token (default: `webui.access_token` from `mycroft.conf`) |
|
|
75
|
+
| `panel_public_url` | where a browser can open the panel, for "Open control panel" in Home Assistant (optional) |
|
|
76
|
+
|
|
77
|
+
Restart OVOS' PHAL service. The device then appears in Home Assistant under
|
|
78
|
+
**Settings → Devices & services → Discovered**. Add it there, once. The plugin
|
|
79
|
+
keeps the device's id in `~/.local/state/ovos-phal-plugin-ha-link/device_id`,
|
|
80
|
+
so it stays the same device.
|
|
81
|
+
|
|
82
|
+
## How it works
|
|
83
|
+
|
|
84
|
+
It uses the integration's protocol ([docs/protocol.md](https://github.com/andlo/ha-ovos-integration/blob/master/docs/protocol.md)):
|
|
85
|
+
`ovos/connect` over Home Assistant's WebSocket API, then bus messages both
|
|
86
|
+
ways. What Home Assistant sends goes on the bus as it is. Of the device's own
|
|
87
|
+
messages, only the types Home Assistant asks for (the `forward` list) are
|
|
88
|
+
sent. It connects again by itself when Home Assistant restarts.
|
|
89
|
+
|
|
90
|
+
## The control panel
|
|
91
|
+
|
|
92
|
+
When [ovos-control-panel](https://github.com/OpenVoiceOS/ovos-control-panel)
|
|
93
|
+
runs on the device, Home Assistant also gets what it can set: language, units,
|
|
94
|
+
voice, speech to text, wake word, skills on and off, updates, restart and
|
|
95
|
+
reboot ([ha-ovos-integration#15](https://github.com/andlo/ha-ovos-integration/issues/15)).
|
|
96
|
+
Home Assistant's requests come through this link, and the plugin calls the
|
|
97
|
+
panel here on the device, so the panel never has to be opened on the network.
|
|
98
|
+
Restart and reboot need the panel's access token (`webui.access_token`).
|
|
99
|
+
|
|
100
|
+
## Coming
|
|
101
|
+
|
|
102
|
+
- What the device sends out on the network ([#16](https://github.com/andlo/ha-ovos-integration/issues/16)).
|
|
103
|
+
- The device as an Assist satellite ([#13](https://github.com/andlo/ha-ovos-integration/issues/13)).
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
|
|
107
|
+
Apache-2.0
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
ovos_phal_plugin_ha_link/__init__.py
|
|
5
|
+
ovos_phal_plugin_ha_link/link.py
|
|
6
|
+
ovos_phal_plugin_ha_link.egg-info/PKG-INFO
|
|
7
|
+
ovos_phal_plugin_ha_link.egg-info/SOURCES.txt
|
|
8
|
+
ovos_phal_plugin_ha_link.egg-info/dependency_links.txt
|
|
9
|
+
ovos_phal_plugin_ha_link.egg-info/entry_points.txt
|
|
10
|
+
ovos_phal_plugin_ha_link.egg-info/requires.txt
|
|
11
|
+
ovos_phal_plugin_ha_link.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ovos_phal_plugin_ha_link
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=64"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "ovos-phal-plugin-ha-link"
|
|
7
|
+
version = "0.1.0a1"
|
|
8
|
+
description = "OpenVoiceOS PHAL plugin: links the device to Home Assistant - it connects itself and carries its bus to the OpenVoiceOS integration"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "Apache-2.0"}
|
|
11
|
+
authors = [{name = "Andreas Lorensen"}]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
keywords = ["ovos", "openvoiceos", "plugin", "phal", "home-assistant", "homeassistant", "assist"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"License :: OSI Approved :: Apache Software License",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"ovos-plugin-manager>=0.0.26",
|
|
21
|
+
"ovos-utils>=0.0.38",
|
|
22
|
+
"ovos-bus-client>=0.0.8",
|
|
23
|
+
"aiohttp>=3.9",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://github.com/andlo/ovos-phal-plugin-ha-link"
|
|
28
|
+
Issues = "https://github.com/andlo/ovos-phal-plugin-ha-link/issues"
|
|
29
|
+
"Home Assistant integration" = "https://github.com/andlo/ha-ovos-integration"
|
|
30
|
+
|
|
31
|
+
[project.entry-points."opm.phal"]
|
|
32
|
+
ovos-phal-plugin-ha-link = "ovos_phal_plugin_ha_link:HALinkPlugin"
|
|
33
|
+
|
|
34
|
+
[tool.setuptools]
|
|
35
|
+
packages = ["ovos_phal_plugin_ha_link"]
|