<%# hmi.htm -%> <% ---------------------- -- Poste seleccionado ---------------------- local path = luci.dispatcher.context.requestpath local fs = require "nixio.fs" local cl = path[1] local utl = require "luci.util" local mUtl = require "luci.moreUtils" local sn = mUtl.get_serialnumber() local pricingd_vars = require "luci.model.pricingd" if params and params.pdr then params = params.pdr end local master = mUtl.identify_pseudo_maestre(path[3] or sn) local method if master == true then method = "pricingd" else method = (path[3] or sn).. "/pricingd" end local options = utl.ubus(method , "get_configuration") local cost_methoda if options and options.cost_method then cost_method = options.cost_method end local all_opts = {} local discount_periods = {} if options then for k , v in pairs (options) do if type(v) ~= "table" then if k~= "debuglevel" then all_opts[k] = v end else if k ~= "discount_periods" then for z, t in pairs (v) do if type(t) == "table" then for n,m in pairs (t) do if cost_method ~= "california" then if (n == "charging_rate" or n == "discount_charging_rate") and string.find(z,"mennekes") then all_opts[n.."_ac"] = m elseif ( n == "charging_rate" or n == "discount_charging_rate") then all_opts[n.."_dc"] = m else if n ~= "credit" then all_opts[n] = m end end elseif cost_method == "california" and (z == "default_charging" or z == "default_idle" ) then if z == "default_idle" and n == "hourPrice" then n = "hourPrice_idle" elseif z == "default_charging" and n == "hourPrice" then n = "hourPrice_charging" end all_opts[n] = m end end end end else for z, t in pairs (v) do discount_periods[z] = t end end end end end -%> <%+header%>

<%=translate("Pricing")%> - <%=path[3] or params or sn%>

<%:Configure pricing parameters%>
<%:Here you can configure the cost method of the charger and %>
<%if cost_method ~= "mcdonalds" and cost_method ~= "california" then%> <%for k , v in pairs (all_opts) do if k~="cost_method" then%> <% local val = v if v%1 ~= 0 then val = string.format("%.2f", v) end %>
<%end%> <%end%> <%elseif cost_method == "california" then%>
<%:Charging%>
<%for n, m in ipairs (pricingd_vars.textValues_california) do%> <%for k , v in pairs (all_opts) do if k~="cost_method" and (k ~= "hourPrice_idle" and k ~= "graceMinutes") then%> <% local val = v if v%1 ~= 0 then val = string.format("%.2f", v) end %> <%if m == k then %>
<%end%> <%end%> <%end%> <%end%>
<%:Idle%>
<%for n, m in ipairs (pricingd_vars.textValues_california) do%> <%for k , v in pairs (all_opts) do if k~="cost_method" and (k == "hourPrice_idle" or k == "graceMinutes") then%> <% local val = v if v%1 ~= 0 then val = string.format("%.2f", v) end %> <%if m == k then %>
<%end%> <%end%> <%end%> <%end%>
<%elseif cost_method == "mcdonalds" then%> <%for k, v in ipairs (pricingd_vars.textValues) do %> <%for z, t in pairs (all_opts) do %> <%if z ~="cost_method" then%> <%if v == z then%> <% local val = t if t%1 ~= 0 then val = string.format("%.2f", t) end %>
<%end%> <%end%> <%end%> <%end%> <%end%> <%if cost_method == "mcdonalds" then%>
<%:Discount periods%>
<%for k , v in ipairs (discount_periods) do local p = utl.split(v,"-") %> <%end%>
<%:Start time%> <%:End time%> <%:%>
<%end%>
<%+footer%>