Rev 1625 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1625 | Rev 1626 | ||
|---|---|---|---|
| Line 53... | Line 53... | ||
| 53 | ir_module.Bind("onStatusChange", test_status); |
53 | ir_module.Bind("onStatusChange", test_status); |
| 54 | ir_module.Bind("onPressed", test_press); |
54 | ir_module.Bind("onPressed", test_press); |
| 55 | ir_module.Bind("onReleased", test_release); |
55 | ir_module.Bind("onReleased", test_release); |
| 56 | 56 | ||
| 57 | 57 | ||
| 58 | /*CreateModuleAlias("bardisk", "Dimmer230", 2, { "channel" : 0 }); |
- | |
| 59 | CreateModuleAlias("bokhylla", "Dimmer230", 1, { "channel" : 0 }); |
- | |
| 60 | CreateModuleAliasGroup("vardagsrum", [ "bokhylla", "bardisk" ]); |
- | |
| 61 | */ |
- | |
| 62 | 58 | ||
| 63 | function fadeto(alias, level, speed) |
- | |
| 64 | { |
- | |
| 65 | var alias_data = resolvealias(alias); |
- | |
| 66 | - | ||
| 67 | if (alias_data == null) |
- | |
| 68 | { |
- | |
| 69 | return "No such module name found"; |
- | |
| 70 | } |
- | |
| 71 | - | ||
| 72 | if (alias_data["is_group"]) |
- | |
| 73 | { |
- | |
| 74 | var result = ""; |
- | |
| 75 | - | ||
| 76 | for (var n = 0; n < alias_data["aliases"].length; n++) |
- | |
| 77 | { |
- | |
| 78 | result += fadeto(alias_data["aliases"][n], level, speed) + "\n"; |
- | |
| 79 | } |
- | |
| 80 | - | ||
| 81 | return result; |
- | |
| 82 | } |
- | |
| 83 | - | ||
| 84 | if (alias_data["module_name"] != "Dimmer230") |
- | |
| 85 | { |
- | |
| 86 | return "Module type " + alias_data["module_name"] + " is not valid for this action, valid are Dimmer230"; |
- | |
| 87 | } |
- | |
| 88 | - | ||
| 89 | if (!speed) |
- | |
| 90 | { |
- | |
| 91 | speed = 135; |
- | |
| 92 | } |
- | |
| 93 | - | ||
| 94 | return Dimmer230_AbsoluteFade(alias_data["module_id"], alias_data["extra"], speed, level); |
- | |
| 95 | } |
- | |
| 96 | RegisterConsoleCommand(fadeto, function(args) { return StandardAutocomplete(args, Dimmer230.instance_.GetAvailableNames(), [ 0, 50, 100, 150, 200, 255 ], [ 50, 135, 200, 255 ]); }); |
- | |
| 97 | - | ||
| 98 | function irsend_autocomplete(args) |
- | |
| 99 | { |
- | |
| 100 | // args[0] == command name |
- | |
| 101 | var arg_index = args.length - 2; |
- | |
| 102 | - | ||
| 103 | if (arg_index == 0) |
- | |
| 104 | { |
- | |
| 105 | return irTransmit.instance_.GetAvailableNames(); |
- | |
| 106 | } |
- | |
| 107 | else if (arg_index == 1) |
- | |
| 108 | { |
- | |
| 109 | var remotes = Storage_GetParameters("RemoteList"); |
- | |
| 110 | - | ||
| 111 | var result = new Array(); |
- | |
| 112 | - | ||
| 113 | for (var name in remotes) |
- | |
| 114 | { |
- | |
| 115 | result.push(name); |
- | |
| 116 | } |
- | |
| 117 | - | ||
| 118 | return result; |
- | |
| 119 | } |
- | |
| 120 | else if (arg_index == 2) |
- | |
| 121 | { |
- | |
| 122 | var remote_storage_name = Storage_GetParameter("RemoteList", args[arg_index]); |
- | |
| 123 | - | ||
| 124 | var buttons = Storage_GetParameters(remote_storage_name); |
- | |
| 125 | - | ||
| 126 | var result = new Array(); |
- | |
| 127 | - | ||
| 128 | for (var name in buttons) |
- | |
| 129 | { |
- | |
| 130 | result.push(name); |
- | |
| 131 | } |
- | |
| 132 | - | ||
| 133 | return result; |
- | |
| 134 | } |
- | |
| 135 | - | ||
| 136 | return new Array(); |
- | |
| 137 | } |
- | |
| 138 | - | ||
| 139 | - | ||
| 140 | function irsend(alias, remote, button) |
- | |
| 141 | { |
- | |
| 142 | var alias_data = resolvealias(alias); |
- | |
| 143 | - | ||
| 144 | if (alias_data == null) |
- | |
| 145 | { |
- | |
| 146 | return "No such module name found"; |
- | |
| 147 | } |
- | |
| 148 | - | ||
| 149 | if (alias_data["is_group"]) |
- | |
| 150 | { |
- | |
| 151 | var result = ""; |
- | |
| 152 | - | ||
| 153 | for (var n = 0; n < alias_data["aliases"].length; n++) |
- | |
| 154 | { |
- | |
| 155 | result += irsend(alias_data["aliases"][n], remote, button) + "\n"; |
- | |
| 156 | } |
- | |
| 157 | - | ||
| 158 | return result; |
- | |
| 159 | } |
- | |
| 160 | - | ||
| 161 | if (alias_data["module_name"] != "irTransmit") |
- | |
| 162 | { |
- | |
| 163 | return "Module type " + alias_data["module_name"] + " is not valid for this action, valid are irTransmit"; |
- | |
| 164 | } |
- | |
| 165 | - | ||
| 166 | var remote_storage_name = Storage_GetParameter("RemoteList", remote); |
- | |
| 167 | - | ||
| 168 | if (!remote_storage_name) |
- | |
| 169 | { |
- | |
| 170 | return "No such remote name in list, " + remote; |
- | |
| 171 | } |
- | |
| 172 | - | ||
| 173 | var button_string = Storage_GetParameter(remote_storage_name, button); |
- | |
| 174 | - | ||
| 175 | if (!button_string) |
- | |
| 176 | { |
- | |
| 177 | return "No such button " + button + " found on remote " + remote; |
- | |
| 178 | } |
- | |
| 179 | - | ||
| 180 | var button = eval("(" + button_string + ")"); |
- | |
| 181 | - | ||
| 182 | Log(JSON.stringify(button)); |
- | |
| 183 | Log(alias_data["module_id"]); |
- | |
| 184 | Log(alias_data["extra"]); |
- | |
| 185 | Log(button["protocol"]); |
- | |
| 186 | Log(button["data"]); |
- | |
| 187 | - | ||
| 188 | return irTransmit_SendCode(alias_data["module_id"], alias_data["extra"], "Burst", button["protocol"], button["data"]); |
- | |
| 189 | } |
- | |
| 190 | RegisterConsoleCommand(irsend, irsend_autocomplete); |
- | |
| 191 | 59 | ||
| 192 | 60 | ||
| 193 | function media(mode) |
61 | function media(mode) |
| 194 | { |
62 | { |
| 195 | if (!mode) |
63 | if (!mode) |