-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIungo_Monitor-20.fqa
1 lines (1 loc) · 68.2 KB
/
Iungo_Monitor-20.fqa
1
{"name":"Iungo Monitor","type":"com.fibaro.powerMeter","apiVersion":"1.2","initialProperties":{"viewLayout":{"$jason":{"body":{"header":{"style":{"height":"0"},"title":"quickApp_device_723"},"sections":{"items":[{"components":[{"name":"label","style":{"weight":"1.2"},"text":"Label","type":"label","visible":true},{"style":{"weight":"0.5"},"type":"space"}],"style":{"weight":"1.2"},"type":"vertical"}]}},"head":{"title":"quickApp_device_723"}}},"uiCallbacks":[],"quickAppVariables":[{"name":"IPaddress","type":"string","value":"192.168.178.12"},{"name":"interval","type":"string","value":"10"},{"name":"debugLevel","type":"string","value":"4"},{"name":"language","type":"string","value":"nl"},{"name":"solarPanel","type":"string","value":"false"},{"name":"gasMeterAnalog","type":"string","value":"false"},{"name":"waterMeter","type":"string","value":"false"},{"name":"solarM2","type":"string","value":"0"},{"name":"monitorOID","type":"string","value":"538d72d9"},{"name":"solarOID","type":"string","value":"95778a43"},{"name":"gasAnalogOID","type":"string","value":"06e869e1"},{"name":"waterOID","type":"string","value":"82ec52ad"},{"name":"meterConsHigh","type":"string","value":"0"},{"name":"meterConsLow","type":"string","value":"0"},{"name":"meterProdHigh","type":"string","value":"0"},{"name":"meterProdLow","type":"string","value":"0"},{"name":"meterGas","type":"string","value":"0"},{"name":"meterWater","type":"string","value":"0"},{"name":"meterEnergyD","type":"string","value":"00-00-0000"},{"name":"meterGasD","type":"string","value":"00-00-0000"},{"name":"meterWaterD","type":"string","value":"00-00-0000"}],"typeTemplateInitialized":true},"initialInterfaces":[],"files":[{"name":"main","isMain":true,"isOpen":false,"content":"-- Iungo Monitor main\n\nlocal version = '2.0'\n\nlocal function getChildVariable(child,varName)\n for _,v in ipairs(child.properties.quickAppVariables or {}) do\n if v.name==varName then return v.value end\n end\n return \"\"\nend\n\n\nfunction QuickApp:logging(level,text) -- Logging function for debug\n if tonumber(debugLevel) >= tonumber(level) then \n self:debug(text)\n end\nend\n\n\nfunction QuickApp:solarPower(power, m2) -- Calculate Solar Power M2\n self:logging(3,\"Quickapp:solarPower\")\n if m2 > 0 and power > 0 then\n solarPower = power / m2\n else\n solarPower = 0\n end\n return solarPower\nend\n\n\nfunction QuickApp:unitCheckWh(measurement) -- Set the measurement and unit to Wh, kWh, MWh or GWh\n self:logging(3,\"unitCheckWh() - Set the measurement and unit to Wh, kWh, MWh or GWh\")\n if measurement > 1000000000 then\n return string.format(\"%.3f\",measurement/1000000000),\"GWh\"\n elseif measurement > 1000000 then\n return string.format(\"%.3f\",measurement/1000000),\"MWh\"\n elseif measurement > 1000 then\n return string.format(\"%.3f\",measurement/1000),\"kWh\"\n else\n return string.format(\"%.3f\",measurement),\"Wh\"\n end\nend\n\n\nfunction QuickApp:recalcMeter(meter,reading) -- Recalculate meter readings\n self:logging(3,\"recalcMeter() - Recalculate meter readings\")\n if tonumber(meter) > 0 and tonumber(meter) <= tonumber(reading) then\n return string.format(\"%.3f\",reading - meter)\n elseif tonumber(meter) > 0 and tonumber(meter) > tonumber(reading) then\n return string.format(\"%.3f\",reading + meter)\n end\n return string.format(\"%.3f\",reading)\nend\n\n\nfunction QuickApp:updateProperties() -- Update the properties\n self:logging(3,\"updateProperties() - Update the properties\")\n self:updateProperty(\"value\", tonumber(string.format(\"%.3f\",data.house_consumption)))\n self:updateProperty(\"power\", tonumber(string.format(\"%.3f\",data.house_consumption)))\n self:updateProperty(\"unit\", \"Watt\")\n self:updateProperty(\"log\", data.tarifcodeText ..\" \" ..translation[\"tarif\"])\nend\n\n\nfunction QuickApp:updateLabels() -- Update the labels \n self:logging(3,\"updateLabels() - Update the labels\")\n local labelText = \"\"\n \n if debugLevel == 4 then\n labelText = labelText ..translation[\"SIMULATION MODE\"] ..\"\\n\\n\"\n end\n \n if solarPanel then\n labelText = labelText ..translation[\"Grid Consumption\"] ..\": \" ..data.grid_consumption ..\" \" ..\"Watt\" ..\" \" ..data.tarifcodeText ..\" \" ..translation[\"tarif\"] ..\"\\n\"\n labelText = labelText ..translation[\"House\"] ..\" \" ..translation[\"Consumption\"] ..\": \" ..data.house_consumption ..\" \" ..\"Watt\" ..\"\\n\"\n labelText = labelText ..translation[\"Solar\"] ..\" \" ..translation[\"Production\"] ..\": \" ..data.solar ..\" \" ..\"Watt\" ..\" (\" ..solarM2 ..\" m² / \" ..data.solarPower ..\" \" ..\"Watt/m²)\" ..\"\\n\"\n else\n labelText = labelText ..translation[\"Consumption\"] ..\": \" ..data.consumption ..\" \" ..\"Watt\" ..\"/\" ..translation[\"tarif\"] ..\": (\" ..data.tarifcodeText ..\")\" ..\"\\n\"\n end\n if gasMeterAnalog then\n labelText = labelText ..translation[\"Gas\"] ..\" \" ..translation[\"Consumption\"] ..\": \" ..data.consumption_gas ..\" \" ..translation[\"L/min\"] ..\"\\n\"\n end\n if waterMeter then\n labelText = labelText ..translation[\"Waterflow\"] ..\": \" ..data.flow ..\" \" ..translation[\"L/min\"] ..\"\\n\"\n end\n \n labelText = labelText ..\"\\n\" ..translation[\"Totals\"] ..\" \" ..translation[\"Consumption\"] ..\":\" ..\"\\n\"\n labelText = labelText ..translation[\"Netting\"] ..\": \" ..data.total_netting ..\" \" ..\"kWh\" ..\"\\n\" \n labelText = labelText ..translation[\"Consumption\"] ..\" \" ..translation[\"high\"] ..\": \" ..data.consumption_high ..\" \" ..\"kWh\" ..\"\\n\" \n labelText = labelText ..translation[\"Consumption\"] ..\" \" ..translation[\"low\"] ..\": \" ..data.consumption_low ..\" \" ..\"kWh\" ..\"\\n\"\n labelText = labelText ..translation[\"Consumption\"] ..\" \" ..translation[\"total\"] ..\": \" ..data.total_consumption ..\" \" ..\"kWh\" ..\"\\n\" \n labelText = labelText ..translation[\"Consumption\"] ..\" \" ..translation[\"low\"] ..\": \" ..string.format(\"%.2f\",tonumber(data.consumption_low)*tonumber(data.cost_consumption_low)/100) ..\" \" ..\"EUR\" ..\" (\" ..data.cost_consumption_low ..\" EURcent)\" ..\"\\n\" \n labelText = labelText ..translation[\"Consumption\"] ..\" \" ..translation[\"high\"] ..\": \" ..string.format(\"%.2f\",tonumber(data.consumption_high)*tonumber(data.cost_consumption_high)/100) ..\" \" ..\"EUR\" ..\" (\" ..data.cost_consumption_high ..\" EURcent)\" ..\"\\n\" \n labelText = labelText ..translation[\"Consumption\"] ..\" \" ..translation[\"total\"] ..\": \" ..string.format(\"%.2f\",(tonumber(data.consumption_low)*tonumber(data.cost_consumption_low)/100)+(tonumber(data.consumption_high)*tonumber(data.cost_consumption_high)/100)) ..\" \" ..\"EUR\" ..\" (\" ..data.cost_consumption_low ..\" EURcent)\" ..\"\\n\\n\"\n \n labelText = labelText ..translation[\"Totals\"] ..\" \" ..translation[\"Production\"] ..\":\" ..\"\\n\"\n if solarPanel then\n labelText = labelText ..translation[\"Solar\"] ..\" \" ..translation[\"Production\"] ..\" \" ..translation[\"total\"] ..\": \" ..data.meterreading ..\" \" ..data.meterreadingUnit ..\"\\n\"\n end\n labelText = labelText ..translation[\"Production\"] ..\" \" ..translation[\"high\"] ..\": \" ..data.production_high ..\" \" ..\"kWh\" ..\"\\n\" \n labelText = labelText ..translation[\"Production\"] ..\" \" ..translation[\"low\"] ..\": \" ..data.production_low ..\" \" ..\"kWh\" ..\"\\n\"\n labelText = labelText ..translation[\"Production\"] ..\" \" ..translation[\"total\"] ..\": \" ..data.total_production ..\" \" ..\"kWh\" ..\"\\n\"\n labelText = labelText ..translation[\"Production\"] ..\" \" ..translation[\"high\"] ..\": \" ..string.format(\"%.2f\",tonumber(data.production_high)*tonumber(data.cost_production_high)/100) ..\" \" ..\"EUR\" ..\" (\" ..data.cost_production_high ..\" EURcent)\" ..\"\\n\" \n labelText = labelText ..translation[\"Production\"] ..\" \" ..translation[\"low\"] ..\": \" ..string.format(\"%.2f\",tonumber(data.production_low)*tonumber(data.cost_production_low)/100) ..\" \" ..\"EUR\" ..\" (\" ..data.cost_production_low ..\" EURcent)\" ..\"\\n\" \n labelText = labelText ..translation[\"Production\"] ..\" \" ..translation[\"total\"] ..\": \" ..string.format(\"%.2f\",(tonumber(data.production_low)*tonumber(data.cost_production_low)/100)+(tonumber(data.production_high)*tonumber(data.cost_production_high)/100)) ..\" \" ..\"EUR\" ..\" (\" ..data.cost_production_low ..\" EURcent)\" ..\"\\n\\n\"\n \n labelText = labelText ..translation[\"Totals\"] ..\" \" ..translation[\"Gas\"] ..\":\" ..\"\\n\"\n labelText = labelText ..translation[\"Gas\"] ..\" \" ..translation[\"total\"] ..\": \" ..data.gas ..\" \" ..\"m³\" ..\"\\n\"\n labelText = labelText ..translation[\"Gas\"] ..\" \" ..translation[\"total\"] ..\": \" ..string.format(\"%.2f\",tonumber(data.gas)*tonumber(data.cost_gas)/100) ..\" \" ..\"EUR\" ..\" (\" ..data.cost_gas ..\" EURcent)\" ..\"\\n\\n\" \n if waterMeter then\n labelText = labelText ..translation[\"Totals\"] ..\" \" ..translation[\"Water\"] ..\":\" ..\"\\n\"\n labelText = labelText ..translation[\"Water\"] ..\" \" ..\"total\" ..\": \" ..data.wused ..\" \" ..\"m³\" ..\"\\n\\n\"\n end\n labelText = labelText ..translation[\"Ampere\"] ..\": \" ..\"\\n\"\n labelText = labelText ..\"L1\" ..\": \" ..data.L1_A ..\" \" ..\"L2\" ..\": \" ..data.L2_A ..\" \" ..\"L3\" ..\": \" ..data.L3_A ..\"\\n\\n\" \n \n labelText = labelText ..translation[\"Voltage\"] ..\": \" ..\"\\n\"\n labelText = labelText ..\"L1\" ..\": \" ..data.L1_V ..\" \" ..\"L2\" ..\": \" ..data.L2_V ..\" \" ..\"L3\" ..\": \" ..data.L3_V ..\"\\n\\n\" \n\n labelText = labelText ..translation[\"Import\"] ..\": \" ..\"\\n\"\n labelText = labelText ..\"L1\" ..\": \" ..data.L1_imp ..\" \" ..\"L2\" ..\": \" ..data.L2_imp ..\" \" ..\"L3\" ..\": \" ..data.L3_imp ..\"\\n\\n\" \n\n labelText = labelText ..translation[\"Export\"] ..\": \" ..\"\\n\"\n labelText = labelText ..\"L1\" ..\": \" ..data.L1_exp ..\" \" ..\"L2\" ..\": \" ..data.L2_exp ..\" \" ..\"L3\" ..\": \" ..data.L3_exp ..\"\\n\\n\" \n\n labelText = labelText ..translation[\"Meter\"] ..\": \" ..data.name ..\" \" ..data.metertype ..\" \" ..data.version ..\"\\n\"\n labelText = labelText ..\"Energy\" ..\": \" ..data.serialE ..\"\\n\"\n labelText = labelText ..translation[\"Gas\"] ..\": \" ..data.serialG ..\"\\n\"\n self:updateView(\"label\", \"text\", labelText)\n self:logging(2,labelText)\nend\n\n\nfunction QuickApp:valuesWater() -- Update the Water values from json file\n self:logging(3,\"valuesWater() - Update the Water values from json file\")\n data.flow = string.format(\"%.3f\",jsonTableWater.rv.propsval[2].value)\n data.pulstotal = jsonTableWater.rv.propsval[3].value\n data.kfact = jsonTableWater.rv.propsval[4].value \n data.offset = jsonTableWater.rv.propsval[5].value\n data.wused = string.format(\"%.3f\",data.pulstotal/data.kfact+data.offset)\n data.wused = self:recalcMeter(meterWater, data.wused)\nend\n\n\nfunction QuickApp:valuesGas() -- Update the Analog Gas values from json file\n self:logging(3,\"valuesGas() - Update the Analog Gas values from json file\")\n data.consumption_gas = string.format(\"%.3f\",jsonTableGas.rv.propsval[2].value)\n data.gas = string.format(\"%.3f\",jsonTableGas.rv.propsval[3].value)\n --data.flow = jsonTableGas.rv.propsval[2].value\n data.cost_gas = string.format(\"%.4f\",tonumber(jsonTableGas.rv.propsval[4].value)*100) -- Cost gas\n data.Gasdigits = jsonTableGas.rv.propsval[5].value \n data.GASrotations = jsonTableGas.rv.propsval[6].value\n data.GASoffset = jsonTableGas.rv.propsval[7].value\n --data.gas = string.format(\"%.3f\",data.GASrotations/data.Gasdigits+data.GASoffset)\n data.gas = self:recalcMeter(meterGas, data.gas)\nend\n\n\nfunction QuickApp:valuesSolar() -- Update the Solar values from json file\n self:logging(3,\"valuesSolar() - Update the Solar values from json file\")\n data.solar = string.format(\"%.1f\",jsonTableSolar.rv.propsval[2].value)\n data.pulstotal = string.format(\"%.3f\",jsonTableSolar.rv.propsval[3].value)\n data.ppkwh = string.format(\"%.3f\",jsonTableSolar.rv.propsval[4].value)\n data.offset = string.format(\"%.3f\",jsonTableSolar.rv.propsval[5].value)\n data.meterreading = string.format(\"%.3f\",(tonumber(data.pulstotal)/tonumber(data.ppkwh)+tonumber(data.offset))*1000) -- Calculate meterreading x1000 for Wh values\n data.meterreading, data.meterreadingUnit = self:unitCheckWh(tonumber(data.meterreading)) -- Set measurement and unit to Wh, kWh, MWh or GWh\n data.solarPower = string.format(\"%.2f\",self:solarPower(tonumber(data.solar), tonumber(solarM2)))\n --data.grid_consumption = string.format(\"%.1f\",tonumber(data.consumption) - tonumber(data.solar)) -- Calculate net_consumption\n data.house_consumption = string.format(\"%.1f\",tonumber(data.consumption) + tonumber(data.solar)) -- House_consumption is consumption plus solar\nend\n\n\nfunction QuickApp:valuesMonitor() -- Update the Monitor values from json file\n self:logging(3,\"valuesMonitor() - Update the Monitor values from json file\")\n local i=1\n while jsonTableMonitor.rv.propsval[i] do\n --self:logging(4,jsonTableMonitor.rv.propsval[i].id)\n --self:logging(4,jsonTableMonitor.rv.propsval[i].value)\n if jsonTableMonitor.rv.propsval[i].id == \"usage\" then\n data.consumption = string.format(\"%.1f\",jsonTableMonitor.rv.propsval[i].value) -- Usage form the grid\n elseif jsonTableMonitor.rv.propsval[i].id == \"T1\" then\n data.consumption_low = string.format(\"%.3f\",jsonTableMonitor.rv.propsval[i].value)\n data.consumption_low = self:recalcMeter(meterConsLow, data.consumption_low)\n elseif jsonTableMonitor.rv.propsval[i].id == \"Cost-T1\" then\n data.cost_consumption_low = string.format(\"%.4f\",tonumber(jsonTableMonitor.rv.propsval[i].value)*100)\n elseif jsonTableMonitor.rv.propsval[i].id == \"T2\" then\n data.consumption_high = string.format(\"%.3f\",jsonTableMonitor.rv.propsval[i].value)\n data.consumption_high = self:recalcMeter(meterConsHigh, data.consumption_high)\n elseif jsonTableMonitor.rv.propsval[i].id == \"Cost-T2\" then\n data.cost_consumption_high = string.format(\"%.4f\",tonumber(jsonTableMonitor.rv.propsval[i].value)*100)\n elseif jsonTableMonitor.rv.propsval[i].id == \"-T1\" then\n data.production_low = string.format(\"%.3f\",jsonTableMonitor.rv.propsval[i].value)\n data.production_low = self:recalcMeter(meterProdLow, data.production_low)\n elseif jsonTableMonitor.rv.propsval[i].id == \"Cost-nT1\" then\n data.cost_production_low = string.format(\"%.4f\",tonumber(jsonTableMonitor.rv.propsval[i].value)*100)\n elseif jsonTableMonitor.rv.propsval[i].id == \"-T2\" then\n data.production_high = string.format(\"%.3f\",jsonTableMonitor.rv.propsval[i].value)\n data.production_high = self:recalcMeter(meterProdHigh, data.production_high)\n elseif jsonTableMonitor.rv.propsval[i].id == \"Cost-nT2\" then\n data.cost_production_high = string.format(\"%.4f\",tonumber(jsonTableMonitor.rv.propsval[i].value)*100)\n elseif jsonTableMonitor.rv.propsval[i].id == \"gas_usage\" and not gasMeterAnalog then\n data.consumption_gas = string.format(\"%.3f\",jsonTableMonitor.rv.propsval[i].value)\n elseif jsonTableMonitor.rv.propsval[i].id == \"gas\" and not gasMeterAnalog then\n data.gas = string.format(\"%.3f\",jsonTableMonitor.rv.propsval[i].value)\n data.gas = self:recalcMeter(meterGas, data.gas)\n elseif jsonTableMonitor.rv.propsval[i].id == \"Cost-gas\" and not gasMeterAnalog then\n data.cost_gas = string.format(\"%.4f\",tonumber(jsonTableMonitor.rv.propsval[i].value)*100) -- Cost gas\n elseif jsonTableMonitor.rv.propsval[i].id == \"c_tariff\" then\n data.tarifcode = tostring(jsonTableMonitor.rv.propsval[i].value)\n elseif jsonTableMonitor.rv.propsval[i].id == \"L1I\" then -- L1 Ampere\n data.L1_A = string.format(\"%.0f\",jsonTableMonitor.rv.propsval[i].value)\n elseif jsonTableMonitor.rv.propsval[i].id == \"L2I\" then -- L2 Ampere\n data.L2_A = string.format(\"%.0f\",jsonTableMonitor.rv.propsval[i].value)\n elseif jsonTableMonitor.rv.propsval[i].id == \"L3I\" then -- L3 Ampere\n data.L3_A = string.format(\"%.0f\",jsonTableMonitor.rv.propsval[i].value) \n elseif jsonTableMonitor.rv.propsval[i].id == \"L1U\" then -- L1 Voltage\n data.L1_V = string.format(\"%.0f\",jsonTableMonitor.rv.propsval[i].value)\n elseif jsonTableMonitor.rv.propsval[i].id == \"L2U\" then -- L2 Voltage\n data.L2_V = string.format(\"%.0f\",jsonTableMonitor.rv.propsval[i].value)\n elseif jsonTableMonitor.rv.propsval[i].id == \"L3U\" then -- L3 Voltage\n data.L3_V = string.format(\"%.0f\",jsonTableMonitor.rv.propsval[i].value) \n elseif jsonTableMonitor.rv.propsval[i].id == \"L1Pimp\" then -- L1 Import kW\n data.L1_imp = string.format(\"%.3f\",jsonTableMonitor.rv.propsval[i].value)\n elseif jsonTableMonitor.rv.propsval[i].id == \"L2Pimp\" then -- L2 Import kW\n data.L2_imp = string.format(\"%.3f\",jsonTableMonitor.rv.propsval[i].value)\n elseif jsonTableMonitor.rv.propsval[i].id == \"L3Pimp\" then -- L3 Import kW\n data.L3_imp = string.format(\"%.3f\",jsonTableMonitor.rv.propsval[i].value)\n elseif jsonTableMonitor.rv.propsval[i].id == \"L1Pexp\" then -- L1 Export kW\n data.L1_exp = string.format(\"%.3f\",jsonTableMonitor.rv.propsval[i].value)\n elseif jsonTableMonitor.rv.propsval[i].id == \"L2Pexp\" then -- L2 Export kW\n data.L2_exp = string.format(\"%.3f\",jsonTableMonitor.rv.propsval[i].value)\n elseif jsonTableMonitor.rv.propsval[i].id == \"L3Pexp\" then -- L3 Export kW\n data.L3_exp = string.format(\"%.3f\",jsonTableMonitor.rv.propsval[i].value)\n elseif jsonTableMonitor.rv.propsval[i].id == \"name\" then -- Name\n data.name = jsonTableMonitor.rv.propsval[i].value\n elseif jsonTableMonitor.rv.propsval[i].id == \"metertype\" then -- Metertype\n data.metertype = jsonTableMonitor.rv.propsval[i].value\n elseif jsonTableMonitor.rv.propsval[i].id == \"version\" then -- Version\n data.version = jsonTableMonitor.rv.propsval[i].value\n elseif jsonTableMonitor.rv.propsval[i].id == \"serial_e\" then -- Version\n data.serialE = jsonTableMonitor.rv.propsval[i].value\n elseif jsonTableMonitor.rv.propsval[i].id == \"serial_g\" then -- Version\n data.serialG = jsonTableMonitor.rv.propsval[i].value\n else\n --self:warning(\"Unknown measurement value\")\n end\n i=i+1\n end\n --data.grid_consumption = string.format(\"%.1f\",tonumber(data.consumption) - tonumber(data.solar)) -- Initial calculation without Solar Panel\n data.grid_consumption = string.format(\"%.1f\",tonumber(data.consumption)) -- Net consumption is equal to consumption\n data.house_consumption = string.format(\"%.1f\",tonumber(data.consumption) + tonumber(data.solar)) -- House_consumption is consumption plus solar\n data.total_consumption = string.format(\"%.3f\",tonumber(data.consumption_low) + tonumber(data.consumption_high))\n data.total_production = string.format(\"%.3f\",tonumber(data.production_low) + tonumber(data.production_high))\n data.total_netting = string.format(\"%.3f\",data.total_consumption - data.total_production)\n\n if data.tarifcode == \"2\" then \n data.tarifcodeText = translation[\"high\"]\n elseif data.tarifcode == \"1\" then\n data.tarifcodeText = translation[\"low\"]\n else\n data.tarifcodeText = \"\"\n end\nend \n\n\nfunction QuickApp:getData() -- Get data from Iungo Monitor, Solar, Water\n self:logging(3,\"getData() - Get data from Iungo Monitor, Solar, Water\")\n local url = \"http://\" ..IPaddress ..Path\n self:logging(3,\"url: \" ..url)\n self:logging(3,\"currentMethod: \" ..currentMethod)\n \n self.http:request(url, {\n options = {\n data = currentMethod,\n method = \"POST\",\n headers = {\n [\"Content-Type\"] = \"application/json\",\n [\"Accept\"] = \"application/json\",\n }\n },\n success = function(response) \n self:logging(3,\"Response status: \" ..response.status)\n self:logging(3,\"Response data: \" ..response.data)\n apiResult = response.data\n\n if currentMethod == methodMonitor then\n jsonTableMonitor = json.decode(apiResult) -- Decode the json string from api to lua-table Monitor\n self:valuesMonitor() -- Get the values from Monitor json file\n self:updateLabels() -- Update the labels\n self:updateProperties() -- Update the propterties\n self:updateChildDevices() -- Update the Child Devices\n if solarPanel then\n currentMethod = methodSolar\n elseif gasMeterAnalog then\n currentMethod = methodGas\n elseif waterMeter then\n currentMethod = methodWater\n end\n\n elseif currentMethod == methodSolar then\n jsonTableSolar = json.decode(apiResult) -- Decode the json string lua-table Solarpanel\n self:valuesSolar() -- Get the values from Solar json file\n self:updateLabels() -- Update the labels\n self:updateProperties() -- Update the propterties\n self:updateChildDevices() -- Update the Child Devices\n if gasMeterAnalog then\n currentMethod = methodGas\n elseif waterMeter then \n currentMethod = methodWater\n else\n currentMethod = methodMonitor\n end\n \n elseif currentMethod == methodGas then\n jsonTableGas = json.decode(apiResult) -- Decode the json string lua-table Analog Gasmeter\n self:valuesGas() -- Get the values from Analog Gas json file\n self:updateLabels() -- Update the labels\n self:updateChildDevices() -- Update the Child Devices\n currentMethod = methodMonitor \n\n elseif currentMethod == methodWater then\n jsonTableWater = json.decode(apiResult) -- Decode the json string lua-table Watermeter\n self:valuesWater() -- Get the values from Water json file\n self:updateLabels() -- Update the labels\n self:updateChildDevices() -- Update the Child Devices\n if gasMeterAnalog then\n currentMethod = methodGas\n else\n currentMethod = methodMonitor\n end\n\n else\n self:warning(\"No Monitor, Solar, Water or Analog Gas active\")\n return\n end\n\n end,\n error = function(message)\n self:logging(3,\"error: \" ..message)\n self:updateProperty(\"log\", \"error: \" ..json.encode(error))\n end\n })\n self:logging(3,\"setTimeout \" ..interval ..\" seconds\")\n fibaro.setTimeout(interval*1000, function() -- Checks every [interval] seconds for new data\n self:getData()\n end)\nend \n\n\nfunction QuickApp:simData() -- Simulate Iungo Monitor, Solar, Water\n self:logging(3,\"simData() - Simulate Iungo Monitor, Solar, Water\")\n if currentMethod == methodMonitor then\n \n --apiResult = '{\"ok\":true,\"type\":\"response\",\"time\":0.0026875899638981,\"rv\":{\"propsval\":[{\"id\":\"name\",\"value\":\"EnergieDirect\"},{\"id\":\"metertype\",\"value\":\"XMX\"},{\"id\":\"version\",\"value\":\"5\"},{\"id\":\"serial_e\",\"value\":\"4999999999999999999999666666666666\"},{\"id\":\"usage\",\"value\":516},{\"id\":\"T1\",\"value\":10817.833},{\"id\":\"T2\",\"value\":5398.875},{\"id\":\"-T1\",\"value\":4379.797},{\"id\":\"-T2\",\"value\":9959.182},{\"id\":\"L1I\",\"value\":1},{\"id\":\"L2I\",\"value\":1},{\"id\":\"L3I\",\"value\":2},{\"id\":\"L1Pimp\",\"value\":0.054},{\"id\":\"L2Pimp\",\"value\":0.125},{\"id\":\"L3Pimp\",\"value\":0.336},{\"id\":\"L1Pexp\",\"value\":0},{\"id\":\"L2Pexp\",\"value\":0},{\"id\":\"L3Pexp\",\"value\":0},{\"id\":\"c_tariff\",\"value\":2},{\"id\":\"serial_g\",\"value\":\"4999999999999999999999999999999996\"},{\"id\":\"gas_usage\",\"value\":1},{\"id\":\"gas\",\"value\":3903.388},{\"id\":\"Cost-T1\",\"value\":0.20721},{\"id\":\"Cost-T2\",\"value\":0.22921},{\"id\":\"Cost-nT1\",\"value\":0.20721},{\"id\":\"Cost-nT2\",\"value\":0.22921},{\"id\":\"Cost-gas\",\"value\":0.7711},{\"id\":\"Gas-interval\",\"value\":3600},{\"id\":\"Client-blob\",\"value\":\"\"},{\"id\":\"available\",\"value\":true}]},\"systime\":1610986159,\"seq\":1,\"error\":false}' -- Old API version\n\n --apiResult = '{\"ok\":true,\"type\":\"response\",\"time\":0.0024689069832675,\"rv\":{\"propsval\":[{\"id\":\"name\",\"value\":\"EnergieDirect\"},{\"id\":\"metertype\",\"value\":\"XMX\"},{\"id\":\"version\",\"value\":\"5\"},{\"id\":\"serial_e\",\"value\":\"4999999999999999999999666666666666\"},{\"id\":\"usage\",\"value\":740},{\"id\":\"T1\",\"value\":17096.104},{\"id\":\"T2\",\"value\":8852.012},{\"id\":\"-T1\",\"value\":7768.567},{\"id\":\"-T2\",\"value\":17359.683},{\"id\":\"L1I\",\"value\":1},{\"id\":\"L2I\",\"value\":1},{\"id\":\"L3I\",\"value\":3},{\"id\":\"L1Pimp\",\"value\":0.031},{\"id\":\"L2Pimp\",\"value\":0.128},{\"id\":\"L3Pimp\",\"value\":0.581},{\"id\":\"L1Pexp\",\"value\":0},{\"id\":\"L2Pexp\",\"value\":0},{\"id\":\"L3Pexp\",\"value\":0},{\"id\":\"c_tariff\",\"value\":1},{\"id\":\"serial_g\",\"value\":\"4999999999999999999999999999999996\"},{\"id\":\"gas_usage\",\"value\":0},{\"id\":\"gas\",\"value\":5779.389},{\"id\":\"Cost-T1\",\"value\":0.36789},{\"id\":\"Cost-T2\",\"value\":0.37031},{\"id\":\"Cost-nT1\",\"value\":0.36789},{\"id\":\"Cost-nT2\",\"value\":0.37031},{\"id\":\"netting\",\"value\":\"off\"},{\"id\":\"Cost-net-comp\",\"value\":0},{\"id\":\"Cost-gas\",\"value\":1.2987},{\"id\":\"Gas-interval\",\"value\":3600},{\"id\":\"Client-blob\",\"value\":\"\"},{\"id\":\"available\",\"value\":true}]},\"systime\":1700510795,\"seq\":1,\"error\":false}' -- New API version\n\n apiResult = '{\"ok\":true,\"type\":\"response\",\"time\":0.0026876579795498,\"rv\":{\"propsval\":[{\"id\":\"name\",\"value\":\"EnergieDirect\"},{\"id\":\"metertype\",\"value\":\"XMX\"},{\"id\":\"version\",\"value\":\"5\"},{\"id\":\"serial_e\",\"value\":\"4999999999999999999999666666666666\"},{\"id\":\"usage\",\"value\":501},{\"id\":\"T1\",\"value\":17157.847},{\"id\":\"T2\",\"value\":8929.761},{\"id\":\"-T1\",\"value\":7770.154},{\"id\":\"-T2\",\"value\":17361.077},{\"id\":\"L1I\",\"value\":1},{\"id\":\"L2I\",\"value\":1},{\"id\":\"L3I\",\"value\":2},{\"id\":\"L1Pimp\",\"value\":0.189},{\"id\":\"L2Pimp\",\"value\":0},{\"id\":\"L3Pimp\",\"value\":0.312},{\"id\":\"L1Pexp\",\"value\":0},{\"id\":\"L2Pexp\",\"value\":0},{\"id\":\"L3Pexp\",\"value\":0},{\"id\":\"c_tariff\",\"value\":2},{\"id\":\"serial_g\",\"value\":\"4999999999999999999999999999999996\"},{\"id\":\"gas_usage\",\"value\":0},{\"id\":\"gas\",\"value\":5795.05},{\"id\":\"Cost-T1\",\"value\":0.36789},{\"id\":\"Cost-T2\",\"value\":0.37031},{\"id\":\"Cost-nT1\",\"value\":0.36789},{\"id\":\"Cost-nT2\",\"value\":0.37031},{\"id\":\"netting\",\"value\":\"off\"},{\"id\":\"Cost-net-comp\",\"value\":0},{\"id\":\"Cost-gas\",\"value\":1.2987},{\"id\":\"Gas-interval\",\"value\":3600},{\"id\":\"Client-blob\",\"value\":\"\"},{\"id\":\"crc_err\",\"value\":2},{\"id\":\"available\",\"value\":true}]},\"systime\":1701084126,\"seq\":1,\"error\":false}' -- New (November 2023) API version with extra L1U, L2U and L3U\n\n --apiResult = '{\"ok\":true,\"type\":\"response\",\"time\":0.0039377399953082,\"rv\":{\"propsval\":[{\"id\":\"name\",\"value\":\"Kosten\"},{\"id\":\"metertype\",\"value\":\"Ene\"},{\"id\":\"version\",\"value\":\"5\"},{\"id\":\"serial_e\",\"value\":\"4999999999999999999999666666666666\"},{\"id\":\"usage\",\"value\":489},{\"id\":\"T1\",\"value\":8945.53},{\"id\":\"T2\",\"value\":4963.677},{\"id\":\"-T1\",\"value\":2051.765},{\"id\":\"-T2\",\"value\":6024.202},{\"id\":\"L1I\",\"value\":3},{\"id\":\"L1Pimp\",\"value\":0.489},{\"id\":\"L1Pexp\",\"value\":0},{\"id\":\"c_tariff\",\"value\":1},{\"id\":\"serial_g\",\"value\":\"4999999999999999999999999999999996\"},{\"id\":\"gas_usage\",\"value\":0},{\"id\":\"gas\",\"value\":3143.767},{\"id\":\"Cost-T1\",\"value\":0.18875},{\"id\":\"Cost-T2\",\"value\":0.18875},{\"id\":\"Cost-nT1\",\"value\":0.18875},{\"id\":\"Cost-nT2\",\"value\":0.18875},{\"id\":\"Cost-gas\",\"value\":0.64413},{\"id\":\"Gas-interval\",\"value\":300},{\"id\":\"Client-blob\",\"value\":\"\"},{\"id\":\"available\",\"value\":true}]},\"systime\":1611347255,\"seq\":1,\"error\":false}' -- Iungo Monitor Lite/Basic version\n \n jsonTableMonitor = json.decode(apiResult) -- Decode the json string from api to lua-table Monitor\n self:valuesMonitor() -- Get the values from Monitor json file\n self:updateLabels() -- Update the labels\n self:updateProperties() -- Update the propterties\n self:updateChildDevices() -- Update the Child Devices\n if solarPanel then\n currentMethod = methodSolar\n elseif gasMeterAnalog then\n currentMethod = methodGas\n elseif waterMeter then\n currentMethod = methodWater\n end\n \n elseif currentMethod == methodSolar then\n apiResult = '{\"ok\":true,\"type\":\"response\",\"time\":0.0016563490498811,\"rv\":{\"propsval\":[{\"id\":\"name\",\"value\":\"20 panelen\"},{\"id\":\"solar\",\"value\":500.4},{\"id\":\"pulstotal\",\"value\":16575341},{\"id\":\"ppkwh\",\"value\":800},{\"id\":\"offset\",\"value\":292.07},{\"id\":\"connection\",\"value\":\"breakout\"},{\"id\":\"functiongroup\",\"value\":\"solar\"}]},\"systime\":1611237657,\"seq\":1,\"error\":false}' -- Iungo Solarpanel \n jsonTableSolar = json.decode(apiResult) -- Decode the json string lua-table Solarpanel\n self:valuesSolar() -- Get the values from Solar json file\n self:updateLabels() -- Update the labels\n self:updateChildDevices() -- Update the Child Devices\n if gasMeterAnalog then\n currentMethod = methodGas\n elseif waterMeter then \n currentMethod = methodWater\n else\n currentMethod = methodMonitor\n end\n\n elseif currentMethod == methodGas then\n apiResult = '{\"ok\":true,\"type\":\"response\",\"time\":0.0018438370898366,\"rv\":{\"propsval\":[{\"id\":\"name\",\"value\":\"-\"},{\"id\":\"gas_usage\",\"value\":1},{\"id\":\"gas\",\"value\":5005.31},{\"id\":\"Cost-gas\",\"value\":0.74},{\"id\":\"Gas-digits\",\"value\":100},{\"id\":\"GAS-rotations\",\"value\":385780},{\"id\":\"GAS-offset\",\"value\":1147.51},{\"id\":\"fw-version\",\"value\":\"3.2\"},{\"id\":\"Client-blob\",\"value\":\"\"},{\"id\":\"available\",\"value\":true}]},\"systime\":1637350411,\"seq\":1,\"error\":false}' -- Iungo Analog Gas Meter\n jsonTableGas = json.decode(apiResult) -- Decode the json string lua-table Analog Gasmeter\n self:valuesGas() -- Get the values from Analog Gas json file\n self:updateLabels() -- Update the labels\n self:updateChildDevices() -- Update the Child Devices\n currentMethod = methodMonitor\n\n elseif currentMethod == methodWater then\n apiResult = '{\"ok\":true,\"type\":\"response\",\"time\":0.0010625629220158,\"rv\":{\"propsval\":[{\"id\":\"name\",\"value\":\"Water\"},{\"id\":\"flow\",\"value\":2},{\"id\":\"pulstotal\",\"value\":456523},{\"id\":\"kfact\",\"value\":1000},{\"id\":\"offset\",\"value\":-47.091},{\"id\":\"tariff\",\"value\":0.9616},{\"id\":\"connection\",\"value\":\"breakout_ch2\"}]},\"systime\":1611765184,\"seq\":1,\"error\":false}' -- Iungo Watermeter \n jsonTableWater = json.decode(apiResult) -- Decode the json string lua-table Watermeter\n self:valuesWater() -- Get the values from Water json file\n self:updateLabels() -- Update the labels\n self:updateChildDevices() -- Update the Child Devices\n if gasMeterAnalog then\n currentMethod = methodGas\n else\n currentMethod = methodMonitor\n end\n\n else\n self:warning(\"No Monitor, Solar Water or Analog Gas active\")\n return \n end\n\n self:logging(3,\"setTimeout \" ..interval ..\" seconds\")\n fibaro.setTimeout(interval*1000, function() -- Checks every [interval] seconds for new data\n self:simData()\n end)\nend \n\n\nfunction QuickApp:createVariables() -- Create Variables\n self:logging(3,\"createVariables() - Create Variables\")\n Path = \"/iungo/api_request\" -- Default Path\n methodMonitor = '{\"seq\":1,\"method\":\"object_list_props_values\",\"arguments\":{\"oid\":\"' ..monitorOID ..'\"}}' -- Default Method for Iungo Monitor\n methodSolar = '{\"seq\":1,\"method\":\"object_list_props_values\",\"arguments\":{\"oid\":\"' ..solarOID ..'\"}}' -- Default Method for Iungo Solarpanel\n methodWater = '{\"seq\":1,\"method\":\"object_list_props_values\",\"arguments\":{\"oid\":\"' ..waterOID ..'\"}}' -- Default Method for Iungo Watermeter\n methodGas = '{\"seq\":1,\"method\":\"object_list_props_values\",\"arguments\":{\"oid\":\"' ..gasAnalogOID ..'\"}}' -- Default Method for Iungo Analog Gasmeter\n currentMethod = methodMonitor -- Set default Method to Iungo Monitor Method\n \n data = {}\n data.grid_consumption = \"0\"\n data.house_consumption = \"0\"\n data.consumption = \"0\" \n data.consumption_low = \"0\" \n data.consumption_high = \"0\" \n data.production_low = \"0\" \n data.production_high = \"0\" \n data.cost_consumption_low = \"0\" \n data.cost_consumption_high = \"0\" \n data.cost_production_low = \"0\" \n data.cost_production_high = \"0\" \n data.L1_A = \"0\" \n data.L2_A = \"0\" \n data.L3_A = \"0\" \n data.L1_V = \"0\" \n data.L2_V = \"0\" \n data.L3_V = \"0\" \n data.L1_imp = \"0\"\n data.L2_imp = \"0\"\n data.L3_imp = \"0\"\n data.L1_exp = \"0\"\n data.L2_exp = \"0\"\n data.L3_exp = \"0\"\n data.consumption_gas = \"0\" \n data.gas = \"0\" \n data.cost_gas = \"0\" \n \n data.tarifcode = \"\"\n data.total_consumption = \"0\" \n data.total_production = \"0\" \n data.total_netting = \"0\" \n \n data.solar = \"0\"\n data.solarPower = \"0\" \n data.tarifcodeText = \" \"\n data.meterreading = \"0\"\n data.meterreadingUnit = \" \"\n\n data.GASrotations = \"0\"\n data.Gasdigits = \"0\"\n data.GASoffset = \"0\"\n\n data.flow = \"0\"\n data.wused = \"0\"\n data.pulstotal = \"0\"\n data.ppkwh = \"0\"\n data.offset = \"0\"\n data.kfact = \"0\"\n \n data.name = \" \"\n data.metertype = \" \"\n data.version = \" \"\n data.serialE = \" \" \n data.serialG = \" \" \nend\n\n\nfunction QuickApp:getQuickAppVariables() -- Get all getQuickApp Variables or create them\n IPaddress = self:getVariable(\"IPaddress\")\n interval = tonumber(self:getVariable(\"interval\")) \n debugLevel = tonumber(self:getVariable(\"debugLevel\"))\n local language = string.lower(self:getVariable(\"language\"))\n solarPanel = string.lower(self:getVariable(\"solarPanel\"))\n waterMeter = string.lower(self:getVariable(\"waterMeter\"))\n gasMeterAnalog = string.lower(self:getVariable(\"gasMeterAnalog\"))\n solarM2 = tonumber(self:getVariable(\"solarM2\"))\n monitorOID = self:getVariable(\"monitorOID\")\n solarOID = self:getVariable(\"solarOID\")\n gasAnalogOID = self:getVariable(\"gasAnalogOID\")\n waterOID = self:getVariable(\"waterOID\")\n meterEnergyD = self:getVariable(\"meterEnergyD\")\n meterConsHigh = tonumber(self:getVariable(\"meterConsHigh\"))\n meterConsLow = tonumber(self:getVariable(\"meterConsLow\"))\n meterProdHigh = tonumber(self:getVariable(\"meterProdHigh\"))\n meterProdLow = tonumber(self:getVariable(\"meterProdLow\"))\n meterGasD = self:getVariable(\"meterGasD\")\n meterGas = tonumber(self:getVariable(\"meterGas\"))\n meterWaterD = self:getVariable(\"meterWaterD\")\n meterWater = tonumber(self:getVariable(\"meterWater\"))\n\n\n -- Check existence of the mandatory variables, if not, create them with default values \n if IPaddress == \"\" or IPaddress == nil then \n IPaddress = \"192.168.178.12\" -- Default IPaddress of Iungo Monitor\n self:setVariable(\"IPaddress\", IPaddress)\n self:trace(\"Added QuickApp variable IPaddress\")\n end\n if interval == \"\" or interval == nil then\n interval = \"10\" -- Default interval in seconds (The Iungo meter normally reads every 10 seconds)\n self:setVariable(\"interval\", interval)\n self:trace(\"Added QuickApp variable interval\")\n interval = tonumber(interval)\n end\n if debugLevel == \"\" or debugLevel == nil then\n debugLevel = \"4\" -- Default value for debugLevel is \"4\"\n self:setVariable(\"debugLevel\",debugLevel)\n self:trace(\"Added QuickApp variable debugLevel\")\n debugLevel = tonumber(debugLevel)\n end\n if language == \"\" or language == nil or type(i18n:translation(string.lower(self:getVariable(\"language\")))) ~= \"table\" then\n language = \"en\" \n self:setVariable(\"language\",language)\n self:trace(\"Added QuickApp variable language\")\n translation = i18n:translation(string.lower(self:getVariable(\"language\"))) -- (Extra) Initialise the translation because of early createVariables()\n end\n if solarPanel == \"\" or solarPanel == nil then \n solarPanel = \"false\" -- Default availability of solarPanel is \"false\"\n self:setVariable(\"solarPanel\",solarPanel)\n self:trace(\"Added QuickApp variable solarPanel\")\n end \n if gasMeterAnalog == \"\" or gasMeterAnalog == nil then \n gasMeterAnalog = \"false\" -- Default availability of gasMeterAnalog is \"false\"\n self:setVariable(\"gasMeterAnalog\",gasMeterAnalog)\n self:trace(\"Added QuickApp variable gasMeterAnalog\")\n end \n if waterMeter == \"\" or waterMeter == nil then \n waterMeter = \"false\" -- Default availability of waterMeter is \"false\"\n self:setVariable(\"waterMeter\",waterMeter)\n self:trace(\"Added QuickApp variable waterMeter\")\n end \n if solarM2 == \"\" or solarM2 == nil then \n solarM2 = \"0\" -- How much m2 Solar Panels, default is 0\n self:setVariable(\"solarM2\",solarM2)\n self:trace(\"Added QuickApp variable solarM2\")\n end\n if monitorOID == \"\" or monitorOID == nil then \n monitorOID = \"538d72d9\" -- ObjectID of the monitor\n self:setVariable(\"monitorOID\",monitorOID)\n self:trace(\"Added QuickApp variable monitorOID\")\n end\n if solarOID == \"\" or solarOID == nil then \n solarOID = \"95778a43\" -- ObjectID of the solar monitor\n self:setVariable(\"solarOID\",solarOID)\n self:trace(\"Added QuickApp variable solarOID\")\n end\n if gasAnalogOID == \"\" or gasAnalogOID == nil then \n gasAnalogOID = \"06e869e1\" -- ObjectID of the analog gas meter\n self:setVariable(\"gasAnalogOID\",gasAnalogOID)\n self:trace(\"Added QuickApp variable gasAnalogOID\")\n end\n if waterOID == \"\" or waterOID == nil then \n waterOID = \"82ec52ad\" -- ObjectID of the water meter\n self:setVariable(\"waterOID\",waterOID)\n self:trace(\"Added QuickApp variable waterOID\")\n end\n if meterConsHigh == \"\" or meterConsHigh == nil then \n meterConsHigh = \"0\" \n self:setVariable(\"meterConsHigh\", meterConsHigh)\n self:trace(\"Added QuickApp variable meterConsHigh\")\n meterConsHigh = tonumber(meterConsHigh)\n end\n if meterConsLow == \"\" or meterConsLow == nil then \n meterConsLow = \"0\" \n self:setVariable(\"meterConsLow\", meterConsLow)\n self:trace(\"Added QuickApp variable meterConsLow\")\n meterConsLow = tonumber(meterConsLow)\n end \n if meterProdHigh == \"\" or meterProdHigh == nil then \n meterProdHigh = \"0\" \n self:setVariable(\"meterProdHigh\", meterProdHigh)\n self:trace(\"Added QuickApp variable meterProdHigh\")\n meterProdHigh = tonumber(meterProdHigh)\n end \n if meterProdLow == \"\" or meterProdLow == nil then \n meterProdLow = \"0\" \n self:setVariable(\"meterProdLow\", meterProdLow)\n self:trace(\"Added QuickApp variable meterProdLow\")\n meterProdLow = tonumber(meterProdLow)\n end \n if meterGas == \"\" or meterGas == nil then \n meterGas = \"0\" \n self:setVariable(\"meterGas\", meterGas)\n self:trace(\"Added QuickApp variable meterGas\")\n meterGas = tonumber(meterGas)\n end \n if meterWater == \"\" or meterWater == nil then \n meterWater = \"0\" \n self:setVariable(\"meterWater\", meterWater)\n self:trace(\"Added QuickApp variable meterWater\")\n meterWater = tonumber(meterWater)\n end \n if meterEnergyD == \"\" or meterEnergyD == nil then \n meterEnergyD = \"00-00-0000\" \n self:setVariable(\"meterEnergyD\", meterEnergyD)\n self:trace(\"Added QuickApp variable meterEnergyD\")\n end \n if meterGasD == \"\" or meterGasD == nil then \n meterGasD = \"00-00-0000\" \n self:setVariable(\"meterGasD\", meterGasD)\n self:trace(\"Added QuickApp variable meterGasD\")\n end \n if meterWaterD == \"\" or meterWaterD == nil then \n meterWaterD = \"00-00-0000\" \n self:setVariable(\"meterWaterD\", meterWaterD)\n self:trace(\"Added QuickApp variable meterWaterD\")\n end \n \n if solarPanel == \"true\" then \n solarPanel = true \n else\n solarPanel = false\n end\n if gasMeterAnalog == \"true\" then \n gasMeterAnalog = true \n else\n gasMeterAnalog = false\n end\n if waterMeter == \"true\" then \n waterMeter = true \n else\n waterMeter = false\n end\n\n if meterEnergyD == \"0\" or meterEnergyD == \"00-00-0000\" then\n meterEnergyD = \"\"\n else \n meterEnergyD = translation[\"Since\"] ..\": \" ..meterEnergyD\n end\n if meterGasD == \"0\" or meterGasD == \"00-00-0000\" then\n meterGasD = \"\"\n else\n meterGasD = translation[\"Since\"] ..\": \" ..meterGasD\n end\n if meterWaterD == \"0\" or meterWaterD == \"00-00-0000\" then\n meterWaterD = \"\"\n else \n meterWaterD = translation[\"Since\"] ..\": \" ..meterWaterD\n end\n \n local sum = 1\n if solarPanel then\n sum = sum+1\n end\n if waterMeter then\n sum = sum+1\n end\n if gasMeterAnalog then\n sum = sum+1\n end\n interval = tonumber(string.format(\"%.3f\", interval / sum))\n self:logging(3,\"Interval: \" ..tostring(interval))\nend\n\n\nfunction QuickApp:updateChildDevices()\n for id,child in pairs(self.childDevices) do -- Update Child Devices\n child:updateValue(data) \n end\nend\n\n\nfunction QuickApp:setupChildDevices() -- Setup Child Devices\n local cdevs = api.get(\"/devices?parentId=\"..self.id) or {} -- Pick up all Child Devices\n function self:initChildDevices() end -- Null function, else Fibaro calls it after onInit()...\n\n if #cdevs == 0 then -- If no Child Devices, create them\n local initChildData = { \n {className=\"consumption\", name=\"Consumption\", type=\"com.fibaro.powerMeter\", value=0},\n {className=\"production\", name=\"Production\", type=\"com.fibaro.powerMeter\", value=0},\n {className=\"solarPower\", name=\"Solar Power\", type=\"com.fibaro.powerMeter\", value=0},\n {className=\"gas_usage\", name=\"Gas usage\", type=\"com.fibaro.gasMeter\", value=0},\n {className=\"waterflow\", name=\"Water Flow\", type=\"com.fibaro.waterMeter\", value=0},\n {className=\"consumption_high\", name=\"Consumption High\", type=\"com.fibaro.energyMeter\", value=0},\n {className=\"consumption_low\", name=\"Consumption Low\", type=\"com.fibaro.energyMeter\", value=0},\n {className=\"production_high\", name=\"Production High\", type=\"com.fibaro.energyMeter\", value=0},\n {className=\"production_low\", name=\"Production Low\", type=\"com.fibaro.energyMeter\", value=0},\n {className=\"netting\", name=\"Total Netting\", type=\"com.fibaro.powerMeter\", value=0},\n {className=\"gas\", name=\"Total Gas\", type=\"com.fibaro.gasMeter\", value=0},\n {className=\"total_waterflow\", name=\"Total Water Flow\", type=\"com.fibaro.waterMeter\", value=0},\n {className=\"L1_A\", name=\"Ampere L1\", type=\"com.fibaro.electricMeter\", value=0},\n {className=\"L2_A\", name=\"Ampere L2\", type=\"com.fibaro.electricMeter\", value=0},\n {className=\"L3_A\", name=\"Ampere L3\", type=\"com.fibaro.electricMeter\", value=0},\n {className=\"L1_V\", name=\"Voltage L1\", type=\"com.fibaro.electricMeter\", value=0},\n {className=\"L2_V\", name=\"Voltage L2\", type=\"com.fibaro.electricMeter\", value=0},\n {className=\"L3_V\", name=\"Voltage L3\", type=\"com.fibaro.electricMeter\", value=0},\n {className=\"L1_imp\", name=\"Import L1\", type=\"com.fibaro.powerMeter\", value=0},\n {className=\"L2_imp\", name=\"Import L2\", type=\"com.fibaro.powerMeter\", value=0},\n {className=\"L3_imp\", name=\"Import L3\", type=\"com.fibaro.powerMeter\", value=0},\n {className=\"L1_exp\", name=\"Export L1\", type=\"com.fibaro.powerMeter\", value=0},\n {className=\"L2_exp\", name=\"Export L2\", type=\"com.fibaro.powerMeter\", value=0},\n {className=\"L3_exp\", name=\"Export L3\", type=\"com.fibaro.powerMeter\", value=0},\n }\n for _,c in ipairs(initChildData) do\n local child = self:createChildDevice(\n {name = c.name,\n type=c.type,\n value=c.value,\n unit=c.unit,\n initialInterfaces = {},\n },\n _G[c.className] -- Fetch class constructor from class name\n )\n child:setVariable(\"className\",c.className) -- Save class name so we know when we load it next time\n end \n else \n for _,child in ipairs(cdevs) do\n local className = getChildVariable(child,\"className\") -- Fetch child class name\n local childObject = _G[className](child) -- Create child object from the constructor name\n self.childDevices[child.id]=childObject\n childObject.parent = self -- Setup parent link to device controller \n end\n end\nend\n\n\nfunction QuickApp:onInit() -- Let's get started\n __TAG = fibaro.getName(plugin.mainDeviceId) ..\" ID:\" ..plugin.mainDeviceId\n self:debug(\"onInit Iungo Monitor - Version \"..version..\" - ⓒ by SmartHomeEddy\")\n \n self:setupChildDevices()\n \n if not api.get(\"/devices/\"..self.id).enabled then\n self:warning(\"Device\", fibaro.getName(plugin.mainDeviceId), \"is disabled\")\n return\n end\n \n self:getQuickAppVariables() -- Get QuickApp Variables\n self:createVariables() -- Create all Variables\n\n self.http = net.HTTPClient({timeout=3000})\n \n if tonumber(debugLevel) >= 4 then \n self:simData() -- Go in simulation\n else\n self:getData() -- Get data from Iungo Monitor, Solarpanel, Watermeter and or Analog Gasmeter\n end\nend\n\n-- EOF "},{"name":"i18n","isMain":false,"isOpen":false,"content":"-- Quickapp Iungo Monitor i18n translation\n\n\nclass \"i18n\"\nfunction i18n:translation(language)\n translation = {\n en = {\n [\"SIMULATION MODE\"] = \"SIMULATION MODE\", \n [\"House\"] = \"House\", \n [\"tarif\"] = \"tarif\", \n [\"Grid Consumption\"] = \"Grid Consumption\", \n [\"Energy\"] = \"Energy\", \n [\"Netting\"] = \"Netting\", \n [\"Consumption\"] = \"Consumption\", \n [\"Production\"] = \"Production\", \n [\"Water\"] = \"Water\", \n [\"Waterflow\"] = \"Waterflow\", \n [\"Totals\"] = \"Totals\", \n [\"total\"] = \"total\", \n [\"low\"] = \"low\", \n [\"high\"] = \"high\", \n [\"Solar\"] = \"Solar\", \n [\"Panels\"] = \"Panels\", \n [\"Power\"] = \"Power\", \n [\"Gas\"] = \"Gas\", \n [\"Water\"] = \"Water\", \n [\"L1\"] = \"L1\", \n [\"L2\"] = \"L2\", \n [\"L3\"] = \"L3\", \n [\"Ampere\"] = \"Ampere\", \n [\"Voltage\"] = \"Voltage\", \n [\"Import\"] = \"Import\", \n [\"Export\"] = \"Export\", \n [\"Amp\"] = \"Amp\", \n [\"Volt\"] = \"Volt\", \n [\"Max\"] = \"Max\", \n [\"L/min\"] = \"L/min\", \n [\"High\"] = \"High\", \n [\"Low\"] = \"Low\", \n [\"Since\"] = \"Since\", \n [\"Meter\"] = \"Meter\", \n [\"Lasthour\"] = \"Lasthour\", \n [\"Updated\"] = \"Updated\"},\n nl = {\n [\"SIMULATION MODE\"] = \"SIMULATIEMODUS\", \n [\"House\"] = \"Huis\", \n [\"tarif\"] = \"tarief\", \n [\"Grid Consumption\"] = \"Netverbruik\", \n [\"Energy\"] = \"Energie\", \n [\"Netting\"] = \"Saldering\", \n [\"Consumption\"] = \"Consumptie\", \n [\"Production\"] = \"Productie\", \n [\"Water\"] = \"Water\", \n [\"Waterflow\"] = \"Waterstroom\", \n [\"Totals\"] = \"Totalen\", \n [\"total\"] = \"totaal\", \n [\"low\"] = \"laag\", \n [\"high\"] = \"hoog\", \n [\"Solar\"] = \"Zon\",\n [\"Panels\"] = \"Panelen\", \n [\"Power\"] = \"Stroom\", \n [\"Gas\"] = \"Gas\", \n [\"Water\"] = \"Water\", \n [\"L1\"] = \"L1\", \n [\"L2\"] = \"L2\", \n [\"L3\"] = \"L3\", \n [\"Ampere\"] = \"Ampère\", \n [\"Voltage\"] = \"Spanning\", \n [\"Import\"] = \"Import\", \n [\"Export\"] = \"Export\", \n [\"Amp\"] = \"Amp\", \n [\"Volt\"] = \"Volt\", \n [\"Max\"] = \"Max\", \n [\"L/min\"] = \"L/min\", \n [\"High\"] = \"Hoog\", \n [\"Low\"] = \"Laag\", \n [\"Since\"] = \"Sinds\", \n [\"Meter\"] = \"Meter\", \n [\"Lasthour\"] = \"Afgelopen uur\", \n [\"Updated\"] = \"Bijgewerkt\"},\n fr = {\n [\"SIMULATION MODE\"] = \"MODE SIMULATION\", \n [\"House\"] = \"Maison\", \n [\"tarif\"] = \"tarif\", \n [\"Grid Consumption\"] = \"Consommation du réseau\", \n [\"Energy\"] = \"Énergie\", \n [\"Netting\"] = \"Filets\", \n [\"Consumption\"] = \"Consommation\", \n [\"Production\"] = \"Production\", \n [\"Water\"] = \"Eau\", \n [\"Waterflow\"] = \"L'écoulement de l'eau\", \n [\"Totals\"] = \"Totaux\", \n [\"total\"] = \"totale\", \n [\"low\"] = \"faible\", \n [\"high\"] = \"élevée\", \n [\"Solar\"] = \"Solaire\", \n [\"Panels\"] = \"Panneaux\",\n [\"Power\"] = \"Pouvoir\", \n [\"Gas\"] = \"Gaz\", \n [\"Water\"] = \"L'eau\", \n [\"L1\"] = \"L1\", \n [\"L2\"] = \"L2\", \n [\"L3\"] = \"L3\", \n [\"Ampere\"] = \"Ampère\", \n [\"Voltage\"] = \"Voltage\", \n [\"Import\"] = \"Importer\", \n [\"Export\"] = \"Exporter\", \n [\"Amp\"] = \"Amp\", \n [\"Volt\"] = \"Volt\", \n [\"Max\"] = \"Max\", \n [\"L/min\"] = \"L/min\", \n [\"High\"] = \"Élevé\", \n [\"Low\"] = \"Faible\", \n [\"Since\"] = \"Depuis\", \n [\"Meter\"] = \"Mètre\", \n [\"Lasthour\"] = \"Dernière heure\", \n [\"Updated\"] = \"Actualisé\"},\n pl = {\n [\"SIMULATION MODE\"] = \"TRYB SYMULACYJNY\", \n [\"House\"] = \"Dom\", \n [\"tarif\"] = \"taryfa\", \n [\"Grid Consumption\"] = \"Zużycie sieci\", \n [\"Energy\"] = \"Energia\", \n [\"Netting\"] = \"Siatka\", \n [\"Consumption\"] = \"Konsumpcja\", \n [\"Production\"] = \"Produkcja\", \n [\"Water\"] = \"Woda\", \n [\"Waterflow\"] = \"Przepływ wody\", \n [\"Totals\"] = \"Sumy\", \n [\"total\"] = \"całkowity\", \n [\"low\"] = \"niska\", \n [\"high\"] = \"wysoka\", \n [\"Solar\"] = \"Słoneczny\",\n [\"Panels\"] = \"Panele\",\n [\"Power\"] = \"Moc\", \n [\"Gas\"] = \"Gaz\", \n [\"Water\"] = \"Woda\", \n [\"L1\"] = \"L1\", \n [\"L2\"] = \"L2\", \n [\"L3\"] = \"L3\", \n [\"Ampere\"] = \"Amper\", \n [\"Voltage\"] = \"Woltaż\", \n [\"Import\"] = \"Import\", \n [\"Export\"] = \"Eksport\", \n [\"Amp\"] = \"Amp\", \n [\"Volt\"] = \"Woltaż\", \n [\"Max\"] = \"Max\", \n [\"L/min\"] = \"L/min\", \n [\"High\"] = \"Wysoki\", \n [\"Low\"] = \"Niski\", \n [\"Since\"] = \"Od\", \n [\"Meter\"] = \"Metr\", \n [\"Lasthour\"] = \"Ostatnia godzina\", \n [\"Updated\"] = \"Zaktualizowano\"},\n } \n translation = translation[language] -- Shorten the table to only the current translation\n return translation\nend\n\n-- EOF "},{"name":"childs","isMain":false,"isOpen":false,"content":"-- Iungo Monitor childs\n\n\nclass 'consumption'(QuickAppChild)\nfunction consumption:__init(dev)\n QuickAppChild.__init(self,dev)\nend\nfunction consumption:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.0f\", data.consumption)))\n self:updateProperty(\"power\", tonumber(string.format(\"%.0f\", data.consumption)))\n self:updateProperty(\"unit\", \"Watt\")\n self:updateProperty(\"log\", \" \")\nend\n\n\nclass 'production'(QuickAppChild)\nfunction production:__init(dev)\n QuickAppChild.__init(self,dev)\nend\nfunction production:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.0f\", data.solar)))\n self:updateProperty(\"power\", tonumber(string.format(\"%.0f\", data.solar)))\n self:updateProperty(\"unit\", \"Watt\")\n self:updateProperty(\"log\", data.meterreading ..\" \" ..data.meterreadingUnit)\nend\n\n\nclass 'solarPower'(QuickAppChild)\nfunction solarPower:__init(dev)\n QuickAppChild.__init(self,dev)\nend\nfunction solarPower:updateValue(data) \n self:updateProperty(\"value\", tonumber(data.solarPower))\n self:updateProperty(\"power\", tonumber(data.solarPower))\n self:updateProperty(\"unit\", \"Watt/m²\")\n self:updateProperty(\"log\", solarM2 ..\" m² \" ..translation[\"Panels\"])\nend\n\n\nclass 'gas_usage'(QuickAppChild)\nfunction gas_usage:__init(dev)\n QuickAppChild.__init(self,dev)\nend\nfunction gas_usage:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.0f\",data.consumption_gas)))\n self:updateProperty(\"unit\", \"L/min\")\n self:updateProperty(\"log\", \" \")\nend\n\n\nclass 'waterflow'(QuickAppChild)\nfunction waterflow:__init(dev)\n QuickAppChild.__init(self,dev)\nend\nfunction waterflow:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.0f\",data.flow)))\n self:updateProperty(\"unit\", \"L/min\")\n self:updateProperty(\"log\", \" \")\nend\n\n\nclass 'consumption_high'(QuickAppChild)\nfunction consumption_high:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"consumption\" then \n self:updateProperty(\"rateType\", \"consumption\")\n self:warning(\"Changed rateType interface of Consumption High child device (\" ..self.id ..\") to consumption\")\n end\nend\nfunction consumption_high:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.3f\",data.consumption_high)))\n self:updateProperty(\"unit\", \"kWh\")\n self:updateProperty(\"log\", meterEnergyD)\nend\n\n\nclass 'consumption_low'(QuickAppChild)\nfunction consumption_low:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"consumption\" then \n self:updateProperty(\"rateType\", \"consumption\")\n self:warning(\"Changed rateType interface of Consumption High child device (\" ..self.id ..\") to consumption\")\n end\nend\nfunction consumption_low:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.3f\",data.consumption_low)))\n self:updateProperty(\"unit\", \"kWh\")\n self:updateProperty(\"log\", meterEnergyD)\nend\n\n\nclass 'production_high'(QuickAppChild)\nfunction production_high:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"production\" then \n self:updateProperty(\"rateType\", \"production\")\n self:warning(\"Changed rateType interface of Production High child device (\" ..self.id ..\") to production\")\n end\nend\nfunction production_high:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.3f\",data.production_high)))\n self:updateProperty(\"unit\", \"kWh\")\n self:updateProperty(\"log\", meterEnergyD)\nend\n\n\nclass 'production_low'(QuickAppChild)\nfunction production_low:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"production\" then \n self:updateProperty(\"rateType\", \"production\")\n self:warning(\"Changed rateType interface of Production High child device (\" ..self.id ..\") to production\")\n end\nend\nfunction production_low:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.3f\",data.production_low)))\n self:updateProperty(\"unit\", \"kWh\")\n self:updateProperty(\"log\", meterEnergyD)\nend\n\n\nclass 'netting'(QuickAppChild)\nfunction netting:__init(dev)\n QuickAppChild.__init(self,dev)\nend\nfunction netting:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.0f\", data.total_netting)))\n self:updateProperty(\"power\", tonumber(string.format(\"%.0f\", data.total_netting)))\n self:updateProperty(\"unit\", \"kWh\")\n self:updateProperty(\"log\", meterEnergyD)\nend\n\n\nclass 'gas'(QuickAppChild)\nfunction gas:__init(dev)\n QuickAppChild.__init(self,dev)\nend\nfunction gas:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.3f\",data.gas)))\n self:updateProperty(\"unit\", \"m³\")\n self:updateProperty(\"log\", meterGasD)\nend\n\n\nclass 'total_waterflow'(QuickAppChild)\nfunction total_waterflow:__init(dev)\n QuickAppChild.__init(self,dev)\nend\nfunction total_waterflow:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.3f\",data.wused)))\n self:updateProperty(\"unit\", \"m³\")\n self:updateProperty(\"log\", meterWaterD)\nend\n\n\nclass 'L1_A'(QuickAppChild)\nfunction L1_A:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"consumption\" then \n self:updateProperty(\"rateType\", \"consumption\")\n self:warning(\"Changed rateType interface of Todays Consumption child device (\" ..self.id ..\") to consumption\")\n end\nend\nfunction L1_A:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.1f\",data.L1_A)))\n self:updateProperty(\"unit\", translation[\"Amp\"])\n self:updateProperty(\"log\", \"\")\nend\n\n\nclass 'L2_A'(QuickAppChild)\nfunction L2_A:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"consumption\" then \n self:updateProperty(\"rateType\", \"consumption\")\n self:warning(\"Changed rateType interface of Todays Consumption child device (\" ..self.id ..\") to consumption\")\n end\nend\nfunction L2_A:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.1f\",data.L2_A)))\n self:updateProperty(\"unit\", translation[\"Amp\"])\n self:updateProperty(\"log\", \"\")\nend\n\n\nclass 'L3_A'(QuickAppChild)\nfunction L3_A:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"consumption\" then \n self:updateProperty(\"rateType\", \"consumption\")\n self:warning(\"Changed rateType interface of Todays Consumption child device (\" ..self.id ..\") to consumption\")\n end\nend\nfunction L3_A:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.1f\",data.L3_A)))\n self:updateProperty(\"unit\", translation[\"Amp\"])\n self:updateProperty(\"log\", \"\")\nend\n\n\nclass 'L1_V'(QuickAppChild)\nfunction L1_V:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"consumption\" then \n self:updateProperty(\"rateType\", \"consumption\")\n self:warning(\"Changed rateType interface of Todays Consumption child device (\" ..self.id ..\") to consumption\")\n end\nend\nfunction L1_V:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.0f\",data.L1_V)))\n self:updateProperty(\"unit\", translation[\"Volt\"])\n self:updateProperty(\"log\", \"\")\nend\n\n\nclass 'L2_V'(QuickAppChild)\nfunction L2_V:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"consumption\" then \n self:updateProperty(\"rateType\", \"consumption\")\n self:warning(\"Changed rateType interface of Todays Consumption child device (\" ..self.id ..\") to consumption\")\n end\nend\nfunction L2_V:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.0f\",data.L2_V)))\n self:updateProperty(\"unit\", translation[\"Volt\"])\n self:updateProperty(\"log\", \"\")\nend\n\n\nclass 'L3_V'(QuickAppChild)\nfunction L3_V:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"consumption\" then \n self:updateProperty(\"rateType\", \"consumption\")\n self:warning(\"Changed rateType interface of Todays Consumption child device (\" ..self.id ..\") to consumption\")\n end\nend\nfunction L3_V:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.0f\",data.L3_V)))\n self:updateProperty(\"unit\", translation[\"Volt\"])\n self:updateProperty(\"log\", \"\")\nend\n\n\nclass 'L1_imp'(QuickAppChild)\nfunction L1_imp:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"production\" then \n self:updateProperty(\"rateType\", \"production\")\n self:warning(\"Changed rateType interface of Todays Production child device (\" ..self.id ..\") to production\")\n end\nend\nfunction L1_imp:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.3f\",data.L1_imp)))\n self:updateProperty(\"power\", tonumber(string.format(\"%.3f\",data.L1_imp)))\n self:updateProperty(\"unit\", \"kW\")\n self:updateProperty(\"log\", \" \")\nend\n\n\nclass 'L2_imp'(QuickAppChild)\nfunction L2_imp:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"production\" then \n self:updateProperty(\"rateType\", \"production\")\n self:warning(\"Changed rateType interface of Todays Production child device (\" ..self.id ..\") to production\")\n end\nend\nfunction L2_imp:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.3f\",data.L2_imp)))\n self:updateProperty(\"power\", tonumber(string.format(\"%.3f\",data.L2_imp)))\n self:updateProperty(\"unit\", \"kW\")\n self:updateProperty(\"log\", \" \")\nend\n\n\nclass 'L3_imp'(QuickAppChild)\nfunction L3_imp:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"production\" then \n self:updateProperty(\"rateType\", \"production\")\n self:warning(\"Changed rateType interface of Todays Production child device (\" ..self.id ..\") to production\")\n end\nend\nfunction L3_imp:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.3f\",data.L3_imp)))\n self:updateProperty(\"power\", tonumber(string.format(\"%.3f\",data.L3_imp)))\n self:updateProperty(\"unit\", \"kW\")\n self:updateProperty(\"log\", \" \")\nend\n\n\nclass 'L1_exp'(QuickAppChild)\nfunction L1_exp:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"production\" then \n self:updateProperty(\"rateType\", \"production\")\n self:warning(\"Changed rateType interface of Todays Production child device (\" ..self.id ..\") to production\")\n end\nend\nfunction L1_exp:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.3f\",data.L1_exp)))\n self:updateProperty(\"power\", tonumber(string.format(\"%.3f\",data.L1_exp)))\n self:updateProperty(\"unit\", \"kW\")\n self:updateProperty(\"log\", \" \")\nend\n\n\nclass 'L2_exp'(QuickAppChild)\nfunction L2_exp:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"production\" then \n self:updateProperty(\"rateType\", \"production\")\n self:warning(\"Changed rateType interface of Todays Production child device (\" ..self.id ..\") to production\")\n end\nend\nfunction L2_exp:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.3f\",data.L2_exp)))\n self:updateProperty(\"power\", tonumber(string.format(\"%.3f\",data.L2_exp)))\n self:updateProperty(\"unit\", \"kW\")\n self:updateProperty(\"log\", \" \")\nend\n\n\nclass 'L3_exp'(QuickAppChild)\nfunction L3_exp:__init(dev)\n QuickAppChild.__init(self,dev)\n if fibaro.getValue(self.id, \"rateType\") ~= \"production\" then \n self:updateProperty(\"rateType\", \"production\")\n self:warning(\"Changed rateType interface of Todays Production child device (\" ..self.id ..\") to production\")\n end\nend\nfunction L3_exp:updateValue(data) \n self:updateProperty(\"value\", tonumber(string.format(\"%.3f\",data.L3_exp)))\n self:updateProperty(\"power\", tonumber(string.format(\"%.3f\",data.L3_exp)))\n self:updateProperty(\"unit\", \"kW\")\n self:updateProperty(\"log\", \" \")\nend\n\n-- EOF "},{"name":"readme","isMain":false,"isOpen":false,"content":"--[[ Iungo Monitor readme\n\nThis QuickApp retrieves power consumption, solar production, energy usage, gas and water usage from the Iungo Monitor, Solarpanel Analog Gasmeter and Watermeter. \n(Child) Devices for Consumption, Production, Solar Power, Gas usage, Water Flow, Consumption High, Consumption Low, Production High, Production Low, Total Netting, Total Gas, Total Water FLow, Ampere L1-L2-L3, Voltage L1-L2-L3, Import L1-L2-L3 (in kW) and Export L1-L2-L3 (in kW). \n\nThe QuickApp works with the standalone Iungo or Iungo with BreakOutBox (max. extra 3 devices for Solar, Water and Gas analog). \n\n\nIungo OIDs:\n- Monitor: 538d72d9 (default)\n- Solar: 95778a43 (default)\n- Water: 82ec52ad (default) or 40c3afff\n- Gas analog: 06e869e1\n- Modbus: 06f6c748\n- Not effective smd220-Modbus 88a7d1ea or sdm630-Modbus 64904b93\n\n\nTested with Iungo version 1.5, revision 4444, date Nov 17 2023 with the help of Twanve (thanks) from the Fibaro forum. \n\n\nVersion 2.0 (3rd January 2024)\n- Added support for the newest API\n- Changed device types to the newest powerSensor --> powerMeter, multilevelSensor --> gasMeter or waterMeter\n- Added Child devices for Total Netting, Gas usage, Ampere L1-L2-L3, Voltage L1-L2-L3, Import L1-L2-L3 (kW), Export L1-L2-L3 (kW)\n- Added extra values to the labels: Total Netting, Ampere L1-L2-L3, Voltage L1-L2-L3, Import L1-L2-L3 kW, Export L1-L2-L3 kW, Cost consumption low and high, Cost production low and high, Cost gast, metername, type, version and serial number\n- Improved the calculations of grid consumption and house consumption\n- Changed the Gas en Water labels to L/min\n- Changed to multi-file\n- Added translations for English, Dutch, French and Polish\n- Added a separate Gas analog meter for those who have an Analog Gas Meter and Iungo addon\n- Added support for the Iungo Modbus addon\n- Added the ability to change the OID's\n- Meter measurement now can also be used for adding up the readings for Consumption High and Low, Production High and Low, Gas and Water to reset the measurements also upwards \n\n\nVersion 1.1 (11th September 2021)\n- Changed the Child Devices Consumption High, Consumption Low, Production High and Production Low to device type energyMeter to facilitate the new Energy Panel\n- Added automaticaly change rateType interface of Child device Consumption High and Low to \"consumption\" and Production High and Low to \"production\"\n- Changed the Main Device to device type powerSensor to show the power graphs\n- Added Net Consumption to the value of the Main Device \n- Changed the Child Devices Consumption, Production and Solar Power to device type powerSensor to show the power graphs \n- Changed the Water Flow unit text from m³ to Litre\n- Added the amount of m² Solar Panels to the log text ot the Child Device Solar Power and to the labels\n- Changed meterreading to automatically kWh, MWh of GWh\n- Moved tarif informatie to main device log text\n- Added Meter measurement for Consumption High, Consumption Low, Production High, Production Low, Gas and Water to reset the measurements\n- Added Meter measurement Date for Consumption High, Consumption Low, Production High, Production Low, Gas and Water\n- Removed Refresh button\n- Added some extra debug information for debug level = 3\n\nVersion 1.0 (6th February 2021)\n- Now also supports Iungo Solarpanel and Iungo Watermeter\n- Added a lot of Child devices\n- Added QuickApp Variable for user defined icon Mother Device\n- Added QuickApp Variable for Solar Power m²\n- Removed calculation and storage of energy consumption of Fibaro devices\n\nVersion 0.6 (22th January 2021)\n- Now also supports Iungo basic version\n\nVersion 0.5 (21th January 2021)\n- Initial version\n\n\nVariables (mandatory and automaticaly generated): \n- IPaddress = IP address of your Iungo Monitor\n- interval = Number in seconds, the Lungo Monitor normally is updated every 10 seconds (the interval gets devided by the amount of addons you have (next to the Iungo monitor, solarpanel, gasmeter analog or water meter))\n- debugLevel = Number (1=some, 2=few, 3=all, 4=simulation mode) (default = 1)\n- language = Preferred language (default = en) (supported languages are Engish (en), French (fr), Polish (pl) and Dutch (nl))\n- solarPanel = true or false for use of the SolarPanel module (default is false)\n- gasMeterAnalog = true or false for use of the analog Gasmeter module (default is false)\n- waterMeter = true or false for use of the Watermeter module (default is false)\n- monitorOID = monitor objectID (default is 538d72d9 or if you have the Modbus version: 06f6c748)\n- solarOID = solar objectID (default is 95778a43)\n- gasAnalogOID = analog gas meter objectID (default is 0, but if you have one, use 06e869e1)\n- waterOID = water meter objectID (default is 82ec52ad or use 40c3afff)\n- solarM2 = The amount of m² Solar Panels (use . (dot) for decimals) for calculating Solar Power m²\n- meterConsHigh = Last meter measurement Consumption High (kWh)\n- meterConsLow = Last meter measurement Consumption Low (kWh)\n- meterProdHigh = Last meter measurement Production High (kWh)\n- meterProdLow = Last meter measurement Production Low (kWh)\n- meterGas = Last meter measurement Gas (m³)\n- meterWater = Last meter measurement Water (L/min)\n- meterEnergyD = Date last Energy meter measurement\n- meterGasD = Date last Gas meter measurement \n- meterWaterD = Date last Water meter measurement \n]]\n\n-- EOF "}]}