push notification plugin - file not found

moving push notification from vera to openluup.
Copied plugin files to openluup and installed by

do -- IOS Push local ios = luup.create_device ('', "IOS Push", "IOS Push", "D_IosPush.xml") local ITEM_SID = "urn:upnp-org:serviceId:IOSPush1" luup.variable_set(ITEM_SID, "UI7Check", "true", ios) luup.attr_set("device_json", "D_IosPush_UI7.json", ios) end
Entered pushover keys (copied them from working vera, tripple checked)
When I try to send a test message via plugin gui (“send message”) I get this error in the log

2018-01-03 23:38:27.908 openLuup.server:: GET /port_3480/data_requestid=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=luup.call_action(%22urn:upnp-org:serviceId:IOSPush1%22,%20%22SendPushOverNotification%22,%7B%20Subject=%20%22Test%20Subject%22,%20Message=%22aaa%22,%20Priority=%220%22,%20URL=%22%22,%20URLTitle=%22%22,%20Sound=%22%22%7D,32) HTTP/1.1 tcp{client}: 0x2534a90 2018-01-03 23:38:27.910 openLuup.server:: file not found:data_requestid=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=luup.call_action(%22urn:upnp-org:serviceId:IOSPush1%22,%20%22SendPushOverNotification%22,%7B%20Subject=%20%22Test%20Subject%22,%20Message=%22aaa%22,%20Priority=%220%22,%20URL=%22%22,%20URLTitle=%22%22,%20Sound=%22%22%7D,32)
I have excactly the same files on openluup as on vera:
J_IosPush_UI7.js
S_IosPush.xml
D_IosPush_UI7.json
D_IosPush.xml
J_IosPush.js
I_IosPush.xml
Did I miss anything?

You’ve left out a ‘?’ after data_request in the URL…

data_request?id=lu_action&...

…so it’s looking for a file of that name rather than seeing it as an HTTP query request.

As I used the plugin gui the request is generated by the plugin. I tried using the sendmessage from the action tab, same result.
If there is missing something (?) in the request would that mean there is a bug in the plugin?
I wonder if I should start from scatch with my underlying linux distribution (permission issues?) But that would mean quite some work to install all the plugins again (smaller part) and then check/rebuild all my workflows to ensure all transitions using the plugins (day/night, heliotrophe, push, multiswitches,…) are still working.

edit:

did some more testing:
the “send message” tab of the plugin doesn’t work on vera either,
but it works in vera on the actions tab.

When I use actions tab of the plugin on openluup i get this

ERROR: Device does not handle service/action

and in the log

2018-01-04 12:19:37.518 openLuup.server:: GET /port_3480/data_request?id=action&output_format=json&DeviceNum=32&serviceId=urn:upnp-org:serviceId:IOSPush1&action=SendPushOverNotification&Title=ol&Message=ol&Priority=1&URL=&URLTitle=&Sound=&DeviceName= HTTP/1.1 tcp{client}: 0x33f74f0 2018-01-04 12:19:37.520 luup.call_action:0: 32.urn:upnp-org:serviceId:IOSPush1.SendPushOverNotification 2018-01-04 12:19:37.521 openLuup.context_switch:: ERROR: [string "[32] I_IosPush.xml"]:493: attempt to index global 'ltn12' (a nil value) 2018-01-04 12:19:37.522 openLuup.server:: request completed (44 bytes, 1 chunks, 3 ms) tcp{client}: 0x33f74f0

This log entry DOES have the ‘?’ correctly in the request.

The error message, however, suggests that you do not have the ltn12 module installed in your Lua configuration, which is odd, siince it should be part of the LuaSocket library.

There is surely no need to start from scratch, but something appears to be missing. Does the implementation file have a require statement for the ltn12 library? Is there a missing .lua file for the plugin?

as far as I can see in I_IosPush.xml there is no require for ltn12 (see file attached).
With the latest release of the plugin (0.98) came two lua files (base64.lue, crc32.lua) which are both present on openluup.

This log line

ERROR: [string "[32] I_IosPush.xml"]:493: attempt to index global 'ltn12' (a nil value)

says that line 493, or thereabouts, does reference that variable.

Indeed, a quick search seems to find five such references. The problem is that there is no require statement.

local ltn12 = require "ltn12"

ak, you’re incredible!

I added these lines to the code

local lxp = require("lxp/lom") local lom = require("lxp/lom") local CRC32 = require ("crc32") local ltn12 = require ("ltn12")

and now the pushover part of the plugin is working without any errors (havent tested the others).

I’m not quite sure if I did the lxp lxm part correctly, but it throws errors if I don’t.
lxp and lom seem to be parts of a data structure beeing used like this

tabxml = lxp.lom.parse (resp[1])
I don’t know how to handle the “require” part correctly in this case.

Also, the problem with the missing “?” was reported and fixed a while back by @dreamcrier.

AK, if you give me the thumbs up i’ll zip all the altered and required files together and post them in your “known working plugins” thread.

Thanks again for your help!

Glad it seems OK now.

I’m not in front of my development system just now, so can’t check things out. I don’t recall the details of the LuaExpat library, to which lxp belongs.

lom, or any other sub tree of the lxp library, does not require to be declared separately. The top level lxp is sufficient, in which case, I would have though that

local lxp = require "lxp"

would be sufficient.

[quote=“akbooer, post:8, topic:198189”]lom, or any other sub tree of the lxp library, does not require to be declared separately. The top level lxp is sufficient, in which case, I would have though that

local lxp = require "lxp"

would be sufficient.[/quote]

If I do that push still works but throws error in log

2018-01-05 12:13:50.304 luup.call_action:0: 29.urn:upnp-org:serviceId:IOSPush1.SendPushOverNotification 2018-01-05 12:13:51.265 openLuup.context_switch:: ERROR: [string "[29] I_IosPush.xml"]:502: attempt to index field 'lom' (a nil value)

Looking at the lxp module on my own system, it seems that the following should work…

local lxp = require "lxp"
local lom = lxp.lom

I can add some detail to this error as I’m trying to get the plugin to run as well. There are a couple of changes you need to make to the implementation file I_IosPush.xml. here is what worked for me. First is the require statement needs to be amended: local url = require("socket.url") local http = require("socket.http") local https = require("ssl.https") local json = require("json") local b64 = require("base64") local lxp = require("lxp") local lom = require("lxp.lom") local CRC32 = require ("CRC32") local Hash = CRC32.Hash local ltn12 = require ("ltn12")

Next the calls to “tabxml = lxp.lom.parse” need to be changed to “tabxml = lom.parse”

You need to generate your own application key AND a user key for the pushover service on the pushover site.

The “function GetGUID()” relies on the vera HW key. You can find the key on the vera as it is stored in a text file, with the key id as the only data inside the file. Perhaps AK could bring this ID across when bridging?? It would also help if this ID could be set as a global luup.attribute much like the “PK_AccessPoint” attribute. To solve this temporarily, I hardcoded my vera HW id into the function itself.

Finally, you must input the user and app keys into the variables created on the variables page. Also change “PushOverUseCustomAppKey” to 1 from 0.

This should get the app running. I am, however, having trouble sending a push message from the control panel. I’m going to guess the failure is related to the plugnplay capabilities of openluup but AK will know for sure. Here is a sample error message from the log: 2018-08-11 15:11:52.244 openLuup.http:: GET /data_requestid=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=luup.call_action(%22urn:upnp-org:serviceId:IOSPush1%22,%20%22SendPushOverNotification%22,%7B%20Subject=%20%22Test%20Subject%22,%20Message=%22Test%20for%20today%22,%20Priority=%220%22,%20URL=%22%22,%20URLTitle=%22%22,%20Sound=%22spacealarm%22%7D,111) HTTP/1.1 tcp{client}: 0x32b332c8 2018-08-11 15:11:52.247 openLuup.servlet:: file not found:data_requestid=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=luup.call_action(%22urn:upnp-org:serviceId:IOSPush1%22,%20%22SendPushOverNotification%22,%7B%20Subject=%20%22Test%20Subject%22,%20Message=%22Test%20for%20today%22,%20Priority=%220%22,%20URL=%22%22,%20URLTitle=%22%22,%20Sound=%22spacealarm%22%7D,111)

AK, any help here is appreciated as I find message pushes to be one of those must have services.

Just as a slight diversion - I’ve found Telegram works well. It’s is also multi platform. Using the instructions here, it all just worked:

http://forum.micasaverde.com/index.php?topic=36021.0

Need to be careful to delete the conversation history, rather than the actual conversation, if cleaning up a conversation.

Very cool. Telegram looks promising. And how can you refuse the Botfather!

[quote=“Buxton, post:11, topic:198189”]First is the require statement needs to be amended:
[…]
Next the calls to “tabxml = lxp.lom.parse” need to be changed to “tabxml = lom.parse”[/quote]

BTW, the second edit wouldn’t be necessary if you changed the require as I proposed earlier…

local lxp = require "lxp"
local lom = lxp.lom
I am, however, having trouble sending a push message from the control panel. I'm going to guess the failure is related to the plugnplay capabilities of openluup but AK will know for sure. Here is a sample error message from the log:

2018-08-11 15:11:52.244 openLuup.http:: GET /data_requestid=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=luup.call_action(%22urn:upnp-org:serviceId:IOSPush1%22,%20%22SendPushOverNotification%22,%7B%20Subject=%20%22Test%20Subject%22,%20Message=%22Test%20for%20today%22,%20Priority=%220%22,%20URL=%22%22,%20URLTitle=%22%22,%20Sound=%22spacealarm%22%7D,111) HTTP/1.1 tcp{client}: 0x32b332c8 2018-08-11 15:11:52.247 openLuup.servlet:: file not found:data_requestid=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=luup.call_action(%22urn:upnp-org:serviceId:IOSPush1%22,%20%22SendPushOverNotification%22,%7B%20Subject=%20%22Test%20Subject%22,%20Message=%22Test%20for%20today%22,%20Priority=%220%22,%20URL=%22%22,%20URLTitle=%22%22,%20Sound=%22spacealarm%22%7D,111)

AK, any help here is appreciated as I find message pushes to be one of those must have services.

Well, the cause of the problem is clear…

/data_requestid=lu_action&serviceId=...

should be…

/data_request?id=lu_action&serviceId=...

but what’s not clear to me just how you are generating this request. Is it just a typo?


Edit: Strangely, that’s the same error as described here:
http://forum.micasaverde.com/index.php/topic,53168.msg338723.html#msg338723

I tried several different ways of calling the lom object with no luck. Requiring the object and then using that instance explicitly in the code worked. I’m not sure why it works this way as the method you outlined should work.

I tracked down the syntax error. In the javascript file “J_IosPush_UI7.js”, the calls are made using a variable derived from a verde API for javascript:

var ipaddress = api.getDataRequestURL()

Then the variable is concatenated into a call such as:

var xmlHttp = null; xmlHttp = new XMLHttpRequest(); url = ''+ ipaddress +'id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=luup.call_action("urn:upnp-org:serviceId:IOSPush1", "SendPushOverNotification",{ Subject= "Test Subject", Message="' + encodeURIComponent(m) + '", Priority="' + mytablePo_select[1][1] + '", URL="", URLTitle="", Sound="' + mytablePo_static[0][1] + '"},'+ device +')'; xmlHttp.open( "GET",url , false ); xmlHttp.send( null );

Replacing “'id=lu_action” with “'?id=lu_action” solved the problem, but why would the original syntax works on UI7, but not openLuup??

Great work!

In the javascript file "J_IosPush_UI7.js", the calls are made using a variable derived from a verde API for javascript:

var ipaddress = api.getDataRequestURL()
[…]
but why would the original syntax works on UI7, but not openLuup??

I can guarantee that the incorrect URL will not work on Vera, so I have to assume that the API call actually returns with a trailing ‘?’. Quite why this would not be so for openLuup is way out of my expertise. I simply do not ‘do’ JavaScript.

If someone can point to something that openLuup is doing wrong here, then I’m more than happy to fix it.

Yeah, I tried to invoke the API in the test window but it wasn’t known to the openLuup engine. So I’m guessing that the API is registered through ALTui somehow. Perhaps the problem stems from a character filter kicking in, or an unescaped character that is discarded. Whatever it is (if it is caused by a true difference in platforms), it means that any plugins that use this JS method will not work on openLuup.

A post was split to a new topic: Integrate CallMeBot with Vera