Thanks for your help.
I finally got my service to work!
Adding httpRequest.send()
didnât work, but the following code:
var service = new Service("com.ha.webhook.service");
const http = require('http');
const url = 'http://[HA_IP]:8123/api/webhook/';
service.register("webhook", function (message) {
var id = message.payload.id;
http.get(url + id);
});
In a simple WebOS App I can call this service using the following command:
webOS.service.request("luna://com.ha.webhook.service/", {
method: "webhook",
parameters: { id: "123"},
onFailure: showFailure,
onSuccess: showSuccess,
});
But I am still not quite sure how I can call the above request inside Home Assistant. I tried the following:
service: webostv.command
data:
entity_id: media_player.living_room_tv
command: system.notifications/createAlert
payload:
message: "Someone's at the door"
buttons:
- label: Open
onclick: "luna://com.ha.webhook.service/webhook"
params:
id: "123"
- label: Cancel
Any idea?
I found a way to show some debug logs. When pressing the âOpenâ button I get the following log:
[18:52:37.257][WARNING] ls-hubd LSHUB_NO_NAME_PERMS Can not find match for 'com.ha.webhook.service' in pattern queue '["com.webos.service.*", "com.webos.service.*", "com.webos.*", "com.palm.service.*", "com.palm.*", "com.palm.*", "com.lge.*", "com.lge.*", "airplay.service"]' {}
[18:52:37.257][ERR] ls-hubd LSHUB_NO_OUT_PERMS "com.webos.surfacemanager" does not have sufficient outbound permissions to communicate with "com.ha.webhook.service" (cmdline: /usr/bin/surface-manager -platform starfish) {"DEST_APP_ID":"com.ha.webhook.service","SRC_APP_ID":"com.webos.surfacemanager","EXE":"/usr/bin/surface-manager","PID":1853}
[18:52:37.257][WARNING] ls-hubd LSHUB_NO_SERVICE _LSHubSendQueryNameReplyMessage: Failed Connecting to Service err_code: -2, service_name: "com.ha.webhook.service", unique_name: "(null)", static, fd -1 {}
[18:52:37.260][INFO] VOICEFW VOICEUI_FOREGROUND foreground changed {"foreground":"com.webos.app.hdmi1"}
[18:52:37.262][WARNING] surface-manager LSM Hub error detected for token: 724 "webhook" "PermissionDenied" {}
[18:52:37.262][WARNING] surface-manager LSM Error response for token: 724 -1 "Not permitted to send to com.ha.webhook.service." {}
/edit: I managed to make it work!
The service name must match any of the patterns in the log:
["com.webos.service.*", "com.webos.service.*", "com.webos.*", "com.palm.service.*", "com.palm.*", "com.palm.*", "com.lge.*", "com.lge.*", "airplay.service"]
Unfortunately, the App name âcom.webos.haâ with the service name âcom.webos.ha.serviceâ does not work:
ares-install ERR! [com.webos.appInstallService failure]: luna-send command failed <Cannnot install privileged app on developer mode>
ares-install ERR! [Tips]: Please change the app id (app id should not start with 'com.lge', 'com.webos', 'com.palm')
So the only name, that works for me, is âcom.webosâ.
And to be honest, I think this is a bug because based on the error message above, this name shouldnât work either.
But at least you have the necessary rights to call the service.