UNPKG

@ncd-io/node-red-enterprise-sensors

Version:

You can install this library through the Palette Manager in Node-Red's UI.

1,199 lines (1,064 loc) 306 kB
<script type="text/javascript"> RED.nodes.registerType('ncd-gateway-node',{ category: 'NCD', color: '#a6bbcf', icon: "serial.png", paletteLabel: "Wireless Gateway", outputLabels: ["Parsed","Unknown"], defaults: { name: {value: ""}, connection: {value: "", type: "ncd-gateway-config"}, unknown_devices: {value:0}, outputs:{value:1} }, inputs: 1, outputs: 1, label: function() { return this.name || "Wireless Gateway"; }, oneditsave: function(){ this.outputs = $("#node-input-unknown_devices").is(':checked') ? 2 : 1; }, button: { enabled: function() { return true; }, onclick: function() { if (this.changed) { return RED.notify(RED._("notification.warning", {message:RED._("notification.warnings.undeployedChanges")}),"warning"); } var label = this.name; if (label.length > 30) { label = label.substring(0,50)+"..."; } label = label.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"); if (this.payloadType === "date") { label = this._("inject.timestamp"); } if (this.payloadType === "none") { label = this._("inject.blank"); } var node = this; $.ajax({ url: "ncd/wireless/gateway/config/"+this.id, type:"POST", success: function(resp) { RED.notify(node._("Modem "+resp,{label:label}),"success"); }, error: function(jqXHR,textStatus,errorThrown) { RED.notify(node._("common.notification.error",{message:node._("common.notification.errors.not-deployed")}),"error"); } }); } }, }); </script> <script type="text/x-red" data-template-name="ncd-gateway-node"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-connection"><i class="icon-tag"></i> Serial Device</label> <select id="node-input-connection"></select> </div> <div class="form-row"> <label for="node-input-unknown_devices"><i class="icon-tag"></i> Output data from Unknown Devices</label> <input type="checkbox" id="node-input-unknown_devices" value="1"> </div> </script> <style> .ncd-active-check strong{ width: 100%; } .form-row.ncd-active-check{ margin: 12px 0px; border: 1px solid #eee; padding: 12px; border-radius: 8px; } .form-row.ncd-active-check > div{ padding: 4px; } .form-row.ncd-active-check > div > input[type='checkbox']{ width: inherit; } .form-row .caption{ font-size: .95em; padding-left: 1em; margin-top: .25em; } #register_list_539 > div{ display: none; } </style> <script type="text/x-red" data-help-name="ncd-gateway-node"> <h3>Gateway Node</h3> <p>This node is primarily useful for debugging and configuring sensors. This node is equipped with a button on the flow that switches the modem between configuration and listening mode.</p> <h3>Output</h3> <p>Any time sensor data is received from any sensor on the network, this node will output a message containing all pertinant information as in the example below.</p> <h3>Input</h3> <p>The Input connection to this Gateway node allows for sending data to devices. The input connection expects the payload to be an object containging an address and data variable. Address is a string representation of the destination device. Data is a byte array of data to be transmitted as payload to that device. Example "payload":{"address":"00:13:A2:00:01:02:03:04",data:[254,108,1]}</p> <pre> msg = { topic: "sensor_data", payload: { nodeId: 0, firmware: 3, battery: 3.2940600000000004, counter: 37, sensor_type: 1, sensor_data: { humidity: 45.51, temperature: 23.91, }, type: "sensor_data", addr: "00:13:a2:00:41:07:18:81", original: { mac: "00:13:a2:00:41:07:18:81", receive_options: { ack: 0, broadcast: 0, type: "" } }, data: [127,0,3,3,255,37,0,1,0,17,199,9,87], type: "receive_packet" }, _msgid: "391caba.5a19454" } </pre> </script> <script type="text/javascript"> NCD_validators = { number_range: function(l, h, base, property_name = false){ if(!base) base = 10; if(property_name === 'smart_threshold_110'){ return function(v){ var int = parseInt(v, base); if(this.smart_threshold_110 == 0){ console.log('ERROR: Invalid property detect. Setting smart_threshold_110 to default value'); $("#node-input-smart_threshold_110").val(1); return true; } else if(v == undefined){ return true; } return int >= l && int <= h; } } if(property_name === 'acceleration_interrupt_threshold_84'){ return function(v){ var int = parseInt(v, base); if(this.acceleration_interrupt_threshold_84 == 0){ console.log('ERROR: Invalid property detect. Setting smart_threshold_110 to default value'); $("#node-input-acceleration_interrupt_threshold_84").val(0); return true; } else if(v == undefined){ return true; } return int >= l && int <= h; } } if(base == 'decimal'){ return function(v){ var n = parseFloat(v); return n >= l && n <= h; } }else{ return function(v){ var int = parseInt(v, base); // Added to remove new settings from interfering with old nodes if(v == undefined){ return true; } return int >= l && int <= h; } } } } RED.nodes.registerType('ncd-wireless-node',{ category: 'NCD', color: '#a6bbcf', icon: "serial.png", paletteLabel: "Wireless Device", defaults: { name: {value: ""}, connection: {value: "", type: "ncd-gateway-config"}, config_comm: {value: "", type: "ncd-gateway-config", required: false}, addr: {value: ""}, sensor_type: {value: ""}, auto_config: {value: ""}, on_the_fly_enable: {value: ""}, node_id_delay_active: {value: ""}, node_id: {value: 0, validate: NCD_validators.number_range(0, 255)},//0 - 255 delay: {value: 300, validate: NCD_validators.number_range(0, 16777215)},//1 - 16777215 form_network: {value: ""}, destination_active: {value: ""}, destination: {value: '0000FFFF', validate: NCD_validators.number_range(0, 0xFFFFFFFF, 16)},//(0 - 0xFFFFFFFF) power_active: {value: ""}, power: {value: 4},//(0 - 4) retries_active: {value: ""}, retries: {value: 10, validate: NCD_validators.number_range(0, 16)},//(0 - 16) pan_id_active: {value: ""}, pan_id: {value: '7FFF', validate: NCD_validators.number_range(0, 0x7FFF, 16)},//(0 - 0x7FFF) change_detection_t3_active: {value: ""}, change_enabled: {value: ""}, change_pr: {value: "0", validate: NCD_validators.number_range(0, 255)}, change_interval: {value: "0", validate: NCD_validators.number_range(0, 16712198)}, change_detection_ch2_active: {value: ""}, change_enabled_ch2: {value: ""}, change_pr_ch2: {value: "0", validate: NCD_validators.number_range(0, 255)}, change_interval_ch2: {value: "0", validate: NCD_validators.number_range(0, 16712198)}, change_detection_ch3_active: {value: ""}, change_enabled_ch3: {value: ""}, change_pr_ch3: {value: "0", validate: NCD_validators.number_range(0, 255)}, change_interval_ch3: {value: "0", validate: NCD_validators.number_range(0, 16712198)}, current_calibration_13_active: {value: ""}, current_calibration_13: {value: "60600", validate: NCD_validators.number_range(0, 42949672)}, current_calibration_13_dep_active: {value: ""}, current_calibration_13_dep: {value: "60600", validate: NCD_validators.number_range(0, 65535)}, current_calibration_ch2_19_active: {value: ""}, current_calibration_ch2_19: {value: "60600", validate: NCD_validators.number_range(0, 42949672)}, current_calibration_ch2_19_dep_active: {value: ""}, current_calibration_ch2_19_dep: {value: "60600", validate: NCD_validators.number_range(0, 65535)}, current_calibration_ch3_28_active: {value: ""}, current_calibration_ch3_28: {value: "60600", validate: NCD_validators.number_range(0, 42949672)}, current_calibration_ch3_28_dep_active: {value: ""}, current_calibration_ch3_28_dep: {value: "60600", validate: NCD_validators.number_range(0, 65535)}, bp_altitude: {value: "0", validate: NCD_validators.number_range(0, 65535)}, bp_pressure: {value: "0", validate: NCD_validators.number_range(0, 14000)}, bp_temp_prec: {value: "0"}, bp_press_prec: {value: "0"}, amgt_accel: {value: "0"}, amgt_mag: {value: "0"}, amgt_gyro: {value: "0"}, impact_accel_active: {value: ""}, impact_accel: {value: "0"}, impact_data_rate_active: {value: ""}, impact_data_rate: {value: "4"}, impact_threshold_active: {value: ""}, impact_threshold: {value: 25, validate: NCD_validators.number_range(1, 127)}, impact_duration_active: {value: ""}, impact_duration: {value: 1, validate: NCD_validators.number_range(1, 127)}, activ_interr_x: {value: 1, validate: RED.validators.number()}, activ_interr_y: {value: 2, validate: RED.validators.number()}, activ_interr_z: {value: 4, validate: RED.validators.number()}, activ_interr_op: {value: 8, validate: RED.validators.number()}, force_calibration_co2_auto_config: {value: ""}, force_calibration_co2: {value: 400, validate: NCD_validators.number_range(400, 2000)}, force_calibration_co2_535_active: {value: ""}, temperature_offset_44_active: {value: ""}, temperature_offset_44: {value: 4, validate: NCD_validators.number_range(0, 25)}, filtering: {value: 0, validate: RED.validators.number()}, data_rate: {value: 5, validate: RED.validators.number()}, time_series: {value: 0, validate: RED.validators.number()}, reading_type: {value: 1, validate: RED.validators.number()}, mode_80_active: {value: ""}, mode_80: {value: 0}, periodic_check_rate_76_active: {value: ""}, periodic_check_rate_76: {value: 60, validate: NCD_validators.number_range(60, 255)}, ppm_threshold_76_active: {value: ""}, ppm_threshold_76: {value: 100, validate: NCD_validators.number_range(0, 1000)}, alert_duration_76_active: {value: ""}, alert_duration_76: {value: 0, validate: NCD_validators.number_range(0, 255)}, ppm_threshold_76_active: {value: ""}, ppm_threshold_76: {value: 100, validate: NCD_validators.number_range(0, 1000)}, sensor_boot_time_76_active: {value: ""}, sensor_boot_time_76: {value: 30, validate: NCD_validators.number_range(0, 255)}, measurement_mode_80_active: {value: ""}, measurement_mode_80: {value: 0}, on_request_timeout_80_active: {value: ""}, on_request_timeout_80: {value: 1, validate: NCD_validators.number_range(1, 10, 10, 'on_request_timeout_80')}, sensor_boot_time_420ma_active: {value: ""}, sensor_boot_time_420ma: {value: 0, validate: NCD_validators.number_range(0, 255)}, sensor_boot_time_78_active: {value: ""}, sensor_boot_time_78: {value: 0, validate: NCD_validators.number_range(0, 255)}, deadband_80_active: {value: ""}, deadband_80: {value: 0, validate: NCD_validators.number_range(0, 255)}, auto_check_interval_88_active: {value: ""}, auto_check_interval_88: {value: 60, validate: NCD_validators.number_range(0, 65535)}, auto_check_threshold_88_active: {value: ""}, auto_check_threshold_88: {value: 20, validate: NCD_validators.number_range(0, 100)}, filter_80_active: {value: ""}, filter_80: {value: 0}, output_data_rate_p1_81_active: {value: ""}, output_data_rate_p1_81: {value: 0}, output_data_rate_p2_81_active: {value: ""}, output_data_rate_p2_81: {value: 0}, sampling_duration_p1_81_active: {value: ""}, sampling_duration_p1_81: {value: 0}, sampling_duration_p2_81_active: {value: ""}, sampling_duration_p2_81: {value: 0}, led_alert_mode_84_active: {value: ""}, led_alert_mode_84: {value: 0}, led_accelerometer_threshold_84_active: {value: ""}, led_accelerometer_threshold_84: {}, led_velocity_threshold_84_active: {value: ""}, led_velocity_threshold_84: {}, set_rtc_101:{value:0}, set_rtc_202:{value:0}, current_calibration_82:{Value:0}, current_calibration_82_active:{Value:""}, current_calibration_c1_80:{value:178, validate: NCD_validators.number_range(0, 655)}, current_calibration_c1_80_active:{value:""}, current_calibration_c2_80:{value:178, validate: NCD_validators.number_range(0, 655)}, current_calibration_c2_80_active:{value:""}, current_calibration_c3_80:{value:178, validate: NCD_validators.number_range(0, 655)}, current_calibration_c3_80_active:{value:""}, current_calibration_c2_82:{Value:0, validate: NCD_validators.number_range(0, 655)}, current_calibration_c2_82_active:{Value:""}, current_calibration_c3_82:{Value:0, validate: NCD_validators.number_range(0, 655)}, current_calibration_c3_82_active:{Value:""}, output_data_rate_101_active: {value: ""}, output_data_rate_101: {value: 0}, output_data_rate_101_m2_active: {value: ""}, output_data_rate_101_m2: {value: 0}, sampling_duration_101_active: {value: ""}, sampling_duration_101: {value: 1, validate: NCD_validators.number_range(1, 255)}, sampling_interval_101_active: {value: ""}, sampling_interval_101: {value: 1}, sampling_interval_202_active: {value: ""}, sampling_interval_202: {value: 1}, probe_boot_time_202_active: {value: ""}, probe_boot_time_202: {value: 30, validate: NCD_validators.number_range(0, 255)}, full_scale_range_101_active: {value: ""}, full_scale_range_101: {value: 1}, full_scale_range_101_m2_active: {value: ""}, full_scale_range_101_m2: {value: 1}, x_axis_101: {value: ""}, y_axis_101: {value: ""}, z_axis_101: {value: ""}, low_pass_filter_80_active: {value:""}, low_pass_filter_80: {value:0}, high_pass_filter_80_active: {value:""}, high_pass_filter_80: {value:0}, low_pass_filter_81_p2_active: {value:""}, low_pass_filter_81_p2: {value:0}, high_pass_filter_81_p2_active: {value:""}, high_pass_filter_81_p2: {value:0}, roll_angle_threshold_47:{value:0, validate: NCD_validators.number_range(0, 255)}, roll_angle_threshold_47_active:{value:""}, pitch_angle_threshold_47:{value:0, validate: NCD_validators.number_range(0, 255)}, pitch_angle_threshold_47_active:{value:""}, accelerometer_state_108:{value:0}, accelerometer_state_108_active:{value:""}, clear_timers_108_active:{value:""}, clear_timers_108:{value:7}, accelerometer_threshold_108:{value:10, validate: NCD_validators.number_range(0, 255)}, accelerometer_threshold_108_active:{value:""}, debounce_time_108:{value:10, validate: NCD_validators.number_range(0, 255)}, debounce_time_108_active:{value:""}, input_one_108:{value:1}, input_one_108_active:{value:""}, input_two_108:{value:1}, input_two_108_active:{value:""}, input_three_108:{value:0}, input_three_108_active:{value:""}, counter_threshold_108:{value:1000, validate: NCD_validators.number_range(0, 65534)}, counter_threshold_108_active:{value:""}, shift_one_108_active:{value:""}, shift_one_minutes_108:{value:0, validate: NCD_validators.number_range(0, 59)}, shift_one_hours_108:{value:0, validate: NCD_validators.number_range(0, 23)}, shift_two_108_active:{value:""}, shift_two_minutes_108:{value:0, validate: NCD_validators.number_range(0, 59)}, shift_two_hours_108:{value:0, validate: NCD_validators.number_range(0, 23)}, shift_three_108_active:{value:""}, shift_three_minutes_108:{value:0, validate: NCD_validators.number_range(0, 59)}, shift_three_hours_108:{value:0, validate: NCD_validators.number_range(0, 23)}, shift_four_108_active:{value:""}, shift_four_minutes_108:{value:0, validate: NCD_validators.number_range(0, 59)}, shift_four_hours_108:{value:0, validate: NCD_validators.number_range(0, 23)}, counter_threshold_35:{value:50, validate: NCD_validators.number_range(0, 65534)}, counter_threshold_35_active:{value:""}, payload_length_80_active:{value:""}, payload_length_80:{value:3, validate: NCD_validators.number_range(0, 3)}, motion_threshold_46_active:{value:""}, motion_threshold_46:{value: 100, validate: NCD_validators.number_range(0, 4294967295)}, low_calibration_420ma_active:{value:""}, low_calibration_420ma:{value: 68805, validate: NCD_validators.number_range(0, 4294967295)}, mid_calibration_420ma_active:{value:""}, mid_calibration_420ma:{value: 68724, validate: NCD_validators.number_range(0, 4294967295)}, high_calibration_420ma_active:{value:""}, high_calibration_420ma:{value: 68714, validate: NCD_validators.number_range(0, 4294967295)}, thermocouple_type_23_active:{value:""}, thermocouple_type_23:{value: 0}, debounce_time_2_active:{value:""}, debounce_time_2:{value: 10, validate: NCD_validators.number_range(0, 255)}, stay_on_mode_539_active: {value:""}, stay_on_mode_539: {value:0}, baudrate_539_active:{value:""}, baudrate_539:{value: 9600}, rx_timeout_539_active:{value:""}, rx_timeout_539:{value: 10, validate: NCD_validators.number_range(0, 255)}, bootup_time_539_active:{value:""}, bootup_time_539:{value: 10, validate: NCD_validators.number_range(0, 255)}, sensor_add_539_active:{value:""}, sensor_add_539:{value: 10, validate: NCD_validators.number_range(0, 255)}, sub_device_type_539_active:{value:""}, sub_device_type_539:{value: 10, validate: NCD_validators.number_range(0, 255)}, number_of_regs_to_rd_539_active:{value:""}, number_of_regs_to_rd_539:{value: 1, validate: NCD_validators.number_range(0, 32)}, register_value_0_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_1_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_2_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_3_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_4_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_5_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_6_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_7_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_8_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_9_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_10_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_11_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_12_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_13_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_14_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_15_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_16_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_17_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_18_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_19_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_20_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_21_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_22_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_23_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_24_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_25_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_26_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_27_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_28_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_29_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_30_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, register_value_31_539: {value: 0, validate: NCD_validators.number_range(0, 65535)}, number_of_read_retries_539_active:{value:""}, number_of_read_retries_539:{value: 1, validate: NCD_validators.number_range(1, 3)}, read_parameter_539_active:{value:""}, read_parameter_539:{value: 3}, //config_set_reg_active_539:{value:""}, //config_set_reg_539:{value:50, validate: NCD_validators.number_range(0, 65534)}, mode_110_active: {value: ""}, mode_110: {value: 0}, auto_raw_interval_110_active:{value:""}, auto_raw_interval_110: {value: 0, validate: NCD_validators.number_range(0, 255)}, auto_raw_destination_110_active:{value:""}, auto_raw_destination_110: {value: '0000FFFF', validate: NCD_validators.number_range(0, 0xFFFFFFFF, 16)},//(0 - 0xFFFFFFFF) clear_probe_uptimers_110: {value:0}, smart_interval_110_active:{value:""}, smart_interval_110: {value: 0, validate: NCD_validators.number_range(0, 255)}, smart_threshold_110_active:{value:""}, smart_threshold_110: {value: 1, validate: NCD_validators.number_range(1, 65534, 10, "smart_threshold_110")}, smart_threshold_p2_110_active:{value:""}, smart_threshold_p2_110: {value: 1, validate: NCD_validators.number_range(1, 65534, 10, "smart_threshold_110")}, rx485_timeout_1011_active:{value:""}, rx485_timeout_1011:{value: 0, validate: NCD_validators.number_range(0, 255)}, mode_1011_active:{value:""}, mode_1011:{value: 0}, auto_address_timeout_1011_active:{value:""}, auto_address_timeout_1011:{value:0, validate: NCD_validators.number_range(0, 65534)}, mode_531_active: {value: ""}, mode_531: {value: 0}, max_range_58_active:{value: ""}, max_range_58: {value: 0, validate: NCD_validators.number_range(0, 16500)}, calibration_58: {value: 0}, factory_reset_tank_probe_58:{value:0}, push_notification_108_active:{value: ""}, push_notification_108: {value: 0}, push_notification_33_active:{value: ""}, push_notification_33:{value: 0}, clear_counter_33:{value:0}, input_two_33:{value:1}, input_two_33_active:{value:""}, stop_bit_1011_active:{value: ""}, stop_bit_1011:{value:0}, set_parity_1011_active:{value: ""}, set_parity_1011:{value:0}, reboot_1011:{value:0}, fly_interval_110_active:{value: ""}, fly_interval_110:{value: 60}, scd_skip_samples_44_active:{value: ""}, scd_skip_samples_44:{value: 1, validate: NCD_validators.number_range(1, 10)}, sps_skip_samples_32_active:{value: ""}, sps_skip_samples_32:{value: 1, validate: NCD_validators.number_range(1, 10)}, sampling_interval_110_active:{value: ""}, sampling_interval_110: {value: 1, validate: NCD_validators.number_range(0, 8)}, deactivate_activate_accelero_108_active: {value: ""}, deactivate_activate_accelero_108: {value: 1}, reset_timeout_108_active:{value: ""}, reset_timeout_108: {value: 60, validate: NCD_validators.number_range(60, 65535)}, reset_mode_to_disabled_108_active: {value: ""}, reset_mode_to_disabled_108: {value: 0}, transmission_interval_108_active: {value: ""}, transmission_interval_108: {value: 2}, rtc_108:{value:0}, change_otf_interval_active:{value: ""}, change_otf_interval:{value: 60}, sampling_rate_duration_active:{value: ""}, sampling_rate_duration:{value: 30, validate: NCD_validators.number_range(30, 20000)}, stop_sampling:{value:0}, extend_otf_timeout:{value:0}, end_cfg:{value:0}, rtd_type_39_active:{value: ""}, rtd_type_39:{value:0}, rtd_range_39_active:{value: ""}, rtd_range_39:{value:0}, pressure_sensor_fs_ch1_118_active:{value: ""}, pressure_sensor_fs_ch1_118:{value:0}, pressure_sensor_fs_ch2_118_active:{value: ""}, pressure_sensor_fs_ch2_118:{value:0}, auto_check_interval_118_active:{value: ""}, auto_check_interval_118:{value: 0, validate: NCD_validators.number_range(0, 65000)}, press_auto_check_percent_118_active:{value: ""}, press_auto_check_percent_118:{value: 0, validate: NCD_validators.number_range(0, 100)}, temp_auto_check_percent_118_active:{value: ""}, temp_auto_check_percent_118:{value: 0, validate: NCD_validators.number_range(0, 100)}, raw_length_97_active:{value: ""}, raw_length_97:{value:3, validate: NCD_validators.number_range(0, 3)}, raw_timeout_97_active:{value: ""}, raw_timeout_97:{value: 0, validate: NCD_validators.number_range(0, 10)}, fly_rate_97_active:{value: ""}, fly_rate_97:{value: 0}, boot_up_time_97_active:{value: ""}, boot_up_time_97:{value: 0, validate: NCD_validators.number_range(0, 255)}, filter_thermocouple_active:{value: ""}, filter_thermocouple:{value:0}, cold_junction_thermocouple_active:{value: ""}, cold_junction_thermocouple:{value:0}, sample_resolution_thermocouple_active:{value: ""}, sample_resolution_thermocouple:{value:0}, number_of_samples_thermocouple_active:{value: ""}, number_of_samples_thermocouple:{value:0}, measurement_type_thermocouple_active:{value: ""}, measurement_type_thermocouple:{value:0}, mode_97_active: {value: ""}, mode_97: {value: 0}, pressure_sensor_type_21_active: {value: ""}, pressure_sensor_type_21: {value: 0}, thermocouple_type_112_active: {value:""}, thermocouple_type_112: {value: 0}, filter_thermocouple_112_active: {value: ""}, filter_thermocouple_112: {value:0}, cold_junction_thermocouple_112_active: {value: ""}, cold_junction_thermocouple_112: {value:0}, sample_resolution_thermocouple_112_active: {value: ""}, sample_resolution_thermocouple_112: {value:0}, number_of_samples_thermocouple_112_active: {value: ""}, number_of_samples_thermocouple_112: {value:0}, operation_mode_thermocouple_112_active: {value: ""}, operation_mode_thermocouple_112: {value: 0}, measurement_type_thermocouple_112_active: {value: ""}, measurement_type_thermocouple_112: {value:0}, enable_rpm_calculate_status_110_active: {value: ""}, enable_rpm_calculate_status_110: {value:0}, odr_p1_110_active: {value: ""}, odr_p1_110: {value:0}, odr_p2_110_active: {value: ""}, odr_p2_110: {value:0}, sampling_duration_p1_110_active: {value: ""}, sampling_duration_p1_110: {value: 1, validate: NCD_validators.number_range(1, 100)}, sampling_duration_p2_110_active: {value: ""}, sampling_duration_p2_110: {value: 1, validate: NCD_validators.number_range(1, 100)}, low_pass_filter_p1_110_active: {value: ""}, low_pass_filter_p1_110: {value:0}, low_pass_filter_p2_110_active: {value: ""}, low_pass_filter_p2_110: {value:0}, high_pass_filter_p1_110_active: {value: ""}, high_pass_filter_p1_110: {value:0}, high_pass_filter_p2_110_active: {value: ""}, high_pass_filter_p2_110: {value:0}, acceleration_interrupt_threshold_84_active: {value: ""}, acceleration_interrupt_threshold_84: {value: 0, validate: NCD_validators.number_range(0, 40, 10, 'acceleration_interrupt_threshold_84')}, motion_detect_threshold_p1_110_active: {value: ""}, motion_detect_threshold_p1_110: {value: 0, validate: NCD_validators.number_range(0, 40)}, motion_detect_threshold_p2_110_active: {value: ""}, motion_detect_threshold_p2_110: {value: 0, validate: NCD_validators.number_range(0, 40)}, quality_of_service_108_active: {value: ""}, quality_of_service_108: {value: 0}, max_raw_sample_110_active: {value: ""}, max_raw_sample_110: {value: 0}, always_on_120: {value:0}, sensor_reset_120: {value:0}, sensor_calib_120: {value:0}, alert_threshold_120_active: {value: ""}, alert_threshold_120: {value: 0, validate: NCD_validators.number_range(0, 40)}, wood_type_121_active: {value: ""}, wood_type_121: {value: 0}, quality_of_service_121_active: {value: ""}, quality_of_service_121: {value: 0}, enable_filtering_110_active: {value: ""}, enable_filtering_110: {value: 0}, fly_interval_108_active: {value: ""}, fly_interval_108: {value: 60}, tare_the_scale_217: {value:0}, weight_calib_217_active: {value: ""}, weight_calib_217: {value: 0}, sample_rate_108_active: {value: ""}, sample_rate_108: {value: 0}, pressure_limit_26_active: {value: ""}, pressure_limit_26: {value: 5, validate: NCD_validators.number_range(5, 5000)}, auto_pressure_check_26_active: {value: ""}, auto_pressure_check_26: {value: 0}, fsr_420ma_active: {value: ""}, fsr_420ma: {value: 0}, always_on_420ma_active: {value: ""}, always_on_420ma: {value: 0}, pressure_sensor_range_AMS5812_21_active: {value: ""}, pressure_sensor_range_AMS5812_21: {value: 0}, pressure_sensor_range_AMS5915_21_active: {value: ""}, pressure_sensor_range_AMS5915_21: {value: 0}, motion_to_sampling_delay_110_active: {value: ""}, motion_to_sampling_delay_110: {value: 100, validate: NCD_validators.number_range(0, 255)}, max_num_motion_tx_delay_110_active: {value: ""}, max_num_motion_tx_delay_110: {value: 1, validate: NCD_validators.number_range(1, 255)}, enable_sensor_103_active: {value: ""}, enable_sensor_103: {value: 3}, output_data_rate_103_active: {value: ""}, output_data_rate_103: {value: 1}, enable_hp_filter_cutoff_103_active: {value: ""}, enable_hp_filter_cutoff_103: {value: 0}, gyro_fsr_103_active: {value: ""}, gyro_fsr_103: {value: 0}, adxl_fsr_103_active: {value: ""}, adxl_fsr_103: {value: 0}, sampling_duration_103_active: {value: ""}, sampling_duration_103: {value: 20, validate: NCD_validators.number_range(1, 20)}, debounce_time_123: {value:10, validate: NCD_validators.number_range(10, 65000)}, debounce_time_123_active: {value:""}, debounce_time_v10_108: {value:10, validate: NCD_validators.number_range(10, 65000)}, debounce_time_v10_108_active: {value:""}, do_read_rate_270_active: {value:""}, do_read_rate_270: {value:0, validate: NCD_validators.number_range(0, 255)}, do_boot_time_270_active: {value:""}, do_boot_time_270: {value:1, validate: NCD_validators.number_range(1, 60)}, do_dev_id_270_active:{value:""}, do_dev_id_1_270:{value:0, validate: NCD_validators.number_range(0, 255)}, do_dev_id_2_270:{value:0, validate: NCD_validators.number_range(0, 255)}, do_dev_id_3_270:{value:0, validate: NCD_validators.number_range(0, 255)}, do_dev_id_4_270:{value:0, validate: NCD_validators.number_range(0, 255)}, ec_boot_time_270_active: {value:""}, ec_boot_time_270: {value:1, validate: NCD_validators.number_range(1, 60)}, ec_dev_id_270_active:{value:""}, ec_dev_id_1_270:{value:0, validate: NCD_validators.number_range(0, 255)}, ec_dev_id_2_270:{value:0, validate: NCD_validators.number_range(0, 255)}, ec_dev_id_3_270:{value:0, validate: NCD_validators.number_range(0, 255)}, ec_dev_id_4_270:{value:0, validate: NCD_validators.number_range(0, 255)}, push_notification_123_active: {value: ""}, push_notification_123: {value:0}, clear_timers_123_active: {value: ""}, clear_timers_123: {value:7}, input_one_123_active: {value: ""}, input_one_123: {value:1}, input_two_123_active: {value: ""}, input_two_123: {value:1}, input_three_123_active: {value: ""}, input_three_123: {value:1}, oxygen_rate_211_active: {value:""}, oxygen_rate_211: {value:15, validate: NCD_validators.number_range(0, 255)}, oxygen_timeout_211_active: {value:""}, oxygen_timeout_211: {value:600, validate: NCD_validators.number_range(0, 65000)}, oxygen_threshold_211_active: {value:""}, oxygen_threshold_211: {value:8, validate: NCD_validators.number_range(0, 65000)}, interrupt_timeout_108_active: {value:""}, interrupt_timeout_108: {value:0, validate: NCD_validators.number_range(0, 65000)}, acc_threshold_103_active: {value:""}, acc_threshold_103: {value:1, validate: NCD_validators.number_range(0, 255)}, start_sps30_fan_cleaning_53:{value:0}, max_flow_541_active: {value:""}, max_flow_541: {value:1, validate: NCD_validators.number_range(0, 255)}, min_flow_541_active: {value:""}, min_flow_541: {value:1, validate: NCD_validators.number_range(0, 255)}, ct_constant_87_active: {value:""}, ct_constant_87: {value:0, validate: NCD_validators.number_range(0, 4294967295)}, deadband_87_active: {value:""}, deadband_87: {value:0, validate: NCD_validators.number_range(0, 65000)}, sampling_frequency_87_active: {value:""}, sampling_frequency_87: {value:0}, raw_length_87_active: {value:""}, raw_length_87: {value:0}, sampling_interval_80_active:{value: ""}, sampling_interval_80: {value: 1, validate: NCD_validators.number_range(0, 8)}, volume_flow_unit_124_active:{value: ""}, volume_flow_unit_124:{value:1}, total_1_flow_unit_124_active:{value: ""}, total_1_flow_unit_124:{value:1}, total_2_flow_unit_124_active:{value: ""}, total_2_flow_unit_124:{value:1}, total_3_flow_unit_124_active:{value: ""}, total_3_flow_unit_124:{value:1}, pressure_unit_124_active:{value: ""}, pressure_unit_124:{value:1}, total_1_op_mode_124_active:{value: ""}, total_1_op_mode_124:{value:1}, total_2_op_mode_124_active:{value: ""}, total_2_op_mode_124:{value:1}, total_3_op_mode_124_active:{value: ""}, total_3_op_mode_124:{value:1}, conductivity_unit_124_active:{value: ""}, conductivity_unit_124:{value:1}, reset_all_totalizers_124:{value: ""}, screen_control_108_active:{value: ""}, screen_control_108:{value:0}, screen_on_time_108_active:{value:""}, screen_on_time_108:{value:5, validate: NCD_validators.number_range(0, 255)}, oxygen_boot_time_536_active:{value: ""}, oxygen_boot_time_536:{value:3, validate: NCD_validators.number_range(1, 100)}, flow_boot_time_536_active:{value: ""}, flow_boot_time_536:{value:3, validate: NCD_validators.number_range(1, 100)}, oxygen_dev_addr_536_active:{value: ""}, oxygen_addr_1_536:{value:0, validate: NCD_validators.number_range(0, 255)}, oxygen_addr_2_536:{value:0, validate: NCD_validators.number_range(0, 255)}, oxygen_addr_3_536:{value:0, validate: NCD_validators.number_range(0, 255)}, oxygen_addr_4_536:{value:0, validate: NCD_validators.number_range(0, 255)}, flow_dev_addr_536_active:{value: ""}, flow_addr_1_536:{value:0, validate: NCD_validators.number_range(0, 255)}, flow_addr_2_536:{value:0, validate: NCD_validators.number_range(0, 255)}, flow_addr_3_536:{value:0, validate: NCD_validators.number_range(0, 255)}, flow_addr_4_536:{value:0, validate: NCD_validators.number_range(0, 255)}, oxygen_rate_536_active:{value: ""}, oxygen_rate_536:{value:2, validate: NCD_validators.number_range(0, 255)}, oxygen_timeout_536_active:{value: ""}, oxygen_timeout_536:{value:5, validate: NCD_validators.number_range(0, 65000)}, oxygen_max_threshold_s1_536_active:{value: ""}, oxygen_max_threshold_s1_536:{value:12, validate: NCD_validators.number_range(0, 2000)}, oxygen_max_threshold_s2_536_active:{value: ""}, oxygen_max_threshold_s2_536:{value:12, validate: NCD_validators.number_range(0, 2000)}, oxygen_max_threshold_s3_536_active:{value: ""}, oxygen_max_threshold_s3_536:{value:12, validate: NCD_validators.number_range(0, 2000)}, oxygen_max_threshold_s4_536_active:{value: ""}, oxygen_max_threshold_s4_536:{value:12, validate: NCD_validators.number_range(0, 2000)}, oxygen_min_threshold_s1_536_active:{value: ""}, oxygen_min_threshold_s1_536:{value:12, validate: NCD_validators.number_range(0, 2000)}, oxygen_min_threshold_s2_536_active:{value: ""}, oxygen_min_threshold_s2_536:{value:12, validate: NCD_validators.number_range(0, 2000)}, oxygen_min_threshold_s3_536_active:{value: ""}, oxygen_min_threshold_s3_536:{value:12, validate: NCD_validators.number_range(0, 2000)}, oxygen_min_threshold_s4_536_active:{value: ""}, oxygen_min_threshold_s4_536:{value:12, validate: NCD_validators.number_range(0, 2000)}, clear_timers_119_active:{value:""}, clear_timers_119:{value:8}, push_notification_119_active:{value: ""}, push_notification_119:{value: 0}, enable_axis_119_active:{value: ""}, enable_axis_119:{value: 0}, raw_acc_data_119_active:{value: ""}, raw_acc_data_119:{value: 0}, odr_p1_543_active: {value: ""}, odr_p1_543: {value:0}, full_scale_range_543_active: {value: ""}, full_scale_range_543: {value: 1} }, inputs: 0, outputs: 1, label: function() { if(this.name) return this.name; if(this.addr) return this.addr.split(":").slice(4).join(':'); if(this.sensor_type){ var types = { "1": "1 - Temperature/Humidity", "2": "2 - 2ch Push Notification/Voltage Detection", "3": "3 - ADC/4-20 mA/DC Voltage", "4": "4 - Thermocouple", "5": "5 - Gyro/Magneto/Temperature", "6": "6 - Temperature/Barometeric Pressure", "7": "7 - Impact Detection", "8": "8 - Vibration", "9": "9 - Proximity and Light", "10": "10 - Light", "12": "12 - 3 Channel Thermocouple", "13": "13 - Current Monitor", "14": "14 - 1 Channel 4-20mA Receiver", "15": "15 - 1 Channel 0-10V Receiver", "16": "16 - 1 Channel Soil Moisture Sensor", "17": "17 - 1 Channel AC Voltage Sensor", "18": "18 - Pulse Frequency", "19": "19 - 2 Channel Current Sensor", "20": "20 - High Precision Pressure Sensor", "21": "21 - Differential Bidirectional Pressure Sensor", "22": "22 - 0-24V AC/DC Optically Isolated Inputs", "23": "23 - 2 Channel Thermocouple Sensor", "24": "24 - Activity Detection", "25": "25 - Asset Monitor", "26": "26 - Pressure Sensor", "27": "27 - Environmental Sensor", "28": "28 - 3-Phase Current Sensor", "29": "29 - Linear Displacement Sensor", "30": "30 - Structural Monitoring Sensor", "31": "31 - Air Quality TVOC eCO2 Temperature and Humidity Sensor", "32": "32 - Particulate Matter Sensor", "33": "33 - AC Current Detect Sensor", "34": "34 - Tank Level Sensor", "35": "35 - 1 Channel Counter", "36": "36 - 2 Channel Counter", "37": "37 - 7 Channel Push Notification", "39": "39 - 3 Wire RTD Temperature Sensor", "40": "40 - Enterprise Vibration Sensor", "41": "41 - RPM Proximity Sensor", "42": "42 - 0-24VDC Voltage Monitor", "43": "43 - Dual Temperature Humidity Current Detection Sensor", "44": "44 - CO2 Gas Sensor", "45": "45 - 4-20mA 16-Bit Input Transmitter", "46": "46 - Motion Detection Sensor", "47": "47 - Wireless Tilt Sensor", "48": "48 - 4-20mA 16-Bit Input Transmitter", "49": "49 - 6 Channel Thermocouple Sensor", "50": "50 - Predictive Maintenance Sensor", "51": "51 - 6 Channel Current Sensor", "52": "52 - 2 Channel 4-20mA Receiver", "53": "53 - Air Quality CO2 and PM Sensor", "54": "54 - 3 Channel RTD", "56": "56 - 2 Channel 0-10VDC Receiver", "58": "58 - Tank Level v3", "60": "60 - Air Velocity, Pressure, & Temperature Sensor", "61": "61 - pH Temperature Sensor", "62": "62 - ORP Temperature Sensor", "63": "63 - pH and ORPTemperature Sensor", "64": "64 - EC Salinity TDS and Temperature Sensor", "65": "65 - DO and Temperature Sensor", "66": "66 - DO EC Salinity TDS and Temperature Sensor", "67": "67 - PAR Sensor", "69": "69 - Soil Moisture Temperature and EC Sensor", // "70": "70 - 2 Channel Soil Moisture Temperature and EC Sensor", "71": "71 - 3 Channel Soil Moisture Temperature and EC Sensor", "72": "72 - SDI Soil Moisture Temperature Moisture Probe", "74": "74 - Wireless Temp Humidity Pressure Air quality Sensor V2", "75": "75 - Siemens Air Velocity Probe", "76": "76 - Wireless CO Gas Sensor", "77": "77 - 3 Channel SDI Soil Moisture Temperature Moisture Probe", "78": "78 - Oil Particulate Counter Sensor", "79": "79 - Oil Analysis Sensor", "80": "80 - One Channel Vibration Plus", "81": "81 - Two Channel Vibration Plus", "82": "82 - Condition Based/Predictive Maintenance Sensor", "84": "84 - Standalone Smart Vibration Sensor", "87": "87 - Gen 4 One Channel Wireless Current Sensor", "88": "88 - 1 Channel Ultrasound Vibration Sensor", "89": "89 - 2 Channel Ultrasound Vibration Sensor", "90": "90 - DC Current Sensor", "91": "91 - Wireless Air Velocity Sensor HVAC", "92": "92 - Sound Sensor", "95": "95 - 16-Bit 1-Channel 0-24VDC Receiver", "96": "96 - 16-Bit 1-Channel 0-48VDC Receiver", "97": "97 - One channel Dynamic Ultrasound vibration Sensor", "98": "98 - Two channel Dynamic Ultrasound vibration Sensor", "101": "101 - Pro Vibration", "102": "102 - Strain Gauge", "103": "103 - Custom Wireless Accelerometer Sensor", "105": "105 - 1 Channel Automatic Luber With Ultrasound Vibration Sensor", "106": "106 - 2 Channel Automatic Luber With Ultrasound Vibration Sensor", "107": "107 - 4 Channel 4-20mA Receiver", "108": "108 - Machine Uptime Monitoring Sensor", "109": "109 - Wireless Custom Solar Sensor", "110": "110 - One Channel Vibration Plus v4", "111": "111 - Two Channel Vibration Plus v4", "112": "112 - Condition Based/Predictive Maintenance Sensor v4", "114": "114 - Standalone Smart Vibration Sensor v4", "117": "117 - Custom Vibration Sensor PPV", "118": "118 - Dual Pressure and Temperature Sensor", "119": "119 - Wireless Machine Run Time Hour Meter", "120": "120 - Wireless H2S Sensor", "121": "121 - Wireless Wood Moisture Sensor", "122": "122 - Wireless 4-20mA Current Splitter", "123": "123 - 3 Channel Production Counter", "124": "124 - Wireless EH Flow Sensor", "180": "180 - C1D2 One Channel Vibration Plus", "181": "181 - C1D2 Two Channel Vibration Plus", "200": "200 - 4-20mA Pass Through", "202": "202 - Weather Station", "211": "211 - DO and Flow Sensor", "217": "217 - Wireless Weight Scale", "270": "270 - Custom Salinity DO sensor", "502": "502 - C_50-27", "505": "505 - Custom_SAP_Current_1C", "506": "506 - Custom_SAP_Current_3C", "507": "507 - Custom_SAP_Current_7C", "510": "510 - GreenLight", "515": "515 - Custom_SAP_Current_48C", "518": "518 - Custom Air Velocity", "519": "519: Custom Vibration 1", "520": "520: Custom 6 Channel Current Temperature & Humidity", "521": "521 - Custom 3 Channel Light Sensor", "524": "524 - SDI Multi Soil Probe", "531": "531 - Custom Noise Sensor", "535": "535 - Custom CO2 Sensor", "536": "536 - Wireless Oxygen Flow Meter", "537": "537 - Custom Standalone Smart Vibration Sensor", "538": "538 - Custom One Channel Vibration Plus", "539": "539 - RS485 Modbus Wireless Converter", "540": "540 - Wireless Ultrasonic Flow Meter FD-Q32C", "541": "541 - Custom Inline Flow Sensor", "542": "542 - Custom LWGY Flow Sensor", "543": "543 - Custom Seismic Vibration Sensor", "1010": "1010 - RS232 Wireless Converter 1010", "1011": "1011 - RS485 Wireless Converter 1011", "10000": "10000 - 4-Channel Relay", "10006": "10006 - 4-Channel 4-20 mA Input", "10007": "10007 - 4-Channel Current Monitor", "10012": "10012 - 2-Relay + 2-Input", } return types[this.sensor_type]; } return 'Wireless Device'; }, oneditprepare: function() { var that = this; try { $("#node-config-input-addr").autocomplete( "destroy" ); } catch(err) {} $('.ncd-dependent[sensor_type]').hide(); // loops through all settings that need validation and sets default values // Solves library upgrades that add new properties for(let prop in this._def.defaults){ if(typeof this._def.defaults[prop].validate == 'function'){ if(this[prop] == undefined || this[prop] == ""){ $('#node-input-'+prop).val(this._def.defaults[prop].value); } } } $('#node-input-number_of_regs_to_rd_539').change(function(){ let registers = $(this).val(); $('#register_list_539 > div:nth-child(-n+'+registers+')').show(); $('#register_list_539 > div:nth-last-child(-n+'+(32-registers)+')').hide(); }); // $('#node-input-number_of_regs_to_rd_539_active').change(function(){ // if($(this).prop('checked')){ // if($(this).data('target-id')){ // $('#'+$(this).data('target-id')).prop('disabled', false); // } // if($(this).data('target-class')){ // $('.'+$(this).data('target-class')).prop('disabled', false); // } // } // else{ // if($(this).data('target-id')){ // $('#'+$(this).data('target-id')).prop('disabled', true); // } // if($(this).data('target-class')){ // $('.'+$(this).data('target-class')).prop('disabled', true); // } // } // }); $('#node-input-connection').change(function(){ $.getJSON('ncd/wireless/needs_input/'+$(this).val(),function(data) { if(data.is_raw){ that.needs_input = 1; } }); }); $('#node-input-sensor_type').change(() => { var type = $('#node-input-sensor_type').val(); $('.ncd-dependent').hide(); $('.ncd-dependent[data-sensor-'+type+']').show(); if(parseInt(type) >= 10000){ var current = $('#node-input-auto_config').prop('checked'); if(!current) $('#node-input-auto_config').click(); $('#node-input-auto_config').data('_checked', current).closest('.form-row').hide(); this.inputs = 1; }else{ $("#node-input-auto_config").closest('.form-row').show(); if (typeof $("#node-input-auto_config").data('_checked') !== 'undefined'){ $('#node-input-auto_config').prop('checked', $("#node-input-auto_config").data('_checked')).click().removeData('_checked'); } } }); $("#node-lookup-sensors").click(function() { $("#node-lookup-sensors").addClass('disabled'); var connection = RED.nodes.node($('#node-input-connection').val()) $.getJSON('ncd/wireless/sensors/list/'+$('#node-input-connection').val(),function(data) { $("#node-lookup-sensors").removeClass('disabled'); var macs = []; var sensors = {}; $.each(data, function(i, sensor) { macs.push(sensor.mac); sensors[sensor.mac] = sensor; }); $("#node-input-addr").autocomplete({ source:macs, minLength:0, close: function( event, ui ) { $("#node-input-addr").autocomplete( "destroy" ); }, select: function(e, ui){ $('#node-input-sensor_type option[value="'+sensors[ui.item.value].type+'"]').prop('selected', true); $('#node-input-sensor_type').change(); $('#node-input-node_id').val(sensors[ui.item.value].nodeId); } }).autocomplete("search",""); }); }); $('.section .section-control').each(function(){ var handleClick = function(){ $(this).closest('.section').find('input, select').not('.section-control').prop('disabled', !$(this).is(':checked')); } $(this).click(handleClick); handleClick.apply(this); }); $('#config_sensor').click(function(){ if($(this).prop('disabled')) return; $(this).prop('disabled', true).text('Configuring...'); $('#config_response').empty(); $.getJSON('ncd/wireless/sensors/configure/'+that.id,function(data) { var clean = true; for(var i in data){ if(data[i] !== true){ clean = false; $('#config_response').append('<div>Problem setting '+i+': '+data[i]); } } if(clean){ $('#config_response').append('<div>All configurations successfully set</div>');; } $('#config_sensor').prop('disabled', false).text('Configure Now'); }); }); $('.ncd-config-toggle').each(function(){ var handleClick = function(){ // if($(this).prop('checked') && $(this).data('target-id')) { // $('#'+$(this).data('target-id')).prop('disabled', false); // } // else{ // $('#'+$(this).data('target-id')).prop('disabled', true); // } if($(this).prop('checked')){ if($(this).data('target-id')){ $('#'+$(this).data('target-id')).prop('disabled', false); } if($(this).data('target-class')){ $('.'+$(this).data('target-class')).prop('disabled', false); } } else{ if($(this).data('target-id')){ $('#'+$(this).data('target-id')).prop('disabled', true); } if($(this).data('target-class')){ $('.'+$(this).data('target-class')).prop('disabled', true); } // $('#'+$(this).data('target-id')).prop('disabled', true); } } $(this).click(handleClick); handleClick.apply(this); }); }, }); </script> <script type="text/x-red" data-template-name="ncd-wireless-node"> <div class="form-row"> <label for="node-input-name"><i class="icon-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Name"> </div> <div class="form-row"> <label for="node-input-connection"><i class="icon-tag"></i> Serial Device</label> <select id="node-input-connection"></select> </div> <div class="form-row"> <label for="node-input-config_comm"><i class="icon-tag"></i> Serial Device for Config</label> <select id="node-input-config_comm"></select> </div> <div class="form-row"> <label for="node-input-addr"><i class="fa fa-random"></i> Mac Address</label> <input type="text" id="node-input-addr" style="width:60%;" > <a id="node-lookup-sensors" class="btn"><i id="node-lookup-sensors-icon" class="fa fa-search"></i></a> </div> <div class="form-row"> <label for="node-input-sensor_type"><i class="icon-tag"></i> Sensor Type</label> <select id="node-input-sensor_type"> <option value="1">1 - Temperature and Humidity</option> <option value="2">2 - 2ch Push Notification/Voltage Detection</option> <option value="3">3 - ADC/4-20 mA/DC Voltage</option> <option value="4">4 - Thermocoupl