# 11. Integración con Homebridge

Para controlar tus dispositivos usando Siri y la API de HomeKit, necesitarás:

1. Instalar [Homebridge](https://github.com/homebridge/homebridge) en tu Windows, Linux, Mac, or Raspberry&#x20;
2. Instalar el Plugin [Homebridge Mqttthing](https://github.com/arachnetech/homebridge-mqttthing#readme)
3. Agregar la configuración del dispositivo como aparece abajo, dependiendo del tipo.
4. Abre tu aplicación Home en tu dispositivo iOS y vincula escaneando el código QR del el portal de administración de Homebridge.
5. Renombra tus dispositivos en la aplicación the Home.
6. Listo!

### Configuraciones de dispositivos:

1. **Switch or Light (No Tasmota)**

```javascript
{
    "type": "switch",
    "name": "31141235efb12D367",      //YOUR DEVICE ID
    "url": "smartnest.cz",
    "username": "USERNAME",
    "password": "PASSWORD or API KEY",
    "topics": {
        "getOnline": "31141235efb12D367/report/connected",    //CHANGE HERE TOO
        "getOn": "31141235efb12D367/report/powerState",
        "setOn": "31141235efb12D367/directive/powerState"
    },
    "onlineValue": "Online",
    "offlineValue": "Offline",
    "onValue": "ON",
    "offValue": "OFF",
    "accessory": "mqttthing"
}
```

2\. **Switch or Light (Tasmota)**

```javascript
 {
    "type": "switch",
    "name": "31141235efb12D367",     //YOUR DEVICE ID
    "url": "smartnest.cz",
    "username": "USERNAME",
    "password": "PASSWORD or API KEY",
    "topics": {
        "getOnline": "31141235efb12D367/tele/LWT",         //CHANGE HERE TOO
        "getOn": "31141235efb12D367/stat/POWER",
        "setOn": "31141235efb12D367/cmnd/POWER"
    },
    "onlineValue": "Online",
    "offlineValue": "Offline",
    "onValue": "ON",
    "offValue": "OFF",
    "accessory": "mqttthing"
}
```

3\. **Door or Lock**

```javascript
{
    "type": "lockMechanism",
    "name": "31141235efb12D367",         //YOUR DEVICE ID
    "url": "smartnest.cz",
    "username": "USERNAME",
    "password": "PASSWORD or API KEY",
    "topics": {
        "getOnline": "31141235efb12D367/report/online",        //CHANGE HERE TOO
        "getLockCurrentState": "31141235efb12D367/report/lockedState",
        "getLockTargetState": "31141235efb12D367/report/lockedState",
        "setLockTargetState": "31141235efb12D367/directive/lockedState"
    },
    "lockValues": [
        "false",
        "true",
        "Jammed",
        "Unknown"
    ],
    "accessory": "mqttthing"
}
```

4\. **Thermostat**

```javascript
{
    "accessory": "mqttthing",
    "type": "thermostat",
    "name": "31141235efb12D367",     //YOUR DEVICE ID
    "url": "smartnest.cz",
    "username": "USERNAME",
    "password": "PASSWORD or API KEY",
    "topics": {                                                //CHANGE HERE TOO
        "getCurrentHeatingCoolingState": "31141235efb12D367/report/mode",
        "setTargetHeatingCoolingState": "31141235efb12D367/directive/mode",
        "getTargetHeatingCoolingState": "31141235efb12D367/report/mode",
        "getCurrentTemperature": "31141235efb12D367/report/temperature",
        "setTargetTemperature": "31141235efb12D367/directive/setpoint",
        "getTargetTemperature": "31141235efb12D367/report/setpoint",
        "setTemperatureDisplayUnits": "31141235efb12D367/directive/scale",
        "getTemperatureDisplayUnits": "31141235efb12D367/directive/scale"
    },
    "heatingCoolingStateValues": [
        "Heat",
        "Cool",
        "Auto"
    ],
    "temperatureDisplayUnitsValues": [
        "C",
        "F"
    ],
    "minTemperature": 10,        //Change if you use Fahrenheit
    "maxTemperature": 30,        //Change if you use Fahrenheit
    "restrictHeatingCoolingState": [
        0,
        1
    ]
}
```

5\. **Temperature Sensor**

```javascript
{
    "accessory": "mqttthing",
    "type": "temperatureSensor",    
    "name": "31141235efb12D367",     //YOUR DEVICE ID
    "url": "smartnest.cz",
    "username": "USERNAME",
    "password": "PASSWORD or API KEY",
    "caption": "Temperature",
    "topics": {                                                //CHANGE HERE TOO
        "getCurrentTemperature": "31141235efb12D367/report/temperature"
    },
    "history": true,
    "minTemperature": 10,        //Change if you use Fahrenheit
    "maxTemperature": 30        //Change if you use Fahrenheit
}
```

**6. Fan**

```javascript
 {
    "accessory": "mqttthing",
    "type": "fan",
    "name": "31141235efb12D367",     //YOUR DEVICE ID
    "url": "smartnest.cz",
    "username": "USERNAME",
    "password": "PASSWORD or API KEY",
    "caption": "Fan",
    "topics": {                                    //CHANGE HERE TOO
        "getOn": "31141235efb12D367/report/powerState",
        "setOn": "31141235efb12D367/directive/powerState",
        "getRotationSpeed": "31141235efb12D367/report/percentage",
        "setRotationSpeed": "31141235efb12D367/directive/percentage"
    },
    "integerValue": false,
    "onValue": "ON",
    "offValue": "OFF",
    "turnOffAfterms": 3600000
}
```

## Si quieres agregar un dispositivo diferente puedes consultar la página de [Accesorios soportados en homebridge-mqttthing](https://github.com/arachnetech/homebridge-mqttthing#supported-accessories)
