kodi2mqtt icon indicating copy to clipboard operation
kodi2mqtt copied to clipboard

Feature request: add volume control

Open alexylem opened this issue 6 years ago • 3 comments

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!

alexylem avatar Sep 30 '18 17:09 alexylem

and out curent Volume data in topik

SergMicar avatar Mar 06 '19 09:03 SergMicar

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"));
}`

rubikscuber avatar Sep 15 '19 07:09 rubikscuber

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

eschava avatar Oct 31 '19 11:10 eschava