IoT Connectivity with ThingWorx M5:10


#1

I completed the steps and double checked them, but continue to get the following error when I start the LSR

INFO ] 2018-06-09 12:19:12,819 SolarCollector-1_iotbuck: – Starting script --------------------------
[INFO ] 2018-06-09 12:19:12,819 SolarCollector-1_iotbuck: Registering core callback handler
[INFO ] 2018-06-09 12:19:12,819 SolarCollector-1_iotbuck: Starting main loop
[INFO ] 2018-06-09 12:19:12,819 SolarCollector-1_iotbuck: Calling lifecycle start listeners.
[INFO ] 2018-06-09 12:19:12,819 shapes.propsubscribe: Initialized
[INFO ] 2018-06-09 12:19:12,819 handlers.script: Opened
[INFO ] 2018-06-09 12:19:12,819 SolarCollector-1_iotbuck: MicroServer is now available.
[INFO ] 2018-06-09 12:19:12,819 SolarCollector-1_iotbuck: MicroServer is online.
[INFO ] 2018-06-09 12:19:12,819 SolarCollector-1_iotbuck: Successfully registered SolarCollector-1_iotbuck with MicroServer.
[INFO ] 2018-06-09 12:19:13,53 thingworx.handler: Creating a new handler.
[INFO ] 2018-06-09 12:19:13,53 SolarCollector-1_iotbuck: GetPropertySubscriptions called. 1 properties updated.
[ERROR] 2018-06-09 12:19:20,214 SolarCollector-1_iotbuck: Error occured in handler solarcollectorhandler.read. property: PowerProduced, msg: c:\EMS\microserver\etc\thingworx\lua\utils.lua:330: bad argument #1 to ‘find’ (string expected, got nil)
[ERROR] 2018-06-09 12:19:20,214 luaInterscriptBinding::l_executeCallback: Error executing callback ‘SolarCollector-1_iotbuck//scripts/SolarCollector-1_iotbuck/Properties/PowerProduced’
Returned: 500 c:\EMS\microserver\etc\thingworx\lua\utils.lua:330: bad argument #1 to ‘find’ (string expected, got nil)
[ERROR] 2018-06-09 12:19:20,214 ScriptHandler::Callback: Error getting script result. Code = 500 Result = c:\EMS\microserver\etc\thingworx\lua\utils.lua:330: bad argument #1 to ‘find’ (string expected, got nil)

During debug it did appear to run once.

As I read this, the first agrument is the Me the should be the thing.

SolarCollector1.lua:
properties.PowerProduced = { baseType=“NUMBER”, pushType=“NEVER”, value=1, handler=“solarcollectorhandler” }

solarcollectorhandler.lua:
function read(me, pt, headers, query)
log.info(p_data.name, “Entering Solar Collector Read Handler Function”)

– use csvtools to get last line
csvtools = require(“csvtools”)
file = io.open(“c:\EMS\microsever\logs\collector_log.csv”)
local lastline = csvtools.getLastLine(file)

local timestamp = tonumber(lastline[1])
local volts = tonumber(lastline[6])
local amps = tonumber(lastline[7])
local kilowatts = (amps * volts) / 1000
local logstr = "Solar Collector Producing " … kilowatts … “kW”
log.info(p_data.name, logstr)

  • Set the current values

pt.value = timestamp
pt.time = kilowatts
pt.quality = “GOOD”

pt.next = nil
tw_mutex.unlock()

return 200
end

Any help would be great, as I am running out of ideas on how to debug this

Dave


#2

I was able to debug and fixe this issue.
Thanks


#3

Hi Dave @David075 ,
I am also facing same issue.
What is the solution?


#4

Hi David,

I’m facing the same issue.
Could you please share your solution ?

Thanks and regards,
Nicolas.


#5

Has anyone found a resolution to the issue yet? From the error in the TWX Application log “property: PowerProduced] No Value In Property Read Request”. It appears that there is no value in the PowerProduced property.


#6

My issue was related to a different matter. I had a spelling error in the file name or template reference for the LSR.