Metadata-Version: 2.4
Name: grootfarm
Version: 0.1.0
Summary: Core Python library for the Grootfarm platform.
Author-email: Emerson Navarro <emnavarro02@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/grootfarm/grootfarm-lib
Project-URL: Repository, https://github.com/grootfarm/grootfarm-lib
Project-URL: Issues, https://github.com/grootfarm/grootfarm-lib/issues
Keywords: smartfarming,library,tutorial
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mysql-connector-python
Provides-Extra: dev
Requires-Dist: black; extra == "dev"
Requires-Dist: bumpver; extra == "dev"
Requires-Dist: isort; extra == "dev"
Requires-Dist: pip-tools; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Dynamic: license-file

# grootfarm-lib

Core Python library for the Grootfarm platform.

`grootfarm-lib` provides helper modules to work with brokers, sensors,
wellbeing rules, and database operations in Grootfarm services.

## Install

```bash
pip install grootfarm
```

## Quick Start

```python
import grootfarm
from grootfarm.broker import Broker

print(grootfarm.__version__)
```

## Main Components

### Sensor

```python
from grootfarm.sensor import Sensor

sensor = Sensor("temperature", "celsius", -60, 60)
sensor.set_type("temperature")
print(sensor.get_range())  # (-60, 60)
```

### Wellbeing Rules

```python
from grootfarm.sense import PlantFacts

facts = PlantFacts(
	"temperature",
	sensor_range=(-60, 60),
	plant_range=(20, 25),
	tolerance=5,
)

print(facts.get_wellbeing(24))
# {'status': 'good', 'comparison': 'good'}
```

### Message Processing

```python
from grootfarm.utils import Utils

raw = '{"timestamp":"2026-07-07T10:00:00Z","type":"temperature","value":23,"name":"sensor-a"}'
msg = Utils.process_message(raw)
print(msg)
```

### SQLite Configuration Database

```python
from grootfarm.db import SQLite3

db = SQLite3(":memory:")
db.connect()
db.add_metric("2026-07-07T10:00:00Z", "temperature", 23)
print(db.get_metric("temperature"))
db.close()
```

## Development

Run tests:

```bash
PYTHONPATH=src python -m pytest -q
```

## Modules

- `grootfarm.broker`
- `grootfarm.db`
- `grootfarm.sense`
- `grootfarm.sensor`
- `grootfarm.utils`
