Metadata-Version: 2.4
Name: pywinergy
Version: 0.1.0
Summary: Local control of Winergy / OUPES power stations over Wi-Fi and Bluetooth
License-Expression: MIT
Project-URL: Homepage, https://github.com/Navatusein/pywinergy
Project-URL: Issues, https://github.com/Navatusein/pywinergy/issues
Classifier: Framework :: AsyncIO
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Home Automation
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: ble
Requires-Dist: bleak>=0.21; extra == "ble"
Requires-Dist: bleak-retry-connector>=3.0; extra == "ble"
Provides-Extra: ui
Requires-Dist: textual; extra == "ui"
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Dynamic: license-file

# pywinergy

Local control of Winergy / OUPES portable power stations over Wi-Fi and
Bluetooth, from Python. No cloud connection is needed at runtime.

Used by the [Winergy Home Assistant integration](https://github.com/Navatusein/Winergy-HA-Integration).

> Status: early development. Tested on a Mega 2 (firmware 1.2.0).

## Install

```sh
pip install pywinergy            # Wi-Fi only, no dependencies
pip install "pywinergy[ble]"     # + Bluetooth (bleak)
pip install "pywinergy[ui]"      # + interactive terminal UI (textual)
```

## Command line

```sh
pywinergy discover                          # find stations on the LAN
pywinergy --host 192.168.1.50 status        # current readings
pywinergy --host 192.168.1.50 monitor       # print readings as they change
pywinergy --host 192.168.1.50 usb on        # switch outputs: ac / dc / usb
pywinergy --host 192.168.1.50 ui            # interactive screen

pywinergy ble-scan                          # find stations over Bluetooth
pywinergy cloud-key                         # fetch the Bluetooth device key from your account
pywinergy --ble AA:BB:CC:DD:EE:FF --ble-key KEY status
```

`--host` and `--ble-key` can also come from `WINERGY_HOST` and `WINERGY_BLE_KEY`.

## Library

```python
import asyncio
from pywinergy import WinergyStation

async def main():
    station = WinergyStation.tcp("192.168.1.50")
    await station.connect()
    state = await station.refresh()
    print(state.battery_percent, "%")
    await station.set_usb_output(True)
    await station.stop()

asyncio.run(main())
```

For long-running use, `station.start()` keeps reconnecting in the background
while the station is switched off, and `station.add_listener(callback)` is
called on every change. Network failures raise `StationUnavailable`.

Over Bluetooth use `WinergyStation.ble(device, device_key)`, where `device`
is a bleak `BLEDevice` (see `discover_ble()`).

## Development

```sh
pip install -e ".[dev,ble,ui]"
pytest
ruff check .
```

Release: bump `version` in `pyproject.toml` and publish a GitHub Release
tagged `vX.Y.Z`; the `release` workflow uploads it to PyPI.

## Disclaimer

Not affiliated with or endorsed by Winergy or OUPES.
