https://github.com/josermorales/pyosmanager
Python client for Open Surplus Manager API
https://github.com/josermorales/pyosmanager
api-client iot pypi python
Last synced: 5 months ago
JSON representation
Python client for Open Surplus Manager API
- Host: GitHub
- URL: https://github.com/josermorales/pyosmanager
- Owner: JoseRMorales
- License: mit
- Created: 2024-06-23T17:23:42.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-20T18:12:35.000Z (over 1 year ago)
- Last Synced: 2025-09-01T05:53:45.786Z (10 months ago)
- Topics: api-client, iot, pypi, python
- Language: Python
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# pyOSManager
> Python client for Open Surplus Manager
This repo is about the Python client, for info about Open Surplus Manager see the project [repository](https://github.com/JoseRMorales/OpenSurplusManager)
## Installation
```bash
pip install pyosmanager
```
## Usage
```python
import asyncio
from pyosmanager import OSMClient
from pyosmanager.responses import DeviceResponse
async def main():
async with OSMClient("http://localhost:8080") as client:
res = await client.get_devices()
d: DeviceResponse
for d in res:
print(d.name)
if __name__ == "__main__":
asyncio.run(main())
```
## Methods
- `is_healthy() -> bool`
True if the server is healthy
- `get_core_state() -> dict`
Retrieve the core state
- `get_devices() -> list[DeviceResponse]`
Retrieve a list of devices
- `get_device(device_name: str) -> DeviceResponse`
Retrieve a device data dictionary by name
- `get_device_consumption(device_name: str) -> float`
Retrieve the device consumption by name
- `get_surplus() -> float:`
Retrieve the surplus value
- `set_surplus_margin(margin: float) -> float:`
Set the surplus margin
- `set_grid_margin(margin: float) -> float:`
Set the grid margin
- `set_idle_power(idle_power: float) -> float:`
Set the idle power
- `set_device_max_consumption(device_name: str, max_consumption: float) -> float:`
Set the max consumption for a device
- `set_device_expected_consumption(device_name: str, expected_consumption: float) -> float:`
Set the expected consumption for a device
- `set_device_cooldown(device_name: str, cooldown: int) -> int:`
Set the cooldown for a device