Trying to crete a new tile to execute a shell command
Closed this issue · 21 comments
Hello,
I'm using BerryIO + the nicholas smartapp
I was able to duplicate the reboot tile which launches api_command/reboot
I replced it with another command api_commnd/sudo ps4-waker
But its not working...
Can you please help point out what should I do?>
You cannot use api_command to run any command, only the BerryIO API commands listed here:
https://github.com/NeonHorizon/berryio/blob/master/includes/configs/api.php
Hi,
Is there anyway I can add more commands?
I already added the ps4-waker command to that list...but it needs sudo and still doesn't work..
Need your help please.
Yes but its not easy....
Add the name in this list:
https://github.com/NeonHorizon/berryio/blob/master/includes/configs/api.php
To use sudo please add the command to NEED_SUDO here but it might not work through the web interface:
https://github.com/NeonHorizon/berryio/blob/master/includes/configs/common.php
Add the php script in this folder (this is the hard bit you will probably need the exec command):
https://github.com/NeonHorizon/berryio/tree/master/includes/commands
This is exactly what I did.
Add the name in this list:
https://github.com/NeonHorizon/berryio/blob/master/includes/configs/api.php (DONE - added "ps4-waker"):
pi@raspberrypi:/usr/share/berryio/includes/configs $ cat api.php
'pse4-waker')); elseif(power_reboot() === FALSE) { $content .= message('ERROR: Cannot reboot the system', 'welcome'); return FALSE; } elseif($GLOBALS['EXEC_MODE'] != 'api') $content .= message('See you again shortly!', 'welcome'); pi@raspberrypi:/usr/share/berryio/includes/commands $ in the ST Device Handler (nicholaswilde : Raspberry Pi), Here is what I added: command "restart" command "reboot" command "PS4ON" command "PS4OFF" **standardTile("PS4ON", "device.PS4ON", inactiveLabel: false, decoration: "flat") { state "default", action:"PS4ON", label: "PS4ON", displayName: "PS4ON" } standardTile("PS4OFF", "device.PS4OFF", inactiveLabel: false, decoration: "flat") { state "default", action:"PS4OFF", label: "PS4OFF", displayName: "PS4OFF" def PS4ON(){ log.debug "PS4 ON" sendEvent(name: "switch", value: "off") def uri = "ps4-waker" postAction(uri) } def PS4OFF(){ log.debug "PS4 OFF" sendEvent(name: "switch", value: "off") def uri = "/api_commnd/ps4-waker standby" postAction(uri) }pi@raspberrypi:/usr/share/berryio/includes/configs $ cat common.php
hmmm
im not sure why the format is that bad,
`pi@raspberrypi:/usr/share/berryio/includes/configs $ cat common.php
'pse4-waker')); elseif(power_reboot() === FALSE) { $content .= message('ERROR: Cannot reboot the system', 'welcome'); return FALSE; } elseif($GLOBALS['EXEC_MODE'] != 'api') $content .= message('See you again shortly!', 'welcome'); `def PS4ON(){ log.debug "PS4 ON" sendEvent(name: "switch", value: "off") def uri = "ps4-waker" postAction(uri) } def PS4OFF(){ log.debug "PS4 OFF" sendEvent(name: "switch", value: "off") def uri = "/api_commnd/ps4-waker standby" postAction(uri) }
I can't read this because of the formatting. When you paste it in click the <> insert code button.
Also what language is that, it doesn't look like PHP?
Add the name in this list:
https://github.com/NeonHorizon/berryio/blob/master/includes/configs/api.php
Done:
`pi@raspberrypi:/usr/share/berryio/includes/configs $ cat api.php
What the hell, i paste the whole text in between `` and its not pasting all the text..
Is there any other way to better reach you? or are you seeing all what i'm pasting in the code?
I'm pasting to you what I did in all 3 points you mentioned.
I copied reboot.php to ps4-waker.php as follows:
`pi@raspberrypi:/usr/share/berryio/includes/commands $ cat ps4-waker.php
'ps4-waker')); elseif(power_reboot() === FALSE) { $content .= message('ERROR: Cannot reboot the system', 'welcome'); return FALSE; } elseif($GLOBALS['EXEC_MODE'] != 'api') $content .= message('See you again shortly!', 'welcome'); pi@raspberrypi:/usr/share/ber`In ST Device Handler, I added these:
command "restart" command "reboot" command "PS4ON" command "PS4OFF"
details(["button", "temperature", "cpuPercentage", "memory" , "diskUsage", "contact", "restart", "refresh", "reboot", "PS4ON", "PS4OFF"])
def PS4ON(){ log.debug "PS4 ON" sendEvent(name: "switch", value: "off") def uri = "ps4-waker" postAction(uri) } def PS4OFF(){ log.debug "PS4 OFF" sendEvent(name: "switch", value: "off") def uri = "/api_commnd/ps4-waker standby" postAction(uri) }
Can you read it now?
I think this is going to be too complicated to support in a github issue but I think you have multiple problems. For example you have told the system the API commands are PS4ON and PS4OFF but you only have one file called ps4-waker.php in commands. It needs to match, so you need two files one called PS4ON.php and one called PS4OFF.php and they each need to do whatever it is you need the command to do.
do you have an email? or google chat?
I think this is going to be too complicated to support in a github issue but I think you have multiple problems. For example you have told the system the API commands are PS4ON and PS4OFF but you only have one file called ps4-waker.php in commands. It needs to match, so you need two files one called PS4ON.php and one called PS4OFF.php and they each need to do whatever it is you need the command to do.
but the command itself is ps4-waker not PS4ON <- this was just a name/alas but at the command itself which i believe is /api_commands/ps4-waker
All i wanna do is duplicate the reboot command with another one with a new tile:
i did the tile
i tried to duplicate all files and edited .groove file
but it just wont work when i press PS4ON
reboot works..
Have you tried it on the command line, its best to get it to work there first.
berryio api_command ps4-waker
Have you tried it on the command line, its best to get it to work there first.
berryio api_command ps4-waker
pi@raspberrypi:/usr/share/berryio/includes/commands $ berryio api_command ps4-waker
ERROR: Unknown Command
The only way I can think of that you would get that error is if ps4-waker isn't in this file?
https://github.com/NeonHorizon/berryio/blob/master/includes/configs/api.php