% --[[ Status.htm (Charging_points module) ]]-- local chp = require "luci.model.charging_points" local fs = require "nixio.fs" local utl = require "luci.util" local dsp = require "luci.dispatcher" local mUtl = require "luci.moreUtils" local os = require "os" local path = luci.dispatcher.context.requestpath local user, serialnumber, hw_model = chp.whoami(path) local parameters = {} local sections = {} local gmod, amod local modules = {} -- Load modules if user ~= "user" then gmod = require "luci.model.ocpp_variables" amod = require "luci.model.advanced_ocpp_variables" modules = {gmod, amod} else gmod = require "luci.model.user_global_variables" modules = {gmod} end ------------------------------------------------------------------------------------------------------------------------- local path = dsp.context.requestpath serialnumber = mUtl.get_serialnumber() local method local sn = "" local maestre if serialnumber then if string.sub(path[3],1,1) == "6" and string.sub(path[3],1,4) ~= "ocpp" then sn = path[3] else sn = serialnumber end maestre = mUtl.identify_pseudo_maestre(sn or serialnumber ) if maestre == true then method = sn or serialnumber wizard = "wizard" maestre_js = "true" else method = sn wizard = sn..[[/wizard]] maestre_js = "false" end end cl = path[1] local model = mUtl.model(serialnumber) local all_options = utl.ubus(method, "get_configuration") local sn_options = {} local all_options2 = {} if all_options and all_options.ocpp then all_options = all_options["ocpp"] if all_options then for k , v in pairs (all_options) do if type(v) ~= "table" then all_options[k] = v all_options2[k] = v elseif type(v) == "table" and k == sn then for z , t in pairs (v) do all_options2[z] = t sn_options[z] = t end end end end else all_options = {} end local version if utl.ubus(wizard, "active_service", {service = "ocppdv16"}).enabled == "true" or utl.ubus(wizard, "active_service", {service = "ocppdjv16"}).enabled == "true" then version = 16 elseif utl.ubus(wizard, "active_service", {service = "ocppdv15"}).enabled == "true" then version = 15 --elseif utl.ubus(wizard, "active_service", {service = "ocppdv201"}).enabled == "true" then -- version = 201 else version = 0 end all_options2["version"] = version local info = {} for i=1, 2, 1 do for k, v in pairs(modules[i].booleanValues) do info[k] = v end for k, v in pairs(modules[i].textValues) do info[k] = v end for k, v in pairs(modules[i].listValues) do info[k] = v end end local security_profile if all_options and all_options["security_profile"] then security_profile = all_options["security_profile"] end local all_pass = {} table.insert(all_pass, all_options2) table.insert(all_pass, info ) if luci.http.formvalue("status") == "1" then luci.http.prepare_content("application/json") luci.http.write_json(all_pass) return end %> <%+header%>