//parametros configurables*************************************************
#define DEBUG_PS 1//Descomentar para debug
#define CON_LCD 0
#define CON_WOL 0
    //va por 16
    class CocinapRUBDomoConfig: public DomoConfig
{
  public:
  CocinapRUBDomoConfig()
  {
    velocidadPortSerie=115200;
    strcpy(ssidWifi,"Idhun");//nombre wifi
    strcpy(keyWifi,"Ardileorca1234.");//key wifi
    strcpy(ideEsp,"Esp8266_P");//idenitificador del esp (sera único)
    strcpy(hostMQTT,"192.168.2.50");//servidor mqttBroker
    portMQTT=1883;//puerto del servidor mqtt Broker
    refresTimeVars=30;//tiempo de refresco en segundos de las variables
    refresTimeSens=15;//tiempo de refresco en segundos de los sensores
  }
  //configuracion de sensores---------------------------------
  virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd, MqttWOLManager* wol, MqttDesencadenadorManager *des)
  {
     sens->AddHDT22(D4, "casa/cocina");//01
     sens->AddDinRetardOff(D5, 60,"casa/p/mov");//2
     int mov=2;
     sens->AddAnalogIn(0, "casa/p/luz",true);//3
     int luz=3;
     sens->AddDin( D1, "casa/p/inter");//4
      int interr=4;
     sens->AddDout(D2, "casa/p/lam", false);//5
     int lam=5;
     int lauto= vars->AddVirtualOutVarInt( "casa/p/luzAuto");//variable privada
      char st[64];
    
    //Efecto Pulsadores
    sprintf(st,"{%d}>0 -> !{%d} ",interr,lam);//accion interruptor
    des->AddDes(st);
    sprintf(st,"{%d}<1 -> !{%d} ",interr,lam);//accion interruptor
    des->AddDes(st);
    
    sprintf(st,"{%d}<1&{%d}>0&{%d}=1 -> {%d}=0 ",mov,lauto,lam,lam);//apaga luz si no hay nadie
    des->AddDes(st);
     sprintf(st,"{%d}>20&{%d}>0&{%d}>0 -> {%d}=1 ",luz,mov,lauto,lam);//enciende luz si hay presencia y esta oscuro
    des->AddDes(st);
     
  }
};
class ActDomoConfig: public DomoConfig
{
  public:
  ActDomoConfig()
  {
    velocidadPortSerie=115200;
    strcpy(ssidWifi,"Idhun");//nombre wifi
    strcpy(keyWifi,"Ardileorca1234.");//key wifi
    
    strcpy(ideEsp,"Esp8266_pruebas");//idenitificador del esp (sera único)
    strcpy(hostMQTT,"192.168.2.50");//servidor mqttBroker
    portMQTT=1883;//puerto del servidor mqtt Broker

    refresTimeVars=30;//tiempo de refresco en segundos de las variables
    refresTimeSens=15;//tiempo de refresco en segundos de los sensores

    //config lcd--------------------
    lcd.colum=16;//columnas lcd
    lcd.lines=2;//lineas
    //pines lcd
    lcd.rs=D5;
    lcd.en=D6;//eneable
    lcd.d0=D3;
    lcd.d1=D2;
    lcd.d2=D1;
    lcd.d3=D0;

  }
  //configuracion de sensores, variables, lcd---------------------------------
  virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd, MqttWOLManager* wol, MqttDesencadenadorManager *des)
  {
    //sensores--------------------------------------------------------
    /*
    sens->AddHDT22(int pin, char* topic);
    //tempe y presion varometrica
    sens->AddBMP180(int sda,int scl, char* topic);
    //entradas digitales
    sens->AddDin(int pin, char* topic);//añade variable digital que se actualiza de manera instantanea (interruptores sensor presencia ..)
    sens->AddDinAccion(int pin, char* topic);//añade variable que solo publica en el cambio (pulsadores, ...)
    //salida digital
    sens->AddDout(int pin, char* topic, bool defautlValor);//variable que solo publica en el cambio (pulsadores, ...)
    Sensor analogico
    sens->AddAnalogIn(int pin, char* topic, bool ValNegado);//nivel de luz, nivel de lluvia ...

    sens->AddBuzz(int pin, char* topic);
    */
    
     sens->AddDinRetardOn(D1,5,"casa/p/pul");
     sens->AddDout(D5,"casa/p/led", true);
     //sens->AddHDT22(D4, "casa/desp");
    //sens->AddBuzz(D0, "casa/p/buz");
    //sens->AddMelodia("m200#100d200#0");
    //variables----------------------------------------------------
  /*
    int ivar= vars->AddVar(byte flags, char*topic);//variable con flags a elegir
  int ivar= vars->AddInternalVarFloat( char*topic);//variable privada
  int ivar= vars->AddInternalVarInt( char*topic);//variable privada
   * /
    int lamb= vars->AddInternalVarInt( "casa/Salon/LAmb");
    int lchim= vars->AddInternalVarInt( "casa/Salon/LChime");
    int lent= vars->AddInternalVarInt( "casa/Salon/LEnt");
    
    int pul1= vars->AddInternalVarInt( "casa/Salon/pul1");
    int pul2= vars->AddInternalVarInt( "casa/Salon/pul2");
    int pul3= vars->AddInternalVarInt( "casa/Salon/pul3");
    int pulIall= vars->AddInternalVarInt( "casa/Salon/intAll");
    int pulAll= vars->AddInternalVarInt( "casa/Salon/pulAll");
    //lcd---------------------------------------------------------
    
     //lcd->add(0,"T des: %s",0,0);
     //lcd->add(1,"H des: %s",1,0);
     //lcd->add(temCoci,"T coci: %s",0,1);
     //lcd->add(temDesp,"H coci: %s",1,1);
     
      /*
     //sin depender de variable
     lcd->add(-1,"Hola",0,0);
     lcd->add(-1,"como va",1,0);

     lcd->add(-1,"Mi ritmo",0,1);
     lcd->add(-1,"bueno pa goza",1,1);* /
     */
    //desencadenaores----------
    char st[64];
    //Efecto Interruptor-----
    sprintf(st,"{%d}<1 -> !{%d} ",0,1);//terminar en espacios y separar operadores (no puede estar 2 operadores juntos)
    des->AddDes(st);
    sprintf(st,"{%d}>0 -> !{%d} ",0,1);//terminar en espacios
    des->AddDes(st);
    /*
    sprintf(st,"{%d}>0 -> {%d}=1 & {%d}=1 & {%d}=1 ",pulIall,lamb,lchim, lent);//terminar en espacios
    des->AddDes(st);
    sprintf(st,"{%d}<1 -> {%d}=0 & {%d}=0 & {%d}=0 ",pulIall,lamb,lchim, lent);//terminar en espacios
    des->AddDes(st);
    //Efecto Pulsadores
    sprintf(st,"{%d}>0 -> !{%d} ",pulAll,pulIall);//terminar en espacios
    des->AddDes(st);
    sprintf(st,"{%d}>0 -> !{%d} ",pul1,lamb);//terminar en espacios
    des->AddDes(st);
     sprintf(st,"{%d}>0 -> !{%d} ",pul2,lchim);//terminar en espacios
    des->AddDes(st);
    sprintf(st,"{%d}>0 -> !{%d} ",pul3,lent);//terminar en espacios
    des->AddDes(st);
     /*  */
  }
};
class SalonHome: public DomoConfig
{
  public:
  SalonHome()
  {
    velocidadPortSerie=115200;
    strcpy(ssidWifi,"Idhun");//nombre wifi
    strcpy(keyWifi,"Ardileorca1234.");//key wifi
    
    strcpy(ideEsp,"Esp8266_SalomHome");//idenitificador del esp (sera único)
    strcpy(hostMQTT,"192.168.2.50");//servidor mqttBroker
    portMQTT=1883;//puerto del servidor mqtt Broker

    refresTimeVars=30;//tiempo de refresco en segundos de las variables
    refresTimeSens=15;//tiempo de refresco en segundos de los sensores

    //config lcd--------------------
    lcd.colum=16;//columnas lcd
    lcd.lines=2;//lineas
    //pines lcd
    lcd.rs=D5;
    lcd.en=D6;//eneable
    lcd.d0=D3;
    lcd.d1=D2;
    lcd.d2=D1;
    lcd.d3=D0;

  }
  //configuracion de sensores, variables, lcd---------------------------------
  virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd, MqttWOLManager* wol, MqttDesencadenadorManager *des)
  {
    //sensores--------------------------------------------------------
    /*
    sens->AddHDT22(int pin, char* topic);
    //tempe y presion varometrica
    sens->AddBMP180(int sda,int scl, char* topic);
    //entradas digitales
    sens->AddDin(int pin, char* topic);//añade variable digital que se actualiza de manera instantanea (interruptores sensor presencia ..)
    sens->AddDinAccion(int pin, char* topic);//añade variable que solo publica en el cambio (pulsadores, ...)
    //salida digital
    sens->AddDout(int pin, char* topic, bool defautlValor);//variable que solo publica en el cambio (pulsadores, ...)
    Sensor analogico
    sens->AddAnalogIn(int pin, char* topic, bool ValNegado);//nivel de luz, nivel de lluvia ...

    sens->AddBuzz(int pin, char* topic);
    */
    sens->AddDoutPulsador(D4, "casa/Salon/ordeTele", true, 1);
    sens->AddDoutPulsador(D2, "casa/Salon/router", true, 1);
    

    sens->AddDout(D3,"casa/Salon/auxiliar", true);
    int aux=2;
    sens->AddDout(D1,"casa/Salon/equipoMusica", true);
    int equipo=3;
     sens->AddDin( D5,"casa/Salon/pulEquipoM");
     int pequipo=4;
     sens->AddDin( D6, "casa/Salon/pulAux");
     int paux=5;
    //variables----------------------------------------------------
    
    //desencadenaores----------
    char st[64];
    //Efecto Interruptor-----
    
    sprintf(st,"{%d}>0 -> !{%d} ",pequipo,equipo);//terminar en espacios
    des->AddDes(st);
    sprintf(st,"{%d}>0 -> !{%d} ",paux,aux);//terminar en espacios
    des->AddDes(st);
    
  }
};
class PulSalonPruebConfig: public DomoConfig
{
  public:
  PulSalonPruebConfig()
  {
    velocidadPortSerie=115200;
    strcpy(ssidWifi,"Idhun");//nombre wifi
    strcpy(keyWifi,"Ardileorca1234.");//key wifi
    
    strcpy(ideEsp,"Esp8266_pulSalonPrueb");//idenitificador del esp (sera único)
    strcpy(hostMQTT,"192.168.2.50");//servidor mqttBroker
    portMQTT=1883;//puerto del servidor mqtt Broker

    refresTimeVars=30;//tiempo de refresco en segundos de las variables
    refresTimeSens=15;//tiempo de refresco en segundos de los sensores

    //config lcd--------------------
    lcd.colum=16;//columnas lcd
    lcd.lines=2;//lineas
    //pines lcd
    lcd.rs=0;
    lcd.en=0;//eneable
    lcd.d0=0;
    lcd.d1=0;
    lcd.d2=0;
    lcd.d3=0;

  }
  //configuracion de sensores, variables, lcd---------------------------------
  virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd, MqttWOLManager* wol, MqttDesencadenadorManager *des)
  {
    //sensores--------------------------------------------------------

     //sens->AddHDT22(D4, "casa/desp");
     // sens->AddDout(D1, "casa/p/LEnt", true);
     sens->AddDout(D7, "casa/p/LEnt", true);
     sens->AddDin( D1,"casa/p/pul1");
     sens->AddDin( D2, "casa/p/pul2");
     sens->AddDin( D3, "casa/p/pul3");
     sens->AddDin( D4,"casa/p/pulAll");
  }
};
class AutomatismosDomoConfig: public DomoConfig
{
  public:
  AutomatismosDomoConfig()
  {
    velocidadPortSerie=115200;
    strcpy(ssidWifi,"Idhun");//nombre wifi
    strcpy(keyWifi,"Ardileorca1234.");//key wifi
    
    strcpy(ideEsp,"Esp8266_autom");//idenitificador del esp (sera único)
    strcpy(hostMQTT,"192.168.2.50");//servidor mqttBroker
    portMQTT=1883;//puerto del servidor mqtt Broker

    refresTimeVars=30;//tiempo de refresco en segundos de las variables
    refresTimeSens=15;//tiempo de refresco en segundos de los sensores

    //config lcd--------------------
    lcd.colum=16;//columnas lcd
    lcd.lines=2;//lineas
    //pines lcd
    lcd.rs=D5;
    lcd.en=D6;//eneable
    lcd.d0=D3;
    lcd.d1=D2;
    lcd.d2=D1;
    lcd.d3=D0;

  }
  //configuracion de sensores, variables, lcd---------------------------------
  virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd, MqttWOLManager* wol, MqttDesencadenadorManager *des)
  {
    //sensores--------------------------------------------------------
    /*
    sens->AddHDT22(int pin, char* topic);
    //tempe y presion varometrica
    sens->AddBMP180(int sda,int scl, char* topic);
    //entradas digitales
    sens->AddDin(int pin, char* topic);//añade variable digital que se actualiza de manera instantanea (interruptores sensor presencia ..)
    sens->AddDinAccion(int pin, char* topic);//añade variable que solo publica en el cambio (pulsadores, ...)
    //salida digital
    sens->AddDout(int pin, char* topic, bool defautlValor);//variable que solo publica en el cambio (pulsadores, ...)
    Sensor analogico
    sens->AddAnalogIn(int pin, char* topic, bool ValNegado);//nivel de luz, nivel de lluvia ...
    */
     //sens->AddHDT22(D4, "casa/desp");
     //sens->AddAnalogIn(0, "casa/desp/luz",true);
    //variables----------------------------------------------------
  /*
    int ivar= vars->AddVar(byte flags, char*topic);//variable con flags a elegir
  int ivar= vars->AddInternalVarFloat( char*topic);//variable privada
  int ivar= vars->AddInternalVarInt( char*topic);//variable privada
   */
    int lamb= vars->AddInternalVarInt( "casa/Salon/LAmb");
    int lchim= vars->AddInternalVarInt( "casa/Salon/LChime");
    int lent= vars->AddInternalVarInt( "casa/Salon/LEnt");
    
    int pul1= vars->AddInternalVarInt( "casa/Salon/pul1");
    int pul2= vars->AddInternalVarInt( "casa/Salon/pul2");
    int pul3= vars->AddInternalVarInt( "casa/Salon/pul3");
    int pulIall= vars->AddInternalVarInt( "casa/Salon/intAll");
    int pulAll= vars->AddInternalVarInt( "casa/Salon/pulAll");
    //lcd---------------------------------------------------------
    
     //lcd->add(0,"T des: %s",0,0);
     //lcd->add(1,"H des: %s",1,0);
     //lcd->add(temCoci,"T coci: %s",0,1);
     //lcd->add(temDesp,"H coci: %s",1,1);
     
      /*
     //sin depender de variable
     lcd->add(-1,"Hola",0,0);
     lcd->add(-1,"como va",1,0);

     lcd->add(-1,"Mi ritmo",0,1);
     lcd->add(-1,"bueno pa goza",1,1);*/
    //desencadenaores----------
    char st[64];
    //Efecto Interruptor-----
    sprintf(st,"{%d}>0 -> {%d}=1 & {%d}=1 & {%d}=1 ",pulIall,lamb,lchim, lent);//terminar en espacios
    des->AddDes(st);
    sprintf(st,"{%d}<1 -> {%d}=0 & {%d}=0 & {%d}=0 ",pulIall,lamb,lchim, lent);//terminar en espacios
    des->AddDes(st);
    //Efecto Pulsadores
    sprintf(st,"{%d}>0 -> !{%d} ",pulAll,pulIall);//terminar en espacios
    des->AddDes(st);
    sprintf(st,"{%d}>0 -> !{%d} ",pul1,lamb);//terminar en espacios
    des->AddDes(st);
     sprintf(st,"{%d}>0 -> !{%d} ",pul2,lchim);//terminar en espacios
    des->AddDes(st);
    sprintf(st,"{%d}>0 -> !{%d} ",pul3,lent);//terminar en espacios
    des->AddDes(st);
     
  }
};

