Author Topic: Problems creating new service  (Read 208 times)

Offline samyoue

  • Sr. Newbie
  • *
  • Posts: 47
  • Karma: +2/-3
Problems creating new service
« on: January 20, 2018, 06:36:13 am »
Hi I'm trying to create a new plugin which will eventually have 5 different services, one of which accepting 1 argument (so could potentially use setTarget from light switch service but I want to use my own terminology etc), but the others require multiple arguments (one of which potentially needing 7 arguments!).

Baby steps though.
I've already modified Racarters Texecom Alarm plugin with some good results (when its polished I'll post new version as per discussion with Racarter) including a lot of added functionality.

For this new project I've started from scratch,
I've sucessfully got a device showing up under devices and my startup code runs fine (writes to a file '/www/testing.txt' with date/time).

When I try and run the following in test lua code box:
Code: [Select]
luup.call_action("urn:samyoue-com:serviceId:HomeTouch1","HEvent",{idV="action called"},30)or
Code: [Select]
luup.call_action("urn:samyoue-com:serviceId:HomeTouch1","HEvent","action called",30)I get no update to the testing.txt file and this in the log:
Code: [Select]
01      01/20/18 11:05:25.080   sbrk JobHandler_LuaUPnP::HandleActionRequest Problem with getnameinfo <0x74147520>
08      01/20/18 11:05:25.080   JobHandler_LuaUPnP::HandleActionRequest device: 0 service: urn:micasaverde-com:serviceId:HomeAutomationGateway1 action: RunLua <0x74147520>
08      01/20/18 11:05:25.081   JobHandler_LuaUPnP::HandleActionRequest argument id=lu_action <0x74147520>
08      01/20/18 11:05:25.081   JobHandler_LuaUPnP::HandleActionRequest argument serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1 <0x74147520>
08      01/20/18 11:05:25.081   JobHandler_LuaUPnP::HandleActionRequest argument action=RunLua <0x74147520>
08      01/20/18 11:05:25.081   JobHandler_LuaUPnP::HandleActionRequest argument Code=luup.call_action("urn:samyoue-com:serviceId:HomeTouch1","HEvent","action called",30)
 <0x74147520>
01      01/20/18 11:05:25.082   sbrk JobHandler_LuaUPnP::HandleActionRequest Problem with getnameinfo <0x74147520>
08      01/20/18 11:05:25.082   JobHandler_LuaUPnP::HandleActionRequest device: 30 service: urn:samyoue-com:serviceId:HomeTouch1 action: HEvent <0x74147520>
02      01/20/18 11:05:25.082   Device_LuaUPnP::HandleActionRequest 30 none of the 1 implementations handled it <0x74147520>
I've looked at several S_ files, D_files, I_files and copied the tags etc but to no avail.

Code: (S_HomeTouch.xml) [Select]
<?xml version="1.0"?>
<scpd xmlns="urn:schemas-upnp-org:service-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion> 
<serviceStateTable>
<stateVariable>
<name>idV</name>
<sendEventsAttribute>no</sendEventsAttribute>
<dataType>string</dataType>
<defaultValue></defaultValue>
</stateVariable>
</serviceStateTable>
<actionList>
<action>
<name>HEvent</name>
<argumentList>
<argument>
<name>idV</name>
<direction>in</direction>
<relatedStateVariable>idV</relatedStateVariable>
</argument>
</argumentList>
</action>
</actionList>
</scpd>
 
Code: (D_HomeTouch.xml) [Select]
<?xml version="1.0"?>
<root xmlns="urn:schemas-upnp-org:device-1-0">
<specVersion>
<major>1</major>
<minor>0</minor>
</specVersion>
<device>
<deviceType>urn:schemas-samyoue-com:device:HomeTouch:1</deviceType>
<friendlyName>HomeTouch Handler</friendlyName>
<manufacturer>Sam Youe</manufacturer>
<manufacturerURL>sam.youe.com</manufacturerURL>
<modelDescription>Handler Device</modelDescription>
<modelName>Handler</modelName>
<modelNumber>2.0</modelNumber>
<staticJson>D_HomeTouch.json</staticJson>
<serviceList>
<service>
<serviceType>urn:schemas-samyoue-com:service:HomeTouch:1</serviceType>
<serviceId>urn:samyoue-com:serviceId:HomeTouch1</serviceId>
<SCPDURL>S_HomeTouch.xml</SCPDURL>
</service>
</serviceList>
<implementationList>
<implementationFile>I_HomeTouch.xml</implementationFile>
</implementationList>
</device>
</root>
Code: (I_HomeTouch.xml) [Select]
<?xml version="1.0"?>
<implementation>
<settings>
<protocol>raw</protocol>
</settings>
<files>L_HomeTouch.lua</files>
<startup>init</startup>
<actionList>   
<action>
<serviceId>urn:urn:samyoue-com:serviceId:HomeTouch1</serviceId>
<name>HEvent</name>
<job>
local path="/www/testing.txt"
local cont=lul_settings.idV
local wf = io.open(path,"w")
if wf then
wf:write (cont)
wf:close ()
return(true)
else
return("ERROR No File Found: "..path)
end
</job>
</action>   
</actionList>
</implementation>
Code: (L_HomeTouch.lua) [Select]
function init()
local cont = 'init '..os.date ("%Y-%m-%d %H:%M:%S")
local path = '/www/testing.txt'
local wf = io.open(path,'w')
if wf then
wf:write (cont)
wf:close ()
return(true)
else
return(false)--"ERROR No File Found: "..path)
end
end

function HEvent(idV)--,state,name,detail)
local path='/www/testing.txt'
local wf = io.open(path,'w')
if wf then
wf:write (idV)
wf:close ()
return(true)
else
return(false)--"ERROR No File Found: "..path)
end
end

I'm guessing from the log message its a problem in my I_file but I cant for the life of me track it down, I'm sure its something really simple I'm missing...

I've been through the wiki pages and the somfy plugin walkthrough and through several other files but like I said I cant see what I'm missing here?

Any help would be greatly appreciated,

Sam.
« Last Edit: January 20, 2018, 02:21:30 pm by samyoue »

Offline samyoue

  • Sr. Newbie
  • *
  • Posts: 47
  • Karma: +2/-3
Re: Problems creating new service
« Reply #1 on: January 20, 2018, 02:30:03 pm »
OK so I just spotted the problem in the I_file the serviceId was listed as 'urn:urn:sam........' rather than 'urn:sam......' just changed that and now it seems to be writing an empty file?
Looks like the action is being called but the argument isn't being passed to it correctly?

Sam

EDIT:- scratch that another luup reload seems to have cured it, all working now... now to expand the test to 7 arguments but I should be good now, thanks all!
« Last Edit: January 20, 2018, 02:46:03 pm by samyoue »