# SHinterface - Smart Home Control Interface

A Qt6-based smart home control application that interfaces with microcontrollers and sensors to manage home automation devices.

## Quick Start

### Building
```bash
mkdir build
cd build
cmake ..
make
```

### Running

**Primary (Master) Mode:**
```bash
./SHinterface -m
```

**Secondary (Client) Mode:**
```bash
./SHinterface -H 192.168.1.100 -p 38940
```

**Headless Server Mode:**
```bash
./SHinterface -m -e
```

## Features

- ✅ Control relays and PWM outputs
- ✅ Monitor various sensors (temperature, humidity, doors, etc.)
- ✅ MQTT sensor integration
- ✅ Actor-based automation system
- ✅ RGB lighting control
- ✅ WebSocket API for remote access
- ✅ Primary/secondary architecture for distributed control

## Configuration

Settings are stored in JSON format. Default location:
```
~/.config/shinterface.json
```

You can specify a custom config file with:
```bash
./SHinterface -c /path/to/config.json
```

## Usage

### Primary Mode (Master)
The primary instance connects to your microcontroller and manages all devices. It can run with or without a GUI.

### Secondary Mode (Client)
Secondary instances connect to the primary via TCP and provide additional control points without needing their own microcontroller connection.

## Command Line Options

```
-m, --master          Use in master mode
-H, --host <address>  Set server host IP address (default: 0.0.0.0)
-p, --port <port>     Set server port (default: 38940)
-c, --config <file>   Set config file path
-e, --headless        Don't start the GUI (master mode only)
--help                Show help
--version             Show version
```

## Architecture

- **Items**: Represent controllable devices (relays, lights, etc.)
- **Actors**: Automate actions based on sensors or time
- **Sensors**: Provide data from physical sensors and calculated sources
- **Services**: TCP and WebSocket interfaces for remote control

## Dependencies

- CMake 4.0+
- Qt6 (Core, Gui, Widgets, Network, Multimedia, SerialPort, Mqtt, WebSockets)
- libpipewire-0.3
- libnl-3.0

## License

See LICENSE file for details.
