From f4ffd5a7942a354ed82a2bcdf03aa334076a529c Mon Sep 17 00:00:00 2001 From: Leighm0 <69341431+Leighm0@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:37:16 +0800 Subject: [PATCH] Version 18 --- README.md | 9 +++++++++ driver.lua | 14 ++++++++++++++ driver.xml | 10 ++++++++-- www/documentation.md | 9 +++++++++ 4 files changed, 40 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3937cd4..db67953 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,9 @@ Total power used today in your home (both solar and grid, if any). **Excess Solar (kW) (read-only)** Current excess solar available for use. +**Current Voltage (v) (read-only)** +Current voltage reading from the Envoy. + ### Variables **PRODUCTION_KW (Int)** @@ -92,6 +95,9 @@ If there is currently excess solar. **EXCESS_SOLAR_KW (Int)** Excess energy available in kW. +**CURRENT_VOLTAGE (Int)** +Current voltage reading from the Envoy in volts. + ## Limitations - Daily energy kWh grid import/export totals are not available currently. @@ -150,6 +156,9 @@ Excess energy available in kW. - **v17** - Bug fix for errors +- **v18** + - Added CURRENT_VOLTAGE variable and properties to gather the current voltage reading from the Envoy. + ## Compiled Driver Available from Releases: https://github.com/Leighm0/enphase_gateway/releases diff --git a/driver.lua b/driver.lua index cc0aadc..afef79b 100644 --- a/driver.lua +++ b/driver.lua @@ -108,6 +108,10 @@ function OnDriverLateInit() C4:AddVariable("EXCESS_SOLAR_KW", "", "INT", true, false) C4:SetVariable("EXCESS_SOLAR_KW", "") end + if (not (Variables and Variables.CURRENT_VOLTAGE)) then + C4:AddVariable("CURRENT_VOLTAGE", "", "INT", true, false) + C4:SetVariable("CURRENT_VOLTAGE", "") + end for property, _ in pairs(Properties) do OnPropertyChanged(property) end @@ -328,22 +332,27 @@ function GetDataResponse(strError, responseCode, tHeaders, data, context, url) elseif (context["data_type"] == "solar-production") then local production_now local consumption_now + local voltage_now if (ReadingsURI == "/production.json") then production_now = data["production"][2]["wNow"] consumption_now = data["consumption"][1]["wNow"] + voltage_now = data["production"][2]["rmsVoltage"] ENPHASE.Production(production_now) ENPHASE.Consumption(consumption_now) ENPHASE.Grid(production_now, consumption_now) ENPHASE.Excess(production_now, consumption_now) + ENPHASE.Voltage(voltage_now) else data = C4:JsonDecode(data) production_now = data[1]["activePower"] consumption_now = data[2]["activePower"] + voltage_now = data[1]["voltage"] ENPHASE.Production(production_now) local consumption_calc = tonumber(production_now) + tonumber(consumption_now) ENPHASE.Consumption(consumption_calc) ENPHASE.Grid(consumption_calc, production_now) ENPHASE.Excess(production_now, consumption_calc) + ENPHASE.Voltage(voltage_now) end elseif (context["data_type"] == "solar-totals") then local production_today = data["production"][2]["whToday"] @@ -477,6 +486,11 @@ function ENPHASE.Excess(consumption_now, production_now) end end +function ENPHASE.Voltage(data) + C4:SetVariable("CURRENT_VOLTAGE", data) + C4:UpdateProperty("Current Voltage (v)", tostring(data)) +end + --[[============================================================================= Send Data to the Web UI ===============================================================================]] diff --git a/driver.xml b/driver.xml index e218d1e..37c0c9f 100644 --- a/driver.xml +++ b/driver.xml @@ -5,8 +5,8 @@ Enphase Gateway IQ/Envoy S Metered Gateways 11/3/2023 12:00 AM - 1/3/2024 12:00 AM - 17 + 2/6/2024 12:00 AM + 18 lua_gen DriverWorks icons\device_lg.png @@ -121,6 +121,12 @@ STRING true + + Current Voltage (v) + + STRING + true + diff --git a/www/documentation.md b/www/documentation.md index 7acc75b..64bfecc 100644 --- a/www/documentation.md +++ b/www/documentation.md @@ -69,6 +69,9 @@ Total power used today in your home (both solar and grid, if any). **Excess Solar (kW) (read-only)** Current excess solar available for use. +**Current Voltage (v) (read-only)** +Current voltage reading from the Envoy. + #### Variables **PRODUCTION_KW (Int)** @@ -92,6 +95,9 @@ If there is currently excess solar. **EXCESS_SOLAR_KW (Int)** Excess energy available in kW. +**CURRENT_VOLTAGE (Int)** +Current voltage reading from the Envoy in volts. + ### Limitations - Daily energy kWh grid import/export totals are not available currently. @@ -149,3 +155,6 @@ Excess energy available in kW. - **v17** - Bug fix for errors + +- **v18** + - Added CURRENT_VOLTAGE variable and properties to gather the current voltage reading from the Envoy.