Skip to content

Instantly share code, notes, and snippets.

@gersilex
Created January 14, 2018 14:05
Show Gist options
  • Save gersilex/8ec49d55b7ad31a3f9e32eb8b221990d to your computer and use it in GitHub Desktop.
Save gersilex/8ec49d55b7ad31a3f9e32eb8b221990d to your computer and use it in GitHub Desktop.
Use a remote/keyboard/mouse on Kodi to send commands to openHAB or other HTTP interfaces (with optional repeations)
[silex@tinywings Downloads]$ ssh media
##############################################
# LibreELEC #
# http://libreelec.tv #
##############################################
LibreELEC (official) Version: 8.0.2
media:~ # pwd
/storage
media:~ # cat custom_scripts/openhab_CMD.py
#!/usr/bin/env python2
import urllib2, sys, time
item = sys.argv[1]
command = sys.argv[2]
try:
repeats = int(sys.argv[3])
except IndexError:
repeats = 1
for _ in range(repeats):
urllib2.urlopen('http://openhab:8080/basicui/CMD?%s=%s' % (item, command))
time.sleep(0.1)
media:~ # cat .kodi/userdata/keymaps/remote.xml
<keymap>
<global>
<remote>
<volumeplus>RunScript(/storage/custom_scripts/openhab_CMD.py,living_avr_volume,INCREASE,4)</volumeplus>
<volumeminus>RunScript(/storage/custom_scripts/openhab_CMD.py,living_avr_volume,DECREASE,4)</volumeminus>
<power>RunScript(/storage/custom_scripts/openhab_CMD.py,living_avr_source,00)</power>
<dvdmenu>RunScript(/storage/custom_scripts/openhab_CMD.py,living_kodi_cinema_mode,TOGGLE)</dvdmenu>
</remote>
</global>
</keymap>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment