kodi2mqtt
kodi2mqtt copied to clipboard
Feature request: add volume control
Possible to add Volume Control? Seems possible with Application.SetVolume RPC method. I personally need Volume+ and Volume- commands, but vanilla Volume set with percentage parameter will be just fine. Thanks!
and out curent Volume data in topik
Not sure if this still works. Volume Control and other useful things can be accessed via the API. I added this a long time ago. The pull request is still open (Update service.py #27). The code below provides some example API calls. For more info look at the wiki page (JSON RPC API).
` private static final String SEND_TOPIC = "command/api"; private static final String SEND_TOPIC2 = "command/playbackstate"; private static final String PREFIX = "kodi/"; private static final String TABLET = "kodi/tablet/"; public static KodiCmd getVolCmd(int i) { return new KodiCmd(PREFIX+SEND_TOPIC, "{"jsonrpc":"2.0","method":"Application.SetVolume","params":{"volume":" + i + "},"id": 1}"); }
public static KodiCmd getMsgCmd(String title, String msg) {
return new KodiCmd(PREFIX+SEND_TOPIC, "{\"jsonrpc\":\"2.0\",\"method\":\"GUI.ShowNotification\",\"params\":{\"title\":\"" + title + "\",\"message\":\"" + msg + "\"},\"id\":1}");
}
public static KodiCmd getVolCmdTablet(int i) {
return new KodiCmd(TABLET+SEND_TOPIC, "{\"jsonrpc\":\"2.0\",\"method\":\"Application.SetVolume\",\"params\":{\"volume\":" + i + "},\"id\": 1}");
}
public static KodiCmd getMsgCmdTablet(String title, String msg) {
return new KodiCmd(TABLET+SEND_TOPIC, "{\"jsonrpc\":\"2.0\",\"method\":\"GUI.ShowNotification\",\"params\":{\"title\":\"" + title + "\",\"message\":\"" + msg + "\"},\"id\":1}");
}
private KodiCommands() {
cmds = new HashMap<>();
cmds.put("right", new KodiCmd(SEND_TOPIC, "{\"jsonrpc\":\"2.0\",\"method\":\"Input.Right\",\"id\":1}"));
cmds.put("left", new KodiCmd(SEND_TOPIC, "{\"jsonrpc\":\"2.0\",\"method\":\"Input.Left\",\"id\":1}"));
cmds.put("up", new KodiCmd(SEND_TOPIC, "{\"jsonrpc\":\"2.0\",\"method\":\"Input.Up\",\"id\":1}"));
cmds.put("down", new KodiCmd(SEND_TOPIC, "{\"jsonrpc\":\"2.0\",\"method\":\"Input.Down\",\"id\":1}"));
cmds.put("back", new KodiCmd(SEND_TOPIC, "{\"jsonrpc\":\"2.0\",\"method\":\"Input.Back\",\"id\":1}"));
cmds.put("select", new KodiCmd(SEND_TOPIC, "{\"jsonrpc\":\"2.0\",\"method\":\"Input.Select\",\"id\":1}"));
cmds.put("home", new KodiCmd(SEND_TOPIC, "{\"jsonrpc\":\"2.0\",\"method\":\"Input.Home\",\"id\":1}"));
cmds.put("msgStart", new KodiCmd(SEND_TOPIC, "{\"jsonrpc\":\"2.0\",\"method\":\"GUI.ShowNotification\",\"params\":{\"title\":\"Gesture Recognition\",\"message\":\"program started\"},\"id\":1}"));
cmds.put("mute", new KodiCmd(SEND_TOPIC, "{\"jsonrpc\":\"2.0\",\"method\":\"Application.SetMute\",\"params\":{\"mute\":\"toggle\"}}"));
cmds.put("toggle", new KodiCmd(SEND_TOPIC2, "toggle"));
cmds.put("stop", new KodiCmd(SEND_TOPIC2, "0"));
cmds.put("resume", new KodiCmd(SEND_TOPIC2, "1"));
cmds.put("play", new KodiCmd(SEND_TOPIC2, "1"));
cmds.put("pause", new KodiCmd(SEND_TOPIC2, "2"));
cmds.put("next", new KodiCmd(SEND_TOPIC2, "next"));
cmds.put("previous", new KodiCmd(SEND_TOPIC2, "previous"));
}`
I've tried to accept pull request for this (and some other issues) and published a 0.14 release under my fork at https://github.com/eschava/kodi2mqtt/releases/tag/0.14