{
  "pluginAlias": "AlphaEssPlatform",
  "pluginType": "platform",
  "singular": true,
  "name":"Configuration for Alpha Ess",
  "headerDisplay": "Please [read the documentation](https://github.com/zerwuff/homebridge-alphaess) of the plugin for more informations and step by step instructions on how to configure it.",

  "schema": {
    "name": {
      "type": "string",
      "title": "Plugin Name",
      "default": "Alpha ESS Homebridge Plugin"
    },
    "properties": {    
      "name": {
        "type": "string",
        "title": "Plugin Name",
        "default": "Alpha ESS Homebridge Plugin"
      },
      "alphaUrl": {
        "title": "Alpha ESS OpenAPI Url",
        "type": "string",
        "default":"https://openapi.alphaess.com/api",
        "required": true,
        "description" :  "The Alpha ESS OPEN API URL"
      },
      "appid": {
        "title": "App Id",
        "type": "string",
        "required": true,
        "description" :  "The Alpha ESS OPEN API appId"
      },
      "appsecret": {
        "title": "App Secret", 
        "type": "string",
        "required": true,
        "description" : "The alpha ESS OPEN API appSecret"
      },
      "serialnumber": {
        "title": "serialnumber",
        "type": "string",
        "required": true,
        "description" : "The Alpha ESS Serial number, eg. AE...."
      },

      "powerLoadingThreshold": {
        "title": "power threshold",
        "type": "integer",
        "required": true,
        "default":1500,
        "description" : "The pv power threshold to enable the trigger"
      },
      "powerLoadingThresholdSecondsLower": {
        "title": "time threshold down -> up",
        "type": "integer",
        "required": true,
        "default":30,
        "description" : "The number of seconds of the power threshold required to trigger from down -> up"
      },
      "powerLoadingThresholdSecondsUpper": {
        "title": "time threshold up -> down ",
        "type": "integer",
        "required": true,
        "default":45,
        "description" : "The number of seconds of the power threshold required to trigger from up -> down"
      },

      "socLoadingThreshold": {
        "title": "socLoadingThreshold",
        "type": "integer",
        "required": false,
        "default": 50,
        "description" : "The battery SOC threshold to enable the trigger"
      },
      "refreshTimerInterval": {
        "title": "refreshTimerInterval",
        "type": "integer",
        "required": false,
        "default":60000,
        "description" : "The refresh timer interval in ms to update system values"
      },
      "mqtt_url": {
        "title": "mqtt_url",
        "type": "string",
        "required": false,
        "description" :  "the mqtt url, e.g mqt://bla.fasel"
      },
      "mqtt_trigger_topic_true": {
        "title": "mqtt_trigger_topic_true",
        "type": "string",
        "required": false,      
        "description" : "the mqtt topic to use when trigger is true"
      },
      "mqtt_trigger_topic_false": {
        "title": "mqtt_trigger_topic_false",
        "type": "string",
        "required": false,      
        "description" : "the mqtt topic to use when trigger is false"
      },
      "mqtt_trigger_message_true": {
        "title": "mqtt_trigger_message_true",
        "type": "string",
        "required": false,      
        "description" : "the mqtt message to use when trigger is true"
      },
      "mqtt_trigger_message_false": {
        "title": "mqtt_trigger_message_false",
        "type": "string",
        "required": false,      
        "description" : "the mqtt message to use when trigger is false"
      },    
      "mqtt_status_topic": {
        "title": "mqtt_status_topic",
        "type": "string",
        "required": false,
        "description" :  "the mqtt status topic name to send alpha ess status data (soc, power) "
      },
      "power_image_filename": {
        "title": "power_image_filename",
        "type": "string",
        "required": false,
        "default":"/tmp/alpha_power_image.png",
        "description" :  "the filename where power image is rendered to "
      },
     "logrequestdata": {
        "title": "logrequestdata",
        "type": "boolean",
        "required": false,
        "default": false, 
        "description":"log request data yes / no"
      },
      
      "tibberEnabled": {
        "title": "Enable Tibber Trigger",
        "type": "boolean",
        "required": false,
        "default": false, 
        "description":"Enable Tibber Trigger yes / no"
      },

      "tibberUrl": {
        "title": "Tibber API URL",
        "type": "string",
        "default":"",
        "required": false,
        "description" :  "the tibber API Url" ,
        "condition": {
          "functionBody": "return model.tibberEnabled === true;"
        }
      },
      "tibberAPIKey": {
        "title": "Tibber API Key",
        "type": "string",
        "required": false,
        "default":"",
        "description" : "the the tibber api key ",
        "condition": {
          "functionBody": "return model.tibberEnabled === true;"
        }
      },
  
      "tibberLoadBatteryEnabled": {
        "title": "Enable Battery loading w/ tibber ",
        "type": "boolean",
        "required": false,
        "default": false, 
        "description":"Enable loading of the battery when lowest price or highest point is met yes / no",
        "condition": {
          "functionBody": "return model.tibberEnabled === true;"
        }
      },
      
      "tibberLoadingMinutes": {
        "title": "Tibber Battery Loading Time (Minutes) ",
        "type": "integer",
        "default": 60,
        "required": false,
        "description" :  "When in loading mode, number of minutes to load the battery",
        "condition": {
          "functionBody": "return model.tibberEnabled === true;"
        }
      },
    
      "tibberCarLoadingMinutes": {
        "title": "Tibber Car Loading Time (Minutes) ",
        "type": "integer",
        "default": 240,
        "required": false,
        "description" :  "When tibber triggers enabled, for how long should the trigger be true after the cheapest point ? E.G. cheapest point: 10 PM, plus that time in minutes sending of mqtt_trigger_message_true/false - to optimize car loading ",
        "condition": {
          "functionBody": "return model.tibberEnabled === true;"
        }
      },
    

      "tibberThresholdSOC": {
        "title": "Tibber SOC Threshold",
        "type": "integer",
        "default": 60,
        "required": false,
        "description" :  "the battery SOC threshold that is required to trigger tibber loading. if below with price, loading is triggerd.",
        "condition": {
          "functionBody": "return model.tibberEnabled === true;"
        }
      },
    
      "tibberThresholdEur": {
        "title": "Tibber difference threshold in euro ",
        "type": "number",
        "default":"0.020",
        "required": false,
        "description" :  "The diff to the lowest price that is acceptable to trigger tibber loading. eg. daily tibber minimum = 0.20 , this value = 0.02, trigger is fired at 0.22 ",
        "condition": {
          "functionBody": "return model.tibberEnabled === true;"
        }
      },

      "tibberThresholdTotalEur": {
        "title": "Tibber absolute lower threshold in eur (lower price limit)",
        "type": "number",
        "default":"0.30",
        "required": false,
        "description" :  "The absolute max price of tibber that is acceptable to trigger battery loading. This wins over tibber difference threshold. Example: daily tibber minimum = 0.20, this value 0.19, then loading is triggered.  Idea: Pump into battery with low prices.",
        "condition": {
          "functionBody": "return model.tibberEnabled === true;"
        }
      },

      "tibberThresholdMaxEur": {
        "title": "Tibber max price threshold in eur (upper price limit)",
        "type": "number",
        "default": "0.50",
        "required": false,
        "description" :  "The absolute max price of tibber needs to be reached during the day to trigger battery loading at the lowest point within threshold. Example: daily price range is 0.20-0.60 , If this value = 0.50, trigger is fired at the lowest time before the high peak of this day. Idea: Protect from high energy prices",
        "condition": {
          "functionBody": "return model.tibberEnabled === true;"
        }
      },
    
     "tibberDischargeDisabled": {
        "title": "Disable Battery Discharge during tibber loading ",
        "type": "boolean",
        "required": true,
        "default": true, 
        "description":"During tibber charge, prevent discharge of the battery, to save battery life and money ",
        "condition": {
          "functionBody": "return model.tibberEnabled === true;"
        }
      },
      "triggerImageFilename": {
        "title": "Trigger Image Filename",
        "type": "string",
        "required": false,
        "default":"/tmp/tibber_image.png",
        "description" :  "The filename where the alpha and tibber trigger image is rendered to "
      }
    }
  },
  "layout": [
 
    {
      "type": "fieldset",
      "expandable": true,
      "title": "Alpha ESS Settings",        
      "expanded": true,
      "items": [
          "name",
          "alphaUrl",
          "appid",
          "appsecret",
          "serialnumber",   
          "refreshTimerInterval",
          "triggerImageFilename",  
          "power_image_filename",       
          "logrequestdata"
      ]
  },
  {
    "type": "fieldset",
    "expandable": true,
    "title": "Alpha Trigger Settings",
    "description":"Reaching this settings will open the sensor, mostly to trigger automation",        
    "expanded": false,
    "items": [    
        "powerLoadingThreshold",   
        "powerLoadingThresholdSecondsUpper",
        "powerLoadingThresholdSecondsLower",
        "socLoadingThreshold"
              
    ]
},
    {
      "type": "fieldset",
      "expandable": true,
      "title": "MQTT Settings",        
      "items": [
          "mqtt_url",
          "mqtt_trigger_topic_true",
          "mqtt_trigger_topic_false",
          "mqtt_trigger_message_true",
          "mqtt_trigger_message_false"        
      ]
  },
    {
        "type": "fieldset",
        "expandable": true,
        "title": "Tibber Settings",        
        "items": [
            "tibberEnabled",
            "tibberUrl",
            "tibberAPIKey",
            "tibberLoadBatteryEnabled",
            "tibberLoadingMinutes",
            "tibberCarLoadingMinutes",
            "tibberThresholdSOC",
            "tibberThresholdEur",
            "tibberThresholdTotalEur",
            "tibberThresholdMaxEur",
            "tibberDischargeDisabled"            
        ]
    }
  ]
  
}