# This is coldtobi's c onfiguation file for solarpowerlog.
# 3 Inverters, feed data to a CVS logger each for data storage and a CVS logger each to store data for the HTML Writer
# Of course, there is one HTML Writer for each Inverter.

# Please note, the file is parsed by libconfig.

application:
{
    # what debuglevel should be used if not specified by any component
    # Choose out of ALL, TRACE, DEBUG, INFO, WARN, ERROR ,FATAL and NONE
    # optional. If not given, it defaults to "ERROR"
    # Note, if specified a logconfig file, the config file can override this
    # setting.
    dbglevel = "FATAL";
};

inverter :
{
  inverters = (
    {
      name   = "Inverter_1";
      description = "A Inverter inverting";
      manufacturer =  "SPUTNIK_ENGINEERING";
      model ="S-Series";

      comms = "TCP/IP";
      tcpadr =  "10.243.48.201";
      tcpport = "12345";
      tcptimeout = 3000;

      commadr = 1;
      ownadr = 0xfb;

      queryinterval= 5;
    },
    {
      name   = "Inverter_2";
      description = "A Inverter inverting";
      manufacturer =  "SPUTNIK_ENGINEERING";
      model ="S-Series";

      comms =  "TCP/IP";
      tcpadr =  "10.243.48.202";
      tcpport = "12345";
      tcptimeout = 3000;

      commadr = 1;
      ownadr = 0xfb;

      queryinterval=5;
    },
    {
      name   = "Inverter_3";
      description = "A Inverter inverting";
      manufacturer =  "SPUTNIK_ENGINEERING";
      model ="S-Series";

      comms =  "TCP/IP";
      tcpadr =  "10.243.48.203";
      tcpport = "12345";
      tcptimeout = 3000;

      commadr = 1;
      ownadr = 0xfb;

      queryinterval=5;
    }
  );
};

logger:
{
    loggers = (
      {
        name = "CVS_Inverter_1";
        type = "CVSWriter";

        datasource = "Inverter_1";

        logfile = "/home/tobi/solar/Inverter1_%s.csv";
        rotate = true;

        data2log = [
          "AC grid feeding current (A)",
          "AC grid voltage (V)",
          "Current Grid Feeding Power",
          "DC current in (A)",
          "DC voltage in (V)",
          "Energy produced accumulated all time (kWh)",
          "Energy produced this month (kWh)",
          "Energy produced this year (kWh)",
          "Energy produced today (kWh)",
          "Inverter Overall Status",
          "Inverter Temperature (C)",
          "Net frequency (Hz)"
        ];
      },
      {
        name = "CVS_Inverter_2";
        type = "CVSWriter";
        datasource = "Inverter_2";
        logfile="/home/tobi/solar/Inverter2_%s.csv";
        rotate=true;

        data2log= [
          "AC grid feeding current (A)",
          "AC grid voltage (V)",
          "Current Grid Feeding Power",
          "DC current in (A)",
          "DC voltage in (V)",
          "Energy produced accumulated all time (kWh)",
          "Energy produced this month (kWh)",
          "Energy produced this year (kWh)",
          "Energy produced today (kWh)",
          "Inverter Overall Status",
          "Inverter Temperature (C)",
          "Net frequency (Hz)"
        ];
      },
      {
        name = "CVS_Inverter_3";
        type = "CVSWriter";
        datasource = "Inverter_3";
        logfile="/home/tobi/solar/Inverter3_%s.csv";
        rotate=true;

        data2log= [
          "AC grid feeding current (A)",
          "AC grid voltage (V)",
          "Current Grid Feeding Power",
          "DC current in (A)",
          "DC voltage in (V)",
          "Energy produced accumulated all time (kWh)"
          "Energy produced this month (kWh)",
          "Energy produced this year (kWh)",
          "Energy produced today (kWh)",
          "Inverter Overall Status",
          "Inverter Temperature (C)",
          "Net frequency (Hz)"
        ];
      },
      {
        name = "CVS_Inverter_HTML1";
        type = "CVSWriter";
        datasource = "Inverter_1";

        logfile="/var/www/spl/Inverter1_%s.csv";
        rotate=true;

        data2log= [
          "Current Grid Feeding Power",
          "Energy produced today (kWh)"
        ];

        flush_file_buffer_immediatly = true;
      },
      {
        name = "CVS_Inverter_HTML2";
        type = "CVSWriter";
        datasource = "Inverter_2";

        logfile="/var/www/spl/Inverter2_%s.csv";
        rotate=true;

        data2log= [
          "Current Grid Feeding Power",
          "Energy produced today (kWh)"
        ];

        flush_file_buffer_immediatly = true;
    },
    {
      name = "CVS_Inverter_HTML3";
      type = "CVSWriter";
      datasource = "Inverter_3";

      logfile="/var/www/spl/Inverter3_%s.csv";
      rotate=true;

      data2log= [
        "Current Grid Feeding Power",
        "Energy produced today (kWh)"
        ];
      flush_file_buffer_immediatly = true;
    },
    {
      name = "HTMLWriter_Inverter1";
      type = "HTMLWriter";
      datasource = "CVS_Inverter_HTML1";

      generate_template = true;
      generate_template_dir = "/tmp";
      writeevery=60;

      htmlfile="/var/www/solarpowerlog-i1-%s.html";
      templatefile="/etc/solarpowerlog/htmlwritertemplate/test.tmpl";

      formatters = (
      # [ what_capability,       formating_operation, where_to_store ],
        [ "CSVDumper::Filename", "stripwebroot", "" , "/var/www" ],
        [ "CSVDumper::LoggedCaps", "searchcvsentry", "powernow", "Current Grid Feeding Power" ],
        [ "CSVDumper::LoggedCaps", "searchcvsentry", "kwhtoday", "Energy produced today (kWh)" ]
      );
    },
    {
      name = "HTMLWriter_Inverter2";
      type = "HTMLWriter";
      datasource = "CVS_Inverter_HTML2";

      generate_template = false;
      generate_template_dir = "/tmp";
      writeevery=60;

      htmlfile="/var/www/solarpowerlog-i2-%s.html";
      templatefile="/etc/solarpowerlog/htmlwritertemplate/test.tmpl";

      formatters = (
      # [ what_capability,       formating_operation, where_to_store ],
        [ "CSVDumper::Filename", "stripwebroot", "" , "/var/www" ],
        [ "CSVDumper::LoggedCaps", "searchcvsentry", "powernow", "Current Grid Feeding Power" ],
        [ "CSVDumper::LoggedCaps", "searchcvsentry", "kwhtoday", "Energy produced today (kWh)" ]
      );
    },
    {
      name = "HTMLWriter_Inverter3";
      type = "HTMLWriter";
      datasource = "CVS_Inverter_HTML3";

      generate_template = false;
      generate_template_dir = "/tmp";
      writeevery=60;
      htmlfile="/var/www/solarpowerlog-i3-%s.html";
      templatefile="/etc/solarpowerlog/htmlwritertemplate/test.tmpl";

      formatters = (
      # [ what_capability,       formating_operation, where_to_store ],
        [ "CSVDumper::Filename", "stripwebroot", "" , "/var/www" ],
        [ "CSVDumper::LoggedCaps", "searchcvsentry", "powernow", "Current Grid Feeding Power" ],
        [ "CSVDumper::LoggedCaps", "searchcvsentry", "kwhtoday", "Energy produced today (kWh)" ]
      );
    }
  );
};

