Skip to content

Commit

Permalink
Version 18
Browse files Browse the repository at this point in the history
  • Loading branch information
Leighm0 committed Feb 6, 2024
1 parent 0a4b4f3 commit f4ffd5a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)**
Expand All @@ -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.
Expand Down Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions driver.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand Down Expand Up @@ -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
===============================================================================]]
Expand Down
10 changes: 8 additions & 2 deletions driver.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<name>Enphase Gateway</name>
<model>IQ/Envoy S Metered Gateways</model>
<created>11/3/2023 12:00 AM</created>
<modified>1/3/2024 12:00 AM</modified>
<version>17</version>
<modified>2/6/2024 12:00 AM</modified>
<version>18</version>
<control>lua_gen</control>
<driver>DriverWorks</driver>
<large image_source="c4z">icons\device_lg.png</large>
Expand Down Expand Up @@ -121,6 +121,12 @@
<type>STRING</type>
<readonly>true</readonly>
</property>
<property>
<name>Current Voltage (v)</name>
<default/>
<type>STRING</type>
<readonly>true</readonly>
</property>
</properties>
</config>
<capabilities>
Expand Down
9 changes: 9 additions & 0 deletions www/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)**
Expand All @@ -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.
Expand Down Expand Up @@ -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.

0 comments on commit f4ffd5a

Please sign in to comment.