Please help: Cannot get Input Values to post other than "0" to feed

I’ve got some LUA code running on a Vera Plus. Unfortunately, the variables all post “0” values.

Any ideas? Below is the Lua code from my Vera Plus device. I’ve also included a link to the Vera forum (where no one seems to read/reply).

module("EnergyMonitor", package.seeall)

-- Setup your account at
-- See API documentation at

-- API Key

-- Setup your devices here. You can use a function to calculate the power as illustrated in the sample.
-- For device logging, use: key, deviceId, serviceId, serviceVar
-- For function based logging, use: key, calculate, serviceVar

local VARIABLES = {
	{ key="HEM", deviceId = 155, serviceId='urn:schemas-micasaverde-com:device:PowerMeter:1', serviceVar="Watts" },
	{ key="HEM", deviceId = 155, serviceId='urn:schemas-micasaverde-com:device:PowerMeter:1', serviceVar="CurrentLevel" },
	{ key="kilnwelder", deviceId = 135, serviceId='urn:schemas-micasaverde-com:device:PowerMeter:1', serviceVar="Watts" },
	{ key="kilnwelder", deviceId = 135, serviceId='urn:schemas-micasaverde-com:device:PowerMeter:1', serviceVar="CurrentLevel" },
    { key='TestVar', calculate=function() return 15 end, serviceVar="dsmtest" } -- Send a constant value

-- Add the following to your Vera's Startup Lua (without the preceding dashes) to run the logging on every Vera restart
-- emoncode = require("EnergyMonitor")
-- emoncode.EnergyMonitorOnTimer()

local NODE_ID = 10
local TOTAL_KEY = 'Total'

-- Upload Frequency in seconds ORIGINALLY 60
local updateInterval = 10

-- Log debug messages
local DEBUG = true

-- You shouldn't need to change anything below this line --

local http = require('socket.http')
http.TIMEOUT = 3

local BASE_URL = "" .. API_KEY
local Log = function (text) luup.log('EnergyMonitor Logger: ' .. (text or "empty")) end
local lastFullUpload = 0

local items = {} -- contains items: { time, deviceId, value }

local function StartCallbackTimer(interval)
	luup.call_delay("EnergyMonitorOnTimer", interval or updateInterval, nil)

local function InitWatch()

local function AddKeyValuePair(key, value)
	local item = string.format("%s:%s", key, tostring(value))
	items[#items + 1] = item

local function SerializeData()
	local dataText = "{" .. table.concat(items, ",") .. "}"
	return dataText

local function ResetData()
	items = {}

local function SendData()
	local data = SerializeData()

	local parameters = "&node=" .. tostring(NODE_ID) .. "&json=" .. data
	local url = BASE_URL .. parameters
	if (DEBUG) then Log("Updating with: " .. parameters) end

local function AddAllVariablesAndTotal()
	local total = 0
	for i, v in ipairs(VARIABLES) do
		local value
		if v.deviceId then
			value = luup.variable_get(v.serviceId, v.serviceVar, v.deviceId)
		elseif v.calculate then
			value = v.calculate()
		value = tonumber(value) or 0
		if v.serviceVar == "Watts" then
			total = total + value
		AddKeyValuePair(v.key, value)
	AddKeyValuePair(TOTAL_KEY, total)

function EnergyMonitorOnTimer()

_G.EnergyMonitorOnTimer = EnergyMonitorOnTimer

Disclaimer: I don’t know the first thing about the language.

However, can you construct a fixed string like one of the examples in the emoncms API Help, and send that? If that works, it shows that the problem is within your code, and not with actually sending it.

If it does work, my bet would be that either the format that your code constructs is wrong, or somewhere, numbers and strings are getting mixed up, and you need to look carefully at what each function expects for its parameters, and at what it returns.
(In many languages, a string will evaluate to zero if a number was expected.)

Can you put fixed values into the VARIABLES array to prove whether getting the values is or is not the problem?

You are using your “read & write” API Key?

Note that only allows one post every 10 s.