-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript_device_onkyo.lua
More file actions
70 lines (58 loc) · 1.48 KB
/
script_device_onkyo.lua
File metadata and controls
70 lines (58 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
commandArray = {}
-- function to get information from receiver
function onkyo_status(command)
local result = {}
local output = io.popen ('onkyo '..command)
for line in output:lines() do
table.insert(result, line)
end
output:close()
return result
end
-- function to change settings receiver
function onkyo_change(command)
os.execute('/bin/onkyo '..command)
end
-- turn the receiver on/off with dummy switch 'Versterker'
if devicechanged['Versterker']=="On" then
onkyo_change('system-power:on')
else
if devicechanged['Versterker']=="Off" then
onkyo_change('system-power:standby')
end
end
-- Set Onkyo to radio input FM
if devicechanged['Versterker']=="On" then
onkyo_change('SLI24')
else
if devicechanged['Versterker']=="Off" then
onkyo_change('system-power:standby')
end
end
-- Change FM radio channel up
if devicechanged['FM Channel up']=="On" then
onkyo_change('PRSUP')
end
-- Change FM radio channel down
if devicechanged['FM Channel down']=="Off" then
onkyo_change('PRSDOWN')
end
-- Change Volume up
if devicechanged['Volume up']=="On" then
onkyo_change('MVLUP')
end
-- Change Volume down
if devicechanged['Volume down']=="Off" then
onkyo_change('MVLDOWN')
end
-- get status information
if devicechanged['Versterker']=="On" then
status = onkyo_status('system-power:query')
print(status[2])
else
if devicechanged['Versterker']=="Off" then
status = onkyo_status('system-power:query')
print(status[2])
end
end
return commandArray