To answer on FORM/POST for login
Dim result As String = ""
Dim WEB = New Net.WebClient()
Dim LoginData As System.Collections.Specialized.NameValueCollection = New System.Collections.Specialized.NameValueCollection()
LoginData.Add("user[email]", ID) // depend on the form field title
LoginData.Add("user[password]", PW) // depend on the form field title
Try
result = Text.Encoding.UTF8.GetString(WEB.UploadValues(URL, "POST", LoginData))
Catch ex As Exception
result = ""
End Try
It is pretty easy to apply
Dim WEB = New Net.WebClient()
WEB.Headers("Content-Type") = "application/json"
WEB.Headers("Authorization") = "Bearer " & varTokenTry
result = WEB.UploadString(varURL&, "POST", "")
Catch ex As Exception
Return ("")
End TryReturn result
Just add a token into header, and can access URL
There are so many web base devices, and some webserver device do not have a valid certification,
While access HTTPS using Webclient, will get a trouble with Certification if there is no valid one.
When I access Envoy Local Servier using HTTPS, I have expericed it.
First, create a Validation Server Function as below
Public Function ValidateServerCertificate(ByVal sender As Object, ByVal certificate As Object, ByVal chain As Object, ByVal sslPolicyErrors As Net.Security.SslPolicyErrors) As Boolean
Return True
End Function
And, Connect the validate server as
Net.ServicePointManager.ServerCertificateValidationCallback = New System.Net.Security.RemoteCertificateValidationCallback(AddressOf ValidateServerCertificate)
When call HTTPS using Webclient, Webclient server will call the user defined server code, and can over-ride an error
You can put the code into MAIN() -0r- Sub New() once
From Evnvoy FW7, Just can login into Enovy using Bearer Token,
I have made a simple code using VB.NET to
(1) Retrieve a Token from Enphase Token Website
(2) Using the Token, access Enovy's Data
Note. Need to add a certification validating code for Envoy, because envoy's certification is not valid.
Note. Ihave added json.vb for JSON file decord and using in the code
Test Site
http://www.forby.com/solar/?detail=1
I have started to use SQL server for logging data,
Actually, home_monitor software will collect the information from Envoy & Battery remotely,
and upload the data on website by calling solar_data.php
I am using jpgraph (www.jpgraph.net) for the line graphs,
and just GD line drawing for home layout.
solar.inc configruation related database
solar_db_initial.php initialize the database, and add the initial data records
solar_data.php add some data into db, and get solar informations
chart_panel0_inc.php house layout drawing information has hard-coded, and location of panel will be
referenced from dataset in DB,
I have updated from the concept software
1. json configuration
need 'envoy.json' in executable folder, it is a configuration file
It includes
Envoy Location / ID / Passowrd
FTP Folder for upload 'index.html' and 'panel.png'
Battery Back (just optional for myself, if needed)
Home Graphic Layout
Panel Layout
Panel Information (Groups, Location, Orientation, Serial Number, etcs)
2. FTP upload for web interface
need 'template.html' in executable folder, it will be updated to 'index.html'
It will showing METER readings
and Micro-inverter information
and House Layout
it is just concept how can be monitor Envoy IQ
and Generate Web page, and uploading using FTP
I will not publish the code on this website,
It is the last code for public,
I will just developt for myself only.
In fact, I can not keep going this programming, because I didn't got PTO yet.
and, My solar project has stuck by COVID-19.
Example
AcbSetSleepMode: "/admin/lib/acb_config.json",
AcbGetSleepModeData: "/admin/lib/acb_config.json",
AcbCancelSleepMode: "/admin/lib/acb_config.json",
AgfProfileIndex: "/installer/agf/index.json?simplified=true",
AgfProfileDetails: "/installer/agf/details.json",
AgfProfileInverterStatus: "/installer/agf/inverters_status.json",
AgfProfileSetProfile: "/installer/agf/set_profile.json",
CellularConfig: "/admin/lib/network_display.json?cellular=1",
ClearGFIPost: "/admin/lib/admin_dcc_display.json",
DhcpGetNewIp: "/admin/lib/network_display.json",
DiagnosticNetworkCheck: "/admin/lib/network_display.json",
EthernetConfigGet: "/admin/lib/network_display.json",
EthernetConfigPut: "/admin/lib/network_display.json",
EventsGet: "/datatab/event_dt.rb",
GetInfo: "/info.xml",
GetTimezones: "/admin/lib/date_time_display.json?tzlist=1",
Home: "/home.json",
InternalMeterInfo: "/ivp/meters",
InternalMeterReadings: "/ivp/meters/readings",
InternalMeterCurrentCTSettings: "/ivp/meters/cts",
Inventory: "/inventory.json?deleted=1",
InverterComm: "/installer/pcu_comm_check",
InverterProduction: "/api/v1/production/inverters",
InverterDelete: "/prov",
InverterPut: "/prov",
NewScanGet: "/ivp/peb/newscan",
NewScanPD: "/ivp/peb/newscan",
PowerForcedModeGet: "/ivp/mod/EID/mode/power",
PowerForcedModePut: "/ivp/mod/EID/mode/power",
PMUGet: "/admin/lib/admin_pmu_display.json",
PMUPost: "/admin/lib/admin_pmu_display.json",
RedeterminePhase: "/ivp/grest/local/gs/redeterminephase",
ReportSettingsGet: "/ivp/peb/reportsettings",
ReportSettingsPut: "/ivp/peb/reportsettings",
SetTimezone: "/admin/lib/date_time_display.json",
SystemReadingStats: "/production.json?details=1",
TariffSettingsGet: "/admin/lib/tariff.json",
TariffSettingsPut: "/admin/lib/tariff.json",
TunnelStateGet: "/admin/lib/dba.json",
TunnelStatePut: "/admin/lib/dba.json",
UpdateMeterConfig: "/ivp/meters/EID",
UpdateMeterCurrentCTConfig: "/ivp/meters/cts/EID",
UpdatePassword: "/admin/lib/security_display.json",
WifiSettings: "/admin/lib/wireless_display.json",
WifiSettingsJoin: "/admin/lib/wireless_display.json"
Simple JSON Parser for Visual Basic in Class
Example
Dim JSON As New json
JSON.Text = System.IO.File.ReadAllText("C:\installer.json").Replace(vbCr, "").Replace(vbLf, "")
Dim p() As String = New String() {"0", "devices", "0"}
Dim v As json_value = JSON.Value(p, True)
Console.WriteLine(JSON.Count.ToString
json_type in json_value
null = 0
bool, numeric, text in json_value.VALUE
array in json_value.VALUES
' Read all values
Dim v() as json_value = JSON.Value()
' Read specific value
' Path should be list of ID in level, array ID is 0 ~ nn
Dim v1 as json_value = JSON.Value(path() as string)
' Read specific value, ignore case of ID while compare
Dim v1 as json_value = JSON.Value(path() as string, True)
if can not find a data using IDs, it will return nothing.
if found a data, check json_value.type, and handle the data
This is a good article to read who want to make a remote access
https://thecomputerperson.wordpress.com/2016/08/28/reverse-engineering-the-enphase-installer-toolkit/
Thank to the app developer
Finally, I have made a simple software using Visual Basic (2015) to monitor Envoy Remotly.
I have attached a source code in this article.
Prepare Remote Access Method
(1) Router Port Forward If needed
* I am using 80 port for this web server, so, I have forward 180 to 80 to Envoy which has connected via WiFi
* It makes me to connect on Envoy Web interface remotely
(2) I am getting inverter informaiton
http://envoy:xxxxxx@forby.com:180/api/v1/production/inverters
* xxxxxx = last six digit of sserial number of your envoy
* forby.com = it is my home router domain, you can use IP address or your own domain
(3) I am getting meter information
http://forby.com:180/production.json
* forby.com = it is my home router domain, you can use IP address or your own domain
This software is not completed yet, I just upload back-born for testing, now
ToDo :
* configuration window
* data logging into DB
* create static web page for my web server, and upload