class PulSalonConfig: public DomoConfig
{
  public:
  PulSalonConfig()
  {
    //CON LCD Y WOL
    velocidadPortSerie=115200;
    strcpy(ssidWifi,"Idhun");//nombre wifi
    strcpy(keyWifi,"Ardileorca1234.");//key wifi
    
    strcpy(ideEsp,"Esp8266_pulSalon");//idenitificador del esp (sera único)
    strcpy(hostMQTT,"192.168.2.50");//servidor mqttBroker
    portMQTT=1883;//puerto del servidor mqtt Broker

    refresTimeVars=30;//tiempo de refresco en segundos de las variables
    refresTimeSens=15;//tiempo de refresco en segundos de los sensores

    //config lcd--------------------
    lcd.colum=16;//columnas lcd
    lcd.lines=2;//lineas
    //pines lcd
    lcd.rs=0;
    lcd.en=0;//eneable
    lcd.d0=0;
    lcd.d1=0;
    lcd.d2=0;
    lcd.d3=0;

  }
  //configuracion de sensores, variables, lcd---------------------------------
  virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd, MqttWOLManager* wol, MqttDesencadenadorManager *des)
  {
    //sensores--------------------------------------------------------
    /*
    sens->AddHDT22(int pin, char* topic);
    //tempe y presion varometrica
    sens->AddBMP180(int sda,int scl, char* topic);
    //entradas digitales
    sens->AddDin(int pin, char* topic);//añade variable digital que se actualiza de manera instantanea (interruptores sensor presencia ..)
    sens->AddDinAccion(int pin, char* topic);//añade variable que solo publica en el cambio (pulsadores, ...)
    //salida digital
    sens->AddDout(int pin, char* topic, bool defautlValor);//variable que solo publica en el cambio (pulsadores, ...)
    Sensor analogico
    sens->AddAnalogIn(int pin, char* topic, bool ValNegado);//nivel de luz, nivel de lluvia ...
    */
     //sens->AddHDT22(D4, "casa/desp");
     // sens->AddDout(D1, "casa/Salon/LEnt", true);
     sens->AddDout(D7, "casa/Salon/LEnt", true);
     sens->AddDinRetardOff( D1, 1,"casa/Salon/pul1");
     sens->AddDinRetardOff( D2, 1, "casa/Salon/pul2");
     sens->AddDinRetardOff( D5, 1, "casa/Salon/pul3");
     sens->AddDinRetardOff( D6, 1,"casa/Salon/pulAll");
  }
};
class DespachoDomoConfig: public DomoConfig
{
  public:
  DespachoDomoConfig()
  {
    velocidadPortSerie=115200;
    strcpy(ssidWifi,"Idhun");//nombre wifi
    strcpy(keyWifi,"Ardileorca1234.");//key wifi
    
    strcpy(ideEsp,"Esp8266_Despacho");//idenitificador del esp (sera único)
    strcpy(hostMQTT,"192.168.2.50");//servidor mqttBroker
    portMQTT=1883;//puerto del servidor mqtt Broker

    refresTimeVars=30;//tiempo de refresco en segundos de las variables
    refresTimeSens=15;//tiempo de refresco en segundos de los sensores

    //config lcd--------------------
    lcd.colum=16;//columnas lcd
    lcd.lines=2;//lineas
    //pines lcd
     lcd.rs=D5;
    lcd.en=D6;//eneable
    lcd.d0=D3;
    lcd.d1=D2;
    lcd.d2=D1;
    lcd.d3=D0;

  }
  //configuracion de sensores, variables, lcd---------------------------------
  virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd,MqttWOLManager* wol, MqttDesencadenadorManager *des)
  {
    //sensores--------------------------------------------------------
     sens->AddHDT22(D4, "casa/desp");
     sens->AddAnalogIn(0, "casa/desp/luz",true);
     sens->AddBuzz(D7, "casa/des/buz");
     
    sens->AddMelodia("m200#100d200#0");//titu
    sens->AddMelodia("d200#100d200#100d200#100f200#100l300#0");
    
    //variables----------------------------------------------------
    int temCoci= vars->AddInternalVarFloat( "casa/cocina/t");//variable privada
    int hcocina= vars->AddInternalVarFloat( "casa/cocina/h");//variable privada
    int temExt= vars->AddInternalVarFloat( "casa/ext/t");//variable privada
    int hExt= vars->AddInternalVarFloat( "casa/ext/h");//variable privada
    //lcd---------------------------------------------------------
     lcd->add(0,"T des: %s",0,0);
     lcd->add(1,"H des: %s",1,0);
     lcd->add(temCoci,"T coci: %s",0,1);
     lcd->add(hcocina,"H coci: %s",1,1);    
     lcd->add(temExt,"T Ext: %s",0,2);
     lcd->add(hExt,"H Ext: %s",1,2);   
     strcpy(lcd->topic,"casa/desp/msg");
     strcpy(wol->topic,"casa/wol");
  }
};
class CocinaDomoConfig: public DomoConfig
{
  public:
  CocinaDomoConfig()
  {
    velocidadPortSerie=115200;
    strcpy(ssidWifi,"Idhun");//nombre wifi
    strcpy(keyWifi,"Ardileorca1234.");//key wifi
    strcpy(ideEsp,"Esp8266_cocina");//idenitificador del esp (sera único)
    strcpy(hostMQTT,"192.168.2.50");//servidor mqttBroker
    portMQTT=1883;//puerto del servidor mqtt Broker
    refresTimeVars=30;//tiempo de refresco en segundos de las variables
    refresTimeSens=15;//tiempo de refresco en segundos de los sensores
  }
  //configuracion de sensores---------------------------------
  virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd, MqttWOLManager* wol, MqttDesencadenadorManager *des)
  {
     sens->AddHDT22(D4, "casa/cocina");//01
     sens->AddDinRetardOff(D5, 60,"casa/cocina/mov");//2
     int mov=2;
     sens->AddAnalogIn(0, "casa/cocina/luz",true);//3
     int luz=3;
     sens->AddDin( D1, "casa/cocina/inter");//4
     sens->AddDout(D2, "casa/cocina/lam", false);//5
     int lam=5;
     int lauto= vars->AddVirtualOutVarInt( "casa/cocina/luzAuto");
      char st[64];
    
    //Efecto Pulsadores
    
    sprintf(st,"{%d}>0 -> !{%d} ",4,lam);//accion interruptor
    des->AddDes(st);
    
    sprintf(st,"{%d}<1 -> !{%d} ",4,lam);//accion interruptor
    des->AddDes(st);
    
    sprintf(st,"{%d}<1&{%d}>0&{%d}=1 -> {%d}=0 ",mov,lauto,lam,lam);//apaga luz si no hay nadie
    des->AddDes(st);
     sprintf(st,"{%d}<20&{%d}>0&{%d}>0 -> {%d}=1 ",luz,mov,lauto,lam);//enciende luz si hay presencia y esta oscuro
    des->AddDes(st);
     
  }
};
class SalonDomoConfig: public DomoConfig
{
  public:
  SalonDomoConfig()
  {
    velocidadPortSerie=115200;
    strcpy(ssidWifi,"Idhun");//nombre wifi
    strcpy(keyWifi,"Ardileorca1234.");//key wifi
    strcpy(ideEsp,"Esp8266_salon");//idenitificador del esp (sera único)
    strcpy(hostMQTT,"192.168.2.50");//servidor mqttBroker
    portMQTT=1883;//puerto del servidor mqtt Broker
    refresTimeVars=30;//tiempo de refresco en segundos de las variables
    refresTimeSens=15;//tiempo de refresco en segundos de los sensores
  }
  //configuracion de sensores---------------------------------
  virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd, MqttWOLManager* wol, MqttDesencadenadorManager *des)
  {
     sens->AddHDT22(D4, "casa/Salon");//01
     sens->AddDinRetardOff(D5, 60,"casa/Salon/mov");//2
     sens->AddAnalogIn(0, "casa/Salon/luz",true);//3
     
      //variables----------------------------------------------------
    //variables para pulsadores---------------------------
    int lamb= vars->AddInternalVarInt( "casa/Salon/LAmb");
    int lchim= vars->AddInternalVarInt( "casa/Salon/LChime");
    int lent= vars->AddInternalVarInt( "casa/Salon/LEnt");
    
    int pul1= vars->AddInternalVarInt( "casa/Salon/pul1");
    int pul2= vars->AddInternalVarInt( "casa/Salon/pul2");
    int pul3= vars->AddInternalVarInt( "casa/Salon/pul3");
    int pulIall= vars->AddInternalVarInt( "casa/Salon/intAll");
    int pulAll= vars->AddInternalVarInt( "casa/Salon/pulAll");
/*
    int cociMov= vars->AddInternalVarInt( "casa/cocina/mov");
    int cociLuz= vars->AddInternalVarInt( "casa/cocina/luz");
    int cociLam= vars->AddInternalVarInt( "casa/cocina/lam");
    int cociAuto= vars->AddInternalVarInt("casa/cocina/luzAuto");
    */
    //variables para pulsadores cocina----------------------------
    
    //desencadenaores----------
    char st[64];
    //Efecto Interruptor-----
    sprintf(st,"{%d}>0 -> {%d}=1 & {%d}=1 & {%d}=0 ",pulIall,lamb,lchim, lent);//terminar en espacios
    des->AddDes(st);
    sprintf(st,"{%d}<1 -> {%d}=0 & {%d}=0 & {%d}=1 ",pulIall,lamb,lchim, lent);//terminar en espacios
    des->AddDes(st);
    //Efecto Pulsadores
    sprintf(st,"{%d}>0 -> !{%d} ",pulAll,pulIall);//terminar en espacios
    des->AddDes(st);
    sprintf(st,"{%d}>0 -> !{%d} ",pul1,lamb);//terminar en espacios
    des->AddDes(st);
     sprintf(st,"{%d}>0 -> !{%d} ",pul2,lchim);//terminar en espacios
    des->AddDes(st);
    sprintf(st,"{%d}>0 -> !{%d} ",pul3,lent);//terminar en espacios
    des->AddDes(st);
/*
    //variablaes cocina
    sprintf(st,"{%d}<1&{%d}>0&{%d}=1 -> {%d}=0 ",cociMov,cociAuto,cociLam,cociLam);//apaga luz si no hay nadie
    des->AddDes(st);
     sprintf(st,"{%d}<20&{%d}>0&{%d}>0 -> {%d}=1 ",cociLuz,cociMov,cociAuto,cociLam);//enciende luz si hay presencia y esta oscuro
    des->AddDes(st);
    */
    
  }
};
class ExteriorDomoConfig: public DomoConfig
{
  public:
  ExteriorDomoConfig()
  {
    velocidadPortSerie=115200;
    strcpy(ssidWifi,"Idhun");//nombre wifi
    strcpy(keyWifi,"Ardileorca1234.");//key wifi
    strcpy(ideEsp,"Esp8266_Ext");//idenitificador del esp (sera único)
    strcpy(hostMQTT,"192.168.2.50");//servidor mqttBroker
    portMQTT=1883;//puerto del servidor mqtt Broker
    refresTimeVars=30;//tiempo de refresco en segundos de las variables
    refresTimeSens=15;//tiempo de refresco en segundos de los sensores
  }
  //configuracion de sensores---------------------------------
  virtual void ConfigGen(MqttSensManager* sens, MqttVarManager* vars, LcdMQTTViewer *lcd, MqttWOLManager* wol, MqttDesencadenadorManager *des)
  {
     sens->AddHDT22(D2, "casa/ext");
     sens->AddAnalogIn(0, "casa/ext/lluvia",true);
  }
};




//configuracion que se usara--------------------------
SalonHome ConfiguracionActual;
