|
976 | 976 | RED.sidebar.show("help"); |
977 | 977 | } catch (error) { } |
978 | 978 | onEditPrepare(); |
979 | | - node.yamlEditor = RED.editor.createEditor({ |
980 | | - id: 'aceEditor', |
981 | | - mode: 'ace/mode/text' |
982 | | - }); |
983 | | - node.yamlEditor.session.setValue(yamelize()); |
984 | | - $('[id*="node-input-"]').on('keyup change autocompletechange', function () { |
985 | | - try { |
986 | | - node.yamlEditor.session.setValue(yamelize()); |
987 | | - } catch (error) { |
988 | | - } |
989 | | - }); |
990 | 979 | } |
991 | 980 |
|
992 | 981 |
|
|
1217 | 1206 |
|
1218 | 1207 | return toHex(red, green, blue, alpha); |
1219 | 1208 | } |
1220 | | - function yamelize() { |
1221 | | - try { |
1222 | | - const getVal = (selector) => { |
1223 | | - const $el = $(selector); |
1224 | | - if (!$el || !$el.length) return ''; |
1225 | | - const raw = $el.val(); |
1226 | | - if (raw === undefined || raw === null) return ''; |
1227 | | - return typeof raw === 'string' ? raw.trim() : String(raw); |
1228 | | - }; |
1229 | | - const appendLine = (label, value) => { |
1230 | | - if (value) { |
1231 | | - sYaml += ` ${label}: "${value}"\n`; |
1232 | | - } |
1233 | | - }; |
1234 | | - |
1235 | | - const name = getVal('#node-input-name').replace(/"/g, '\\"'); |
1236 | | - let sYaml = `- name: "${name}"\n`; |
1237 | | - |
1238 | | - appendLine('address', getVal('#node-input-GALightSwitch')); |
1239 | | - appendLine('state_address', getVal('#node-input-GALightState')); |
1240 | | - appendLine('brightness_address', getVal('#node-input-GALightBrightness')); |
1241 | | - appendLine('brightness_state_address', getVal('#node-input-GALightBrightnessState')); |
1242 | | - |
1243 | | - // Color temperature handling ----------------------------------- |
1244 | | - let colorTemperatureConfigured = false; |
1245 | | - const kelvinPercent = getVal('#node-input-GALightKelvinPercentage'); |
1246 | | - if (kelvinPercent) { |
1247 | | - sYaml += ' color_temperature_mode: relative\n'; |
1248 | | - appendLine('color_temperature_address', kelvinPercent); |
1249 | | - appendLine('color_temperature_state_address', getVal('#node-input-GALightKelvinPercentageState')); |
1250 | | - colorTemperatureConfigured = true; |
1251 | | - } else { |
1252 | | - const kelvinAddress = getVal('#node-input-GALightKelvin'); |
1253 | | - if (kelvinAddress) { |
1254 | | - const kelvinDpt = getVal('#node-input-dptLightKelvin'); |
1255 | | - if (kelvinDpt === '7.600') { |
1256 | | - sYaml += ' color_temperature_mode: absolute\n'; |
1257 | | - appendLine('color_temperature_address', kelvinAddress); |
1258 | | - if (getVal('#node-input-dptLightKelvinState') === '7.600') { |
1259 | | - appendLine('color_temperature_state_address', getVal('#node-input-GALightKelvinState')); |
1260 | | - } |
1261 | | - colorTemperatureConfigured = true; |
1262 | | - } else if (kelvinDpt === '9.002') { |
1263 | | - sYaml += ' color_temperature_mode: absolute_float\n'; |
1264 | | - appendLine('color_temperature_address', kelvinAddress); |
1265 | | - if (getVal('#node-input-dptLightKelvinState') === '9.002') { |
1266 | | - appendLine('color_temperature_state_address', getVal('#node-input-GALightKelvinState')); |
1267 | | - } |
1268 | | - colorTemperatureConfigured = true; |
1269 | | - } |
1270 | | - } |
1271 | | - } |
1272 | | - if (colorTemperatureConfigured) { |
1273 | | - sYaml += ' min_kelvin: 2200\n'; |
1274 | | - sYaml += ' max_kelvin: 6500\n'; |
1275 | | - } |
1276 | | - |
1277 | | - appendLine('color_address', getVal('#node-input-GALightColor')); |
1278 | | - appendLine('color_state_address', getVal('#node-input-GALightColorState')); |
1279 | | - appendLine('hue_address', getVal('#node-input-GALightHSV_H_DIM')); |
1280 | | - appendLine('hue_state_address', getVal('#node-input-GALightHSV_H_State')); |
1281 | | - appendLine('saturation_address', getVal('#node-input-GALightHSV_S_DIM')); |
1282 | | - appendLine('saturation_state_address', getVal('#node-input-GALightHSV_S_State')); |
1283 | | - |
1284 | | - return sYaml; |
1285 | | - } catch (error) { } |
1286 | | - } |
1287 | | - |
1288 | 1209 | }()) |
1289 | 1210 |
|
1290 | 1211 | </script> |
|
1348 | 1269 | <li><a href="#tabs-4"><i class="fa-solid fa-palette"></i> <span data-i18n="knxUltimateHueLight.tabs.rgb_hsv"></span></a></li> |
1349 | 1270 | <li><a href="#tabs-5"><i class="fa-solid fa-heart-circle-check"></i> <span data-i18n="knxUltimateHueLight.tabs.effects"></span></a></li> |
1350 | 1271 | <li><a href="#tabs-6"><i class="fa-solid fa-code-merge"></i> <span data-i18n="knxUltimateHueLight.tabs.behaviour"></span></a></li> |
1351 | | - <li><a href="#tabs-7"><i class="fa-solid fa-house"></i> <span data-i18n="knxUltimateHueLight.tabs.ha_export"></span></a></li> |
1352 | 1272 | </ul> |
1353 | 1273 | <div id="tabs-1"> |
1354 | 1274 | <p> |
|
1876 | 1796 | </div> |
1877 | 1797 | </p> |
1878 | 1798 | </div> |
1879 | | - <div id="tabs-7"> |
1880 | | - <p> |
1881 | | - <br/> <b>YAML</b> <br/> |
1882 | | - <div style="height: 220px; min-height:150px;" class="node-text-editor" id="aceEditor"></div> |
1883 | | - <!-- <button type="button" class="red-ui-button">Button</button> --> |
1884 | | - </p> |
1885 | | - </div> |
1886 | 1799 | </div> |
1887 | 1800 | </div> |
1888 | 1801 | <br /> |
|
0 commit comments