I want to reboot the device from the application, tried LS2 API Service


Below in the Code Snippet

<script type="text/javascript">
   //sample code for calling LS2 API
   var lunaReq= webOS.service.request("luna://com.webos.service.power/shutdown/machineOff",{ 
        "reason":"power off"
        onSuccess: function (args) {
        onFailure: function (args) {

The above code fails with following error

{"returnValue":false,"errorCode":-1,"errorText":"Denied method call \"machineOff\" for category \"/shutdown\""}

Now I want to know why this happens and if its a permission problem than what should I do ?

I haven’t looked into it, but I would assume that’s just a protected method. You wouldn’t want any app to be able to power off or reboot your device, right? In the old days, your app would need to be in the com.palm.appdomain to get access to all the system APIs. That’s what some of us homebrew developers did to get around it. I don’t know if that’s still true for webOS OSE.

Garredow is right there. If you look in you’ll see that it’s in the private api, so that means only com.webos or com.palm apps would have access to this.

Previously you could “fool” it a bit by either giving your app an appid that starts with com.palm or com.webos. Alternatively you could try to pretend to be sending the command from another app.

Best would be to try with the luna-send command in ssh.

luna-send accepts -a and -h parameters if I recall correctly to put the caller. Some mor example of luna-send can be found on WebOS Internals site:

This is legacy webOS used on phones, but should work similarly.

See for an example on how to use -a.

1 Like


How can I access these private API’s do I need to build my application as Built-in-Web-Apps as suggested by or is there any other way ?

@Junil Could you let us know how to access private API?

I had to create a dynamic JS service running as root that uses a shell command to luna-send to get around the private restriction. I guess you could recompile the whole image changing up the compat.api.json file that was mentioned before as well.

Hi, I would like to know how you create the JS service running as root priviledge.

Check Below Solution..

a temporary solution, but got it to work in a pinch:

/usr/bin/sudo /bin/bash -lc 'bundle exec rails server -e demo -p 80'

Can run with a user who has sudo privileges in a systemd unit file like so:

Description=Rails Webserver

ExecStart=/usr/bin/sudo /bin/bash -lc 'bundle exec rails server -e demo -p 80'



Speaking of which doesn't webOS have any capability similar to what Android has with their Device Administration feature?
I was working on writing a webOS agent for an EMM product some time back and this struck me as odd considering how valuable it would be for use cases such as TVs in hotels.