Skip to content

Commit bf43d5c

Browse files
authored
remove URL encode form Kodi volume instructions
1 parent dcc4041 commit bf43d5c

File tree

1 file changed

+34
-50
lines changed

1 file changed

+34
-50
lines changed

kodivolume.md

+34-50
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Kodi volume control using dim commands & JSON-RPC
22

33
You can use HA Bridge to adjust the Kodi software volume output. This allows you to use dim commands and set the volume level with percentage values.
4+
45
### What is JSON-RPC?
56

67
The short answer is JSON-RPC an interface to communicate with Kodi. [See the official Kodi Wiki for more info](http://kodi.wiki/view/JSON-RPC_API)
8+
79
### Setup Kodi to allow control through JSON-RPC
810

911
In Kodi navigate to Settings/Services/Control ([screenshot](http://kodi.wiki/view/Settings/Services/Control))
@@ -21,7 +23,7 @@ Make a note of the **PORT**
2123
Access the HA Bridge Configuration in your browser and open the **Manual Add** tab.
2224
#### Name
2325

24-
Give the device a unique name that doesn’t include **“volume”** as it will cause conflicts with the Echo’s built in volume controls. A device name of **“cody sound”** works well.
26+
Give the device a unique name that doesn’t include **“volume”** as it will cause conflicts with the Echo’s built in volume controls. A device name of **“cody sound”** works well.
2527
#### Device type
2628

2729
Select **TCP** in the dropdown
@@ -47,7 +49,7 @@ Before you continue, open your custom URL in a browser (making sure Kodi is runn
4749
"id": "http://xbmc.org/jsonrpc/ServiceDescription.json",
4850
```
4951

50-
If you don’t see something that looks like the code above, then go back and double check your settings.
52+
If you don’t see something that looks like the code above, then go back and double check your settings.
5153
#### The JSON request
5254

5355
The URL is what connects you to Kodi, JSON is what is used to communicate with it. The JSON that is used to set the volume level is:
@@ -62,14 +64,15 @@ Join the two together by adding `?request=` to the end of the URL and then add t
6264
```
6365
http://KODI_USERNAME:[email protected]:8080/jsonrpc?request={"jsonrpc":"2.0","method":"Application.SetVolume","params":{"volume":100},"id":1}
6466
```
65-
##### Testing the request in a browser
67+
### Testing the request in a browser
6668

6769
Go ahead and test the combined URL/JSON in a browser changing **100** to whatever level you want to set. Kodi should adjust the volume accordingly, try a few different levels to be sure it is working correctly.
6870

69-
The browser will reformat the URL each time you press return so don’t build the URL in the browser bar without making a copy first.
71+
The browser will reformat the URL each time you press return so don’t build the URL in the browser bar without making a copy first.
7072

7173
Ideally build the URL in a text document which you can easily edit and then copy/paste each time.
72-
#### Prepare the three URLs
74+
75+
### Prepare the three URLs
7376

7477
You want to end up with three full URLs in your text file, one for each of the commands.
7578

@@ -90,71 +93,52 @@ http://KODI_USERNAME:[email protected]:8080/jsonrpc?request={"jsonrpc"
9093
```
9194
http://KODI_USERNAME:[email protected]:8080/jsonrpc?request={"jsonrpc":"2.0","method":"Application.SetVolume","params":{"volume":0},"id":1}
9295
```
93-
#### Encoding the JSON part
9496

95-
You should now be able to control the volume of Kodi using the structured URL you built above in a browser. If you can’t get it to work in a browser then you won’t be able to get it to work in HA Bridge.
97+
### Test the three URLS
9698

97-
In order for HA Bridge to send the JSON request you need to encode the URL. This means we take this:
99+
You should now be able to control the volume of Kodi using the structured URL you built above in a browser.
98100

99-
```
100-
http://KODI_USERNAME:[email protected]:8080/jsonrpc?request={"jsonrpc":"2.0","method":"Application.SetVolume","params":{"volume":100},"id":1}
101-
```
101+
If you can’t get it to work in a browser then you won’t be able to get it to work in HA Bridge.
102102

103-
And turn it into this:
104103

105-
```
106-
http://KODI_USERNAME:[email protected]:8080/jsonrpc?request=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Application.SetVolume%22%2C%22params%22%3A%7B%22volume%22%3A100%7D%2C%22id%22%3A1%7D
107-
```
104+
### Manually adding the device
108105

109-
Note that we are only encoding the JSON, the URL part we leave as is.
106+
Add a new manual device and give it a name e.g. “Cody Sound”
110107

111-
Using the online tool [www.url-encode-decode.com](http://www.url-encode-decode.com/), copy the JSON part (shown in bold below) and paste it into the left hand field.
108+
Set `Device type` to `Custom`
112109

113-
http://KODI_USERNAME:[email protected]:8080/jsonrpc?request=**{"jsonrpc":"2.0","method":"Application.SetVolume","params":{"volume":100},"id":1}**
110+
Use the same URL for all three (ON, OFF, DIM)
114111

115-
Click the **Encode url** button.
112+
```
113+
http://KODI_USERNAME:[email protected]:8080/jsonrpc?request=
114+
```
116115

117-
Copy the output from the right hand box and paste it on a new line in your text file.
116+
* `HTTP Verb` to `POST`
117+
* `Content type` to `application/json`
118118

119+
**Content body On**
120+
```json
121+
{"jsonrpc":"2.0","method":"Application.SetVolume","params":{"volume":100},"id":1}
122+
```
123+
**Content body Dim**
124+
```json
125+
{"jsonrpc":"2.0","method":"Application.SetVolume","params":{"volume":${intensity.percent}},"id":1}
119126
```
120-
%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Application.SetVolume%22%2C%22params%22%3A%7B%22volume%22%3A100%7D%2C%22id%22%3A1%7D
127+
**Content body Off**
128+
```json
129+
{"jsonrpc":"2.0","method":"Application.SetVolume","params":{"volume":0},"id":1}
121130
```
122-
#### Join the URL and JSON
123131

124-
Finally you want to insert the URL part before the request (shown in bold below)
125132

126-
**http://KODI_USERNAME:[email protected]:8080/jsonrpc?request=**%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22Application.SetVolume%22%2C%22params%22%3A%7B%22volume%22%3A100%7D%2C%22id%22%3A1%7D
127133
### HA Bridge
128134

129-
Paste the final URL in **On URL** field. Just do the one for now, add the device and in the Bridge Control tab click Save.
130-
131-
Test the button in the Bridge Devices tab and hopefully it should turn the volume up in Kodi.
132-
133-
Go ahead and repeat the steps for the **Off URL**. All the same steps but change 100% to 0%. If you want to use the previous URL you can, just find the 100% in the encoded URL.
134-
135-
`…%22%3A%7B%22volume%22%3A`**100**`%7D%2C%22id%22%3A1%7D`
136-
137-
and change it to 0
138-
139-
`…%22%3A%7B%22volume%22%3A`**0**`%7D%2C%22id%22%3A1%7D`
140-
#### Dim JSON
141-
142-
The Dim URL uses the `${intensity.percent}` to take the given number from your voice command and pass it to Kodi.
143-
144-
Here is the JSON to “Dim” the volume
145-
146-
``` json
147-
{"jsonrpc":"2.0","method":"Application.SetVolume","params":{"volume":"${intensity.percent}""},"id":1}
148-
```
149-
150-
You don’t need to encode the `${intensity.percent}` part. This means you can simply replace the number value (100/0) with `${intensity.percent}` as shown below.
135+
Save and test the button in the Bridge Devices tab and hopefully it should turn the volume up in Kodi.
151136

152-
`…%22%3A%7B%22volume%22%3A`**${intensity.percent}**`%7D%2C%22id%22%3A1%7D`
153137
### Controlling the Device
154138

155139
You can use the commands as listed in the [README](https://github.com/bwssytems/ha-bridge#ask-alexa)
156140

157-
“Set Cody Sound to 50 percent”
158-
“Cody Sound to 70 percent”
141+
“Set Cody Sound to 50 percent”
142+
“Cody Sound to 70 percent”
159143

160-
Remembering that “Turn on Cody Sound” will set the volume to 100%, and “Turn off Cody Sound” will mute.
144+
Remembering that “Turn on Cody Sound” will set the volume to 100%, and “Turn off Cody Sound” will mute.

0 commit comments

Comments
 (0)