Hi, i have a nice feature in my kodibuntu, i dont take credits writing the code, cause someone else did.
But its such a nice feature.
From my harmony remote (i configured 2 buttons) with keymap the refer to scripts.
One script will change static background colour, each time i press the same button it will go to the next, same idea for the effectswitch.py
Can we implant this script in hyperion ng, and make and hyperion-remote command? for me there is no need, but maybe others also like this.
Scnd request: in hyperion,ng maybe its nice if we can setup the background to change to some pre-defined effects.
The scripts are down below.
effectswitch.py
Code
import json
import subprocess
colors = ['Snake',
'Strobe',
'Rainbow swirl fast',
'mood-blobs',
'red',
'purple',
]
defaultData = {"color":"purple",
"effect":"Blue\\ mood\\ blobs"
}
effects = ['Blue\\ mood\\ blobs',
'Cold\\ mood\\ blobs',
'Full\\ color\\ mood\\ blobs',
'Green\\ mood\\ blobs',
'Red\\ mood\\ blobs',
'Warm\\ mood\\ blobs',
'Rainbow\\ swirl',
]
def read_current():
try:
with open('/usr/share/hyperion/scripts/currenteffect.json', 'r') as f:
data = json.load(f)
f.close()
if data == '':
return defaultData
else:
return data
except (IOError, ValueError):
return defaultData
def write_current(data):
try:
with open('/usr/share/hyperion/scripts/currenteffect.json', 'w') as f:
json.dump(data, f)
f.close()
except IOError:
pass
def parse_current_effect():
pass
def set_current_effect():
pass
def set_effect(effect):
subprocess.Popen('/usr/share/hyperion/bin/hyperion-remote --priority 100 --effect ' + effect, shell=True)
def main():
current_data = read_current()
for i,effect in enumerate(effects):
if effect == current_data['effect']:
if i == len(effects) - 1:
current_data['effect'] = effects[0]
break
else:
current_data['effect'] = effects[i + 1]
break
write_current(current_data)
set_effect(current_data['effect'])
main()
Alles anzeigen
colourswitch.py
Code
import json
import subprocess
colors = ['purple',
'orange',
'blue',
'green',
'red',
'cyan',
]
defaultData = {"color":"purple",
"effect":"night rider"
}
def read_current():
try:
with open('/usr/share/hyperion/scripts/currentcolour.json', 'r') as f:
data = json.load(f)
f.close()
if data == '':
return defaultData
else:
return data
except (IOError, ValueError):
return defaultData
def write_current(data):
try:
with open('/usr/share/hyperion/scripts/currentcolour.json', 'w') as f:
json.dump(data, f)
f.close()
except IOError:
pass
def parse_current_effect():
pass
def set_current_effect():
pass
def set_color(color):
subprocess.Popen('/usr/share/hyperion/bin/hyperion-remote --priority 100 --color ' + color, shell=True)
def main():
current_data = read_current()
for i,color in enumerate(colors):
if color == current_data['color']:
if i == len(colors) - 1:
current_data['color'] = colors[0]
break
else:
current_data['color'] = colors[i + 1]
break
write_current(current_data)
set_color(current_data['color'])
main()
Alles anzeigen