Metadata-Version: 2.4
Name: ovos-phal-plugin-browser
Version: 0.1.0a1
Summary: OpenVoiceOS PHAL plugin: the browser tab as the device (volume, location, power, sensors, camera)
Author: Andreas Lorensen
License: Apache-2.0
Project-URL: Homepage, https://github.com/emkay-voice/ovos-phal-plugin-browser
Project-URL: Issues, https://github.com/emkay-voice/ovos-phal-plugin-browser/issues
Project-URL: Emkay, https://github.com/emkay-voice/emkay
Keywords: ovos,openvoiceos,plugin,phal,browser,volume,geolocation,pyodide,emkay
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Environment :: WebAssembly :: Emscripten
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: ovos-plugin-manager>=0.0.26
Requires-Dist: ovos-utils>=0.0.38
Requires-Dist: ovos-bus-client>=0.0.8
Requires-Dist: ovos-config>=0.0.12
Requires-Dist: json-database>=0.7.0
Dynamic: license-file

# ovos-phal-plugin-browser

An [OpenVoiceOS](https://openvoiceos.org) PHAL plugin whose hardware is a
**browser tab**: volume, location, power, connectivity, sensors and the
camera, answered on the bus exactly as the device plugins answer them, with
the actual work done by the web page OVOS runs in.

It was made for [Emkay](https://github.com/emkay-voice/emkay), OpenVoiceOS in
the browser (Pyodide), and is what Emkay uses. Any host that runs OVOS in a
page can use it the same way.

## What it answers

| Bus messages | Behaves like | The page does |
|---|---|---|
| `mycroft.volume.get/set/increase/decrease/mute/unmute/mute.toggle` | ovos-PHAL-plugin-alsa: `percent` 0..1, `{percent, muted}` answers and change reports, level kept in the plugin's settings | sets the gain of the one audio node everything plays through |
| `ovos.ipgeo.update` | ovos-phal-plugin-ipgeo: fills the *assistant* config layer (below the user layer, so a location the user set always wins) | asks the browser's geolocation (the user is asked first); OVOS' `get_reverse_geolocation` turns it into city, country and time zone. Until then, the browser's time zone |
| `system.reboot`, `system.shutdown`, `system.mycroft.service.restart`, `system.factory.reset`, `system.configure.language`, `system.ssh.*` | ovos-PHAL-plugin-system | reloads the page, blanks the screen until tapped, wipes the saved data; ssh is reported as not available |
| `ovos.PHAL.internet_check` | ovos-PHAL-plugin-connectivity-events | reports `navigator.onLine` and its changes |
| `ovos.phal.camera.ping/open/close/get` | ovos-PHAL-plugin-camera: `b64_frame` JPEG answers | opens the browser camera (the user is asked first) and takes a picture |
| `ovos.phal.sensor`, `ovos.phal.binary_sensor` (emitted) | ovos-PHAL-sensors | sends what the browser knows: battery, network, screen on and orientation, moving or still, how the phone lies, compass, storage, memory and CPU cores |

## How a host uses it

The plugin talks to the page through one callable, given when it is made:

```python
from ovos_phal_plugin_browser import BrowserPHAL

plugin = BrowserPHAL(bus=bus, config=config, post=send_to_page)
```

`post(change: dict)` gets what the page should do: `{"volume": 0.6, "muted":
false}`, or `{"request": "location" | "camera_check" | "camera_open" |
"camera_close" | "picture" | "reload" | "off" | "forget_welcome"}`. The page
answers through the plugin's methods: `on_position(lat, lon, error)`,
`on_picture(id, jpeg_b64, error)` and `on_page_event(event, data)` for
`"online"`, `"sensor"`, `"camera"` and `"picture"`.

Emkay's page side is [`web/device.js`](https://github.com/emkay-voice/emkay/blob/main/web/device.js),
and the wiring is in [`worker_main.py`](https://github.com/emkay-voice/emkay/blob/main/py/emkay_mobile/worker_main.py).

On an ordinary device, with real hardware, use the device plugins instead.

## Config

`PHAL.ovos-phal-plugin-browser` in `mycroft.conf`; nothing needs setting. The
volume is kept in `~/.config/OpenVoiceOS/ovos-phal-plugin-browser.json`.

## License

Apache-2.0
