Roowifi

Moderator: leecollings

Post Reply
roblom
Posts: 408
Joined: Wednesday 26 February 2014 15:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: the Netherlands
Contact:

Roowifi

Post by roblom »

A long time ago I've bought a Roowifi board in order to be able to add my Roomba to Domoticz. I did several attempts to get this working but it seems i'm to stupid for it :-)

When I paste the URL below in chrome I get some response.
http://192.168.178.185/roomba.json

Code: Select all

{
"response": { 
"r0": {
"name": "Bumps Wheeldrops",
"value": "0"
},
"r1": {
"name": "Wall",
"value": "0"
},
"r2": {
"name": "Cliff Left",
"value": "0"
},
"r3": {
"name": "Cliff Front Left",
"value": "0"
},
"r4": {
"name": "Cliff Front Right",
"value": "0"
},
"r5": {
"name": "Cliff Right",
"value": "0"
},
"r6": {
"name": "Virtual Wall",
"value": "0"
},
"r7": {
"name": "Motor Overcurrents",
"value": "0"
},
"r8": {
"name": "Dirt Detector - Left",
"value": "0"
},
"r9": {
"name": "Dirt Detector - Right",
"value": "0"
},
"r10": {
"name": "Remote Opcode",
"value": "0"
},
"r11": {
"name": "Buttons",
"value": "0"
},
"r12": {
"name": "Distance",
"value": "0"
},
"r13": {
"name": "Angle",
"value": "0"
},
"r14": {
"name": "Charging State",
"value": "0"
},
"r15": {
"name": "Voltage",
"value": "15888"
},
"r16": {
"name": "Current",
"value": "-151"
},
"r17": {
"name": "Temperature",
"value": "22"
},
"r18": {
"name": "Charge",
"value": "2490"
},
"r19": {
"name": "Capacity",
"value": "2697"
}
}
}
So I thought then it would be easy to use lua with a JSON parser to put some info in Domoticz.
In order to make a start i made the script below.

Code: Select all

local t1 = os.date("%H") -- get hour time digit
local t2 = os.date("%M") -- get minute time digit

local ROOMBAIP = "192.168.178.185"				-- Roomba IP Address

commandArray = {}
 
if t1 == "00" and t2 == "20" then -- time to poll

JSON = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()  -- For Linux

--Extract data from roomba.
RoombaJsonURL	= 'curl "http://'..ROOMBAIP..'/roomba.json"'
jsondata    = assert(io.popen(RoombaJsonURL))
RoombaDevice = jsondata:read('*all')
jsondata:close()
RoombaData = JSON:decode(RoombaDevice)

--RoombaTemperature = jsonData.response.r17

print("  ----- Roomba temperature = " .. RoombaData .. "");

--commandArray={['UpdateDevice']='1609|0|' .. RoombaJson}  -- update sensor value

end

return commandArray
But all I get is

Code: Select all

Error: EventSystem: in /home/pi/domoticz/scripts/lua/script_device_roomba.lua: /home/pi/domoticz/scripts/lua/script_device_roomba.lua:25: attempt to concatenate global 'RoombaData' (a nil value)
Can someone point me in the right direction because I'm stuck...
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest