# Homebridge Solar Monitor Plugin - Setup Guide

## 🚀 **Publishing to NPM**

### **Step 1: Prepare for Publishing**

1. **Create GitHub Repository**:
   ```bash
   # Create new repo on GitHub
   # Clone to your machine
   git clone https://github.com/yourusername/homebridge-solar-monitor.git
   cd homebridge-solar-monitor
   ```

2. **Update package.json**:
   - Change `yourusername` to your actual GitHub username
   - Update repository URLs
   - Add your name as author

3. **Test the Plugin**:
   ```bash
   # Install dependencies
   npm install
   
   # Link for local testing
   npm link
   
   # Test in Homebridge
   ```

### **Step 2: Publish to NPM**

1. **Login to NPM**:
   ```bash
   npm login
   ```

2. **Publish**:
   ```bash
   npm publish
   ```

3. **Verify**:
   - Check: https://www.npmjs.com/package/homebridge-solar-monitor
   - Test installation: `npm install -g homebridge-solar-monitor`

### **Step 3: Install on Homebridge OS**

Once published, users can install via:

#### **Option A: Homebridge UI**
1. Open Homebridge UI: `http://192.168.0.192:8581`
2. Go to **Plugins** → **Search**
3. Search for `homebridge-solar-monitor`
4. Click **Install**

#### **Option B: Command Line**
```bash
# SSH to Homebridge OS
ssh pi@192.168.0.192

# Install plugin
npm install -g homebridge-solar-monitor

# Restart Homebridge
sudo systemctl restart homebridge
```

#### **Option C: Config UI X**
1. Open Config UI X: `http://192.168.0.192:8581`
2. Go to **Plugins** → **+ Install**
3. Search for `homebridge-solar-monitor`
4. Click **Install**

## ⚙️ **Configuration**

### **Via Homebridge UI**:
1. Go to **Accessories** → **Add Accessory**
2. Select **Solar Monitor**
3. Configure:
   - **Name**: Solar Monitor
   - **e-SenZ Username**: 314
   - **e-SenZ Password**: solgen314
   - **Update Interval**: 15
   - **Pushover User Key**: ubacf6yrzqi39wv5758ogeorksmyg2
   - **Pushover App Token**: apqypemqperophpagxtspat3tn7sfr
   - **Second User Key**: us5sg9aqb2i7iqbjmmocr7p2df1ymp

### **Via config.json**:
```json
{
  "accessories": [
    {
      "accessory": "SolarMonitor",
      "name": "Solar Monitor",
      "username": "314",
      "password": "solgen314",
      "updateInterval": 15,
      "pushoverUserKey": "ubacf6yrzqi39wv5758ogeorksmyg2",
      "pushoverAppToken": "apqypemqperophpagxtspat3tn7sfr",
      "secondUserKey": "us5sg9aqb2i7iqbjmmocr7p2df1ymp"
    }
  ]
}
```

## 🎯 **What Users Get**

### **HomeKit Accessories**:
1. **Solar Monitor (Lightbulb)**: Current power output
2. **Today Energy (Temperature)**: Today's production
3. **Yesterday Energy (Humidity)**: Yesterday's production
4. **Monthly Energy (Contact)**: Monthly production status

### **Pushover Notifications**:
- Real-time solar data every 15 minutes
- Multi-user support
- Rich formatting with emojis
- Time-based monitoring (6 AM - 6:30 PM IST)

## ✅ **Success Indicators**

- ✅ Plugin appears in Homebridge UI
- ✅ Accessories show up in HomeKit
- ✅ Real data updates every 15 minutes
- ✅ Pushover notifications received
- ✅ Both users get notifications

## 🔧 **Troubleshooting**

### **Common Issues**:
1. **Python dependencies**: Install via `pip3 install -r requirements.txt`
2. **Chrome/Chromium**: Install browser for scraping
3. **Pushover credentials**: Verify in plugin config
4. **e-SenZ access**: Check login credentials

### **Logs**:
```bash
# View Homebridge logs
sudo journalctl -u homebridge -f

# Or in Homebridge UI: Settings → Logs
```

---

**🎉 Once published, users can install with one click in Homebridge UI!** 