zabbix_export:
  version: '7.0'
  template_groups:
    - uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
      name: Templates/Applications
  templates:
    - uuid: af21edc47557400583e537904ea632aa
      template: 'Aranet Cloud'
      name: 'Aranet Cloud'
      description: 'Generated by official Zabbix template tool "Templator"'
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Applications
      items:
        - uuid: 56f89fce2b1541b7898ad56362d4b28a
          name: 'Get data'
          type: SCRIPT
          key: aranet.get_data
          history: '0'
          value_type: TEXT
          params: |
            var Aranet = {
            	params: {},
            	auth_token: null,
            	refresh_token: null,
            	space_id: null,
            
            	setParams: function (params) {
            		['api_endpoint', 'username', 'password', 'space_name'].forEach(function (field) {
            			if (typeof params !== 'object' || typeof params[field] === 'undefined'
            					|| params[field] === '') {
            				throw 'Required param is not set: "' + field + '".';
            			}
            		});
            
            		Aranet.params = params;
            		if (typeof Aranet.params.api_endpoint === 'string') {
            			if (!Aranet.params.api_endpoint.endsWith('/')) {
            				Aranet.params.api_endpoint += '/';
            			}
            		}
            	},
            
            	request: function (method, query, data) {
            		var response,
            			request = new HttpRequest(),
            			url = Aranet.params.api_endpoint + query;
            
            		request.addHeader('Content-Type: application/json');
            
            		if (Aranet.auth_token !== null) {
            			request.addHeader('Authorization: Bearer ' + Aranet.auth_token);
            		}
            
            		if (typeof data !== 'undefined') {
            			data = JSON.stringify(data);
            		}
            
            		switch (method) {
            			case 'get':
            				response = request.get(url, data);
            				break;
            
            			case 'post':
            				response = request.post(url, data);
            				break;
            
            			default:
            				throw 'Unsupported HTTP request method: ' + method;
            		}
            
            		Zabbix.log(4, '[ Aranet scraper ] Received response with status code ' + request.getStatus() + ': ' + response);
            
            		if (request.getStatus() < 200 || request.getStatus() >= 300) {
            			var message = 'Request failed with status code ' + request.getStatus();
            
            			message += ': ' + response;
            			throw message;
            		}
            
            		if (response !== null) {
            			try {
            				response = JSON.parse(response);
            			}
            			catch (error) {
            				throw 'Failed to parse response received from Aranet Cloud. Check debug log for more information.';
            			}
            		}
            
            		return {
            			status: request.getStatus(),
            			response: response
            		};
            	},
            
            	login: function () {
            		var result,
            			data = {
            				login: Aranet.params.username,
            				passw: Aranet.params.password
            			};
            
            		result = Aranet.request('post', 'user/login', data);
            		if (typeof result.response !== 'object'
            				|| typeof result.response.auth === 'undefined'
            				|| result.status != 200) {
            			throw 'Cannot login to Aranet Cloud. Check debug log for more information.';
            		}
            
            		Aranet.auth_token = result.response.auth;
            		Aranet.refresh_token = result.response.refresh;
            
            		var spaces = result.response.spaces;
            		for (var key in spaces) {
            			if (spaces[key] == Aranet.params.space_name) {
            				Aranet.space_id = key;
            				break;
            			}
            		}
            
            		return result.response;
            	},
            
            	logout: function () {
            		var result,
            			data = {
            				refresh: Aranet.refresh_token
            			};
            
            		try {
            			result = Aranet.request('post', 'user/logout', data);
            			if (result.status != 204) {
            				throw 'Cannot logout from Aranet Cloud ' + request.getStatus() + ': ' + result.response;
            			}
            		}
            		catch (error) {
            			Zabbix.log(4, '[ Aranet scraper ] ' + error)
            		}
            	},
            
            	getMetrics: function () {
            		var result = Aranet.request('get', 'metrics/' + Aranet.space_id);
            
            		if (typeof result.response !== 'object'
            				|| typeof result.response.data === 'undefined'
            				|| result.status != 200) {
            			throw 'Cannot get metrics data from Aranet Cloud. Check debug log for more information.';
            		};
            
            		return result.response;
            	},
            
            	getSensors: function () {
            		var result = Aranet.request('get', 'sensors/' + Aranet.space_id + '?fields=devices,metrics,telemetry,name');
            
            		if (typeof result.response !== 'object'
            				|| typeof result.response.data === 'undefined'
            				|| result.status != 200) {
            			throw 'Cannot get sensors data from Aranet Cloud. Check debug log for more information.';
            		};
            
            		return result.response;
            	},
            
            	getGateways: function () {
            		var result = Aranet.request('get', 'gateways/' + Aranet.space_id);
            
            		if (typeof result.response !== 'object'
            			|| typeof result.response.devices === 'undefined'
            			|| result.status != 200) {
            			throw 'Cannot get gateways data from Aranet Cloud. Check debug log for more information.';
            		};
            
            		return result.response;
            	}
            }
            
            var processed_metrics = {},
            	processed_sensors = [];
            
            try {
            	Aranet.setParams(JSON.parse(value));
            
            	Aranet.login();
            
            	var raw_metrics = Aranet.getMetrics(),
            		raw_sensors = Aranet.getSensors(),
            		raw_gateways = Aranet.getGateways();
            
            	Aranet.logout();
            
            	var items = raw_metrics.data.items;
            	for (item_idx in items) {
            		var unit_name,
            			units = items[item_idx].units;
            
            		units.some(function (unit) {
            			unit_name = unit.name;
            			if (unit.selected) {
            				return true;
            			}
            		});
            
            		processed_metrics[items[item_idx].id] = {
            			name: items[item_idx].name,
            			unit: unit_name
            		}
            
            		delete items[item_idx];
            	}
            
            	var items = raw_sensors.data.items;
            	for (item_idx in items) {
            		var upd_ts = 0,
            			gateway = {},
            			sensor_metrics = [],
            			metrics = items[item_idx].metrics,
            			telemetry = items[item_idx].telemetry;
            
            		for (m_idx in metrics) {
            			var unit = processed_metrics[metrics[m_idx].id];
            
            			if (upd_ts < metrics[m_idx].t) {
            				upd_ts = metrics[m_idx].t;
            			}
            
            			sensor_metrics.push({
            				name: unit.name,
            				unit: unit.unit,
            				value: metrics[m_idx].v
            			});
            		}
            
            		for (var t_idx in telemetry) {
            			var unit = processed_metrics[telemetry[t_idx].id];
            
            			if (upd_ts < telemetry[t_idx].t) {
            				upd_ts = telemetry[t_idx].t;
            			}
            
            			sensor_metrics.push({
            				name: unit.name,
            				unit: unit.unit,
            				value: telemetry[t_idx].v
            			});
            		}
            
            		raw_gateways.devices.some(function (dev) {
            			if (items[item_idx].devices[0].id === dev.id) {
            				gateway = {
            					id: dev.id,
            					name: dev.device
            				}
            				return true;
            			}
            		})
            
            		if (upd_ts) {
            			sensor_metrics.push({
            				name: 'Last update',
            				unit: 's',
            				value: upd_ts
            			});
            		}
            
            		var sensor_id = parseInt(items[item_idx].id).toString(16).slice(-5);
            
            		processed_sensors.push({
            			id: sensor_id,
            			name: items[item_idx].name.trim() === '' ? sensor_id : items[item_idx].name,
            			gateway: gateway,
            			metrics: sensor_metrics
            		});
            
            		delete items[item_idx];
            	}
            
            	return JSON.stringify(processed_sensors);
            }
            catch (error) {
            	Zabbix.log(3, '[ Aranet scraper ] ERROR: ' + error);
            	throw 'Scraping failed: ' + error;
            }
          timeout: 10s
          parameters:
            - name: api_endpoint
              value: '{$ARANET.API.ENDPOINT}'
            - name: password
              value: '{$ARANET.API.PASSWORD}'
            - name: space_name
              value: '{$ARANET.API.SPACE_NAME}'
            - name: username
              value: '{$ARANET.API.USERNAME}'
          tags:
            - tag: component
              value: raw
        - uuid: 92fb73948fa74de8a6a219397b77b570
          name: 'Sensors discovery'
          type: DEPENDENT
          key: aranet.sensor.discovery
          history: '0'
          value_type: TEXT
          description: 'Discovery for Aranet Cloud sensors'
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var input = JSON.parse(value),
                  	output = [];
                  
                  input.forEach(function (sensor) {
                  	sensor.metrics.forEach(function (metric) {
                  		output.push(
                  			{
                  				'{#SENSOR_ID}': sensor.id,
                  				'{#SENSOR_NAME}': sensor.name,
                  				'{#GATEWAY_ID}': sensor.gateway.id,
                  				'{#GATEWAY_NAME}': sensor.gateway.name,
                  				'{#METRIC}': metric.name,
                  				'{#UNIT}': metric.unit
                  			}
                  		);
                  	})
                  });
                  
                  return JSON.stringify(output);
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 15m
          master_item:
            key: aranet.get_data
          tags:
            - tag: component
              value: discovery
            - tag: component
              value: raw
      discovery_rules:
        - uuid: c4d177c29cb34e87b6bec0d22bd3ae23
          name: 'Battery voltage discovery'
          type: DEPENDENT
          key: aranet.battery.voltage.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: 'Battery voltage'
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Battery voltage sensors'
          item_prototypes:
            - uuid: b5fca30b1433461f82ea7fe5c72687ef
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.battery.voltage["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
              trigger_prototypes:
                - uuid: 6a931421d804418085e586dfc0e11311
                  expression: 'max(/Aranet Cloud/aranet.battery.voltage["{#GATEWAY_ID}", "{#SENSOR_ID}"],5m) < {$ARANET.BATT.VOLTAGE.MIN.CRIT:"{#SENSOR_NAME}"}'
                  name: '{#METRIC}: Critically low battery voltage on "[{#GATEWAY_NAME}] {#SENSOR_NAME}"'
                  event_name: '{#METRIC}: Critically low battery voltage on "[{#GATEWAY_NAME}] {#SENSOR_NAME}" (below {$ARANET.BATT.VOLTAGE.MIN.CRIT:"{#SENSOR_NAME}"}{#UNIT} for 5m)'
                  priority: HIGH
                  tags:
                    - tag: scope
                      value: capacity
                - uuid: d729130760f9418baa40fb9eeb8a3ca4
                  expression: 'max(/Aranet Cloud/aranet.battery.voltage["{#GATEWAY_ID}", "{#SENSOR_ID}"],5m) < {$ARANET.BATT.VOLTAGE.MIN.WARN:"{#SENSOR_NAME}"}'
                  name: '{#METRIC}: Low battery voltage on "[{#GATEWAY_NAME}] {#SENSOR_NAME}"'
                  event_name: '{#METRIC}: Low battery voltage on "[{#GATEWAY_NAME}] {#SENSOR_NAME}" (below {$ARANET.BATT.VOLTAGE.MIN.WARN:"{#SENSOR_NAME}"}{#UNIT} for 5m)'
                  priority: WARNING
                  dependencies:
                    - name: '{#METRIC}: Critically low battery voltage on "[{#GATEWAY_NAME}] {#SENSOR_NAME}"'
                      expression: 'max(/Aranet Cloud/aranet.battery.voltage["{#GATEWAY_ID}", "{#SENSOR_ID}"],5m) < {$ARANET.BATT.VOLTAGE.MIN.CRIT:"{#SENSOR_NAME}"}'
                  tags:
                    - tag: scope
                      value: capacity
          master_item:
            key: aranet.sensor.discovery
        - uuid: f10b45e1e1024cb19ea8a705281e61fc
          name: 'CO2 discovery'
          type: DEPENDENT
          key: aranet.co2.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: CO₂
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud CO2 sensors'
          item_prototypes:
            - uuid: 5057bec2a8d0446cb3515f1771e30d41
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.co2["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
              trigger_prototypes:
                - uuid: 9d88ae8357b444728c63844462d25f83
                  expression: 'min(/Aranet Cloud/aranet.co2["{#GATEWAY_ID}", "{#SENSOR_ID}"],5m) > {$ARANET.CO2.MAX.CRIT:"{#SENSOR_NAME}"}'
                  name: '{#METRIC}: Critically high CO2 level on "[{#GATEWAY_NAME}] {#SENSOR_NAME}"'
                  event_name: '{#METRIC}: Critically high CO2 level on "[{#GATEWAY_NAME}] {#SENSOR_NAME}" (over {$ARANET.CO2.MAX.CRIT:"{#SENSOR_NAME}"}{#UNIT} for 5m)'
                  priority: HIGH
                  tags:
                    - tag: scope
                      value: notice
                - uuid: cc54c75ee607485981388da0f7f99ea2
                  expression: 'min(/Aranet Cloud/aranet.co2["{#GATEWAY_ID}", "{#SENSOR_ID}"],5m) > {$ARANET.CO2.MAX.WARN:"{#SENSOR_NAME}"}'
                  name: '{#METRIC}: High CO2 level on "[{#GATEWAY_NAME}] {#SENSOR_NAME}"'
                  event_name: '{#METRIC}: High CO2 level on "[{#GATEWAY_NAME}] {#SENSOR_NAME}" (over {$ARANET.CO2.MAX.WARN:"{#SENSOR_NAME}"}{#UNIT} for 5m)'
                  priority: WARNING
                  dependencies:
                    - name: '{#METRIC}: Critically high CO2 level on "[{#GATEWAY_NAME}] {#SENSOR_NAME}"'
                      expression: 'min(/Aranet Cloud/aranet.co2["{#GATEWAY_ID}", "{#SENSOR_ID}"],5m) > {$ARANET.CO2.MAX.CRIT:"{#SENSOR_NAME}"}'
                  tags:
                    - tag: scope
                      value: notice
          master_item:
            key: aranet.sensor.discovery
        - uuid: c42c2ae80f0d40688031f0ef3adb4dfb
          name: 'Current discovery'
          type: DEPENDENT
          key: aranet.current.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: Current
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Current sensors'
          item_prototypes:
            - uuid: 68434a6b6881497b8f7892b00044e3e7
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.current["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: 0d5eca62cf6e4db8abed33e7ad907925
          name: 'Differential Pressure discovery'
          type: DEPENDENT
          key: aranet.diff_pressure.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: 'Differential Pressure'
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Differential Pressure sensors'
          item_prototypes:
            - uuid: d02fa9c559af492d8f23503c6c0e6b67
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.diff_pressure["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: b9f0950111b6488098c79a60b2a444d6
          name: 'Distance discovery'
          type: DEPENDENT
          key: aranet.distance.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: Distance
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Distance sensors'
          item_prototypes:
            - uuid: 4a2dd84d9be34e39b4b8e0c03199ebec
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.distance["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: 7cf9f5296e784045a86aa0fc7bb1ba69
          name: 'Humidity discovery'
          type: DEPENDENT
          key: aranet.humidity.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: Humidity
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud humidity sensors'
          item_prototypes:
            - uuid: b0b25cd929fe493e8db07b19f64e623a
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.humidity["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
              trigger_prototypes:
                - uuid: 9697528bedd64aca9da1e6343182fe0c
                  expression: 'min(/Aranet Cloud/aranet.humidity["{#GATEWAY_ID}", "{#SENSOR_ID}"],5m) > {$ARANET.HUMIDITY.MAX.WARN:"{#SENSOR_NAME}"}'
                  name: '{#METRIC}: High humidity on "[{#GATEWAY_NAME}] {#SENSOR_NAME}"'
                  event_name: '{#METRIC}: High humidity on "[{#GATEWAY_NAME}] {#SENSOR_NAME}" (over {$ARANET.HUMIDITY.MAX.WARN:"{#SENSOR_NAME}"}{#UNIT} for 5m)'
                  priority: HIGH
                  tags:
                    - tag: scope
                      value: notice
                - uuid: 85c1be625bc940588671bc43e6ed6a8a
                  expression: 'max(/Aranet Cloud/aranet.humidity["{#GATEWAY_ID}", "{#SENSOR_ID}"],5m) < {$ARANET.HUMIDITY.MIN.WARN:"{#SENSOR_NAME}"}'
                  name: '{#METRIC}: Low humidity on "[{#GATEWAY_NAME}] {#SENSOR_NAME}"'
                  event_name: '{#METRIC}: Low humidity on "[{#GATEWAY_NAME}] {#SENSOR_NAME}" (below {$ARANET.HUMIDITY.MIN.WARN:"{#SENSOR_NAME}"}{#UNIT} for 5m)'
                  priority: WARNING
                  dependencies:
                    - name: '{#METRIC}: High humidity on "[{#GATEWAY_NAME}] {#SENSOR_NAME}"'
                      expression: 'min(/Aranet Cloud/aranet.humidity["{#GATEWAY_ID}", "{#SENSOR_ID}"],5m) > {$ARANET.HUMIDITY.MAX.WARN:"{#SENSOR_NAME}"}'
                  tags:
                    - tag: scope
                      value: notice
          master_item:
            key: aranet.sensor.discovery
        - uuid: 144396930b4b4049acb4bfd7b183a6f7
          name: 'Illuminance discovery'
          type: DEPENDENT
          key: aranet.illuminance.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: Illuminance
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Illuminance sensors'
          item_prototypes:
            - uuid: 0617cbdf99844d82a469bf600c94bcfa
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.illuminance["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: 16b57e7a700c4041b787a8916442cd59
          name: 'Last update discovery'
          type: DEPENDENT
          key: aranet.last_update.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: 'Last update'
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Last update metric'
          item_prototypes:
            - uuid: 296198c168694dc0bd0af5d1cc07cc0e
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.last_update["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
                - type: JAVASCRIPT
                  parameters:
                    - 'return Math.floor(Date.now()/1000 - Number(value));'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
              trigger_prototypes:
                - uuid: b0aa8bb4e07e47b5824595b824081d75
                  expression: 'last(/Aranet Cloud/aranet.last_update["{#GATEWAY_ID}", "{#SENSOR_ID}"]) > {$ARANET.LAST_UPDATE.MAX.WARN:"{#SENSOR_NAME}"}'
                  name: '{#METRIC}: Sensor data "[{#GATEWAY_NAME}] {#SENSOR_NAME}" is not updated'
                  event_name: '{#METRIC}: Sensor data "[{#GATEWAY_NAME}] {#SENSOR_NAME}" is not updated (more than {$ARANET.LAST_UPDATE.MAX.WARN:"{#SENSOR_NAME}"})'
                  priority: WARNING
                  tags:
                    - tag: scope
                      value: availability
          master_item:
            key: aranet.sensor.discovery
        - uuid: 9b33a2810e644c3c998d431a4a860993
          name: 'pH discovery'
          type: DEPENDENT
          key: aranet.ph.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: pH
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud pH sensors'
          item_prototypes:
            - uuid: ad6f3af944a04305a196ff60bdae078f
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.ph["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: 1763029f67494745a2f52c980ae86b9c
          name: 'Pore Electrical Conductivity discovery'
          type: DEPENDENT
          key: aranet.pore_electric_cond.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: 'Pore Electrical Conductivity'
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Pore Electrical Conductivity sensors'
          item_prototypes:
            - uuid: 4610a3ef84e54ddeb778e4f1c9e7ab8a
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.pore_electric_cond["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: c1a3941026c24d178a494de66c7be2cc
          name: 'PPFD discovery'
          type: DEPENDENT
          key: aranet.ppfd.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: PPFD
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud PPFD sensors'
          item_prototypes:
            - uuid: 7f41b6f57a024e4fa632268bec66fdd3
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.ppfd["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: 11a77f7018ca4b8f92f65888e3e2a237
          name: 'Atmospheric pressure discovery'
          type: DEPENDENT
          key: aranet.pressure.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: 'Atmospheric Pressure'
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud atmospheric pressure sensors'
          item_prototypes:
            - uuid: 3534343a6f78415e94b52f791a1a419a
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.pressure["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: 6d5e1eebba704d5e88aa67ed029d95ca
          name: 'Pulses discovery'
          type: DEPENDENT
          key: aranet.pulses.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: Pulses
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Pulses sensors'
          item_prototypes:
            - uuid: 471e5f773216407e819c840161562d1e
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.pulses["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: 92f27211f4dd4f61b7939cf8b07fc959
          name: 'Pulses Cumulative discovery'
          type: DEPENDENT
          key: aranet.pulses_cumulative.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: 'Pulses Cumulative'
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Pulses Cumulative sensors'
          item_prototypes:
            - uuid: da698f1bec144ab8aa8d960669c385d5
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.pulses_cumulative["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: 2caab3aefe0b498588aa3ec0d8578e09
          name: 'RSSI discovery'
          type: DEPENDENT
          key: aranet.rssi.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: RSSI
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud RSSI sensors'
          item_prototypes:
            - uuid: eefb5804ec224d26a3050246907c35aa
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.rssi["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: 4d6116d2bd3049b9bb550e1d77338b2e
          name: 'Soil Dielectric Permittivity discovery'
          type: DEPENDENT
          key: aranet.soil_dielectric_perm.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: 'Soil Dielectric Permittivity'
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Soil Dielectric Permittivity sensors'
          item_prototypes:
            - uuid: 53b7bb6bab76432f95599917e61a3ea7
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.soil_dielectric_perm["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: e44cc900de3b4353bbccc6f01388c103
          name: 'Soil Electrical Conductivity discovery'
          type: DEPENDENT
          key: aranet.soil_electric_cond.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: 'Soil Electrical Conductivity'
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Soil Electrical Conductivity sensors'
          item_prototypes:
            - uuid: 2f73f57b147c4d3498bd46a4048e2418
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.soil_electric_cond["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: 215affa3d0d34aa2b27be4ec75ba3349
          name: 'Temperature discovery'
          type: DEPENDENT
          key: aranet.temp.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: Temperature
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud temperature sensors'
          item_prototypes:
            - uuid: 86a562af26184359ac7d2287c6bd87c6
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.temp["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: 9e9bf9e27be743368c50036f02fab572
          name: 'Voltage discovery'
          type: DEPENDENT
          key: aranet.voltage.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: Voltage
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Voltage sensors'
          item_prototypes:
            - uuid: 461f54e7c7ce4658b8acc83be8d6906c
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.voltage["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: c059e164b01242b78ab8505d12c2d291
          name: 'Volumetric Water Content discovery'
          type: DEPENDENT
          key: aranet.volum_water_content.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: 'Volumetric Water Content'
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Volumetric Water Content sensors'
          item_prototypes:
            - uuid: 8a03e78d9f4145b58c55d04189b90423
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.volumetric.water.content["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
        - uuid: 414889299c224d748c857fcf028d9e96
          name: 'Weight discovery'
          type: DEPENDENT
          key: aranet.weight.discovery
          filter:
            evaltype: AND
            conditions:
              - macro: '{#GATEWAY_ID}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
              - macro: '{#GATEWAY_NAME}'
                value: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
              - macro: '{#METRIC}'
                value: Weight
              - macro: '{#SENSOR_ID}'
                value: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
              - macro: '{#SENSOR_NAME}'
                value: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
                operator: NOT_MATCHES_REGEX
          description: 'Discovery for Aranet Cloud Weight sensors'
          item_prototypes:
            - uuid: 6eb5e840b089469ca644a20bcb7739d4
              name: '{#METRIC}: [{#GATEWAY_NAME}] {#SENSOR_NAME}'
              type: DEPENDENT
              key: 'aranet.weight["{#GATEWAY_ID}", "{#SENSOR_ID}"]'
              value_type: FLOAT
              units: '{#UNIT}'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - '$[?(@.id == "{#SENSOR_ID}" && @.name == "{#SENSOR_NAME}")].metrics[?(@.name == "{#METRIC}")].value.first()'
              master_item:
                key: aranet.get_data
              tags:
                - tag: component
                  value: '{#METRIC}'
          master_item:
            key: aranet.sensor.discovery
      tags:
        - tag: class
          value: service
        - tag: target
          value: aranet
      macros:
        - macro: '{$ARANET.API.ENDPOINT}'
          value: 'https://aranet.cloud/api'
          description: 'Aranet Cloud API endpoint.'
        - macro: '{$ARANET.API.PASSWORD}'
          value: '<PUT YOUR PASSWORD>'
          description: 'Aranet Cloud password.'
        - macro: '{$ARANET.API.SPACE_NAME}'
          value: '<PUT YOUR SPACE NAME>'
          description: 'Aranet Cloud organization name.'
        - macro: '{$ARANET.API.USERNAME}'
          value: '<PUT YOUR USERNAME>'
          description: 'Aranet Cloud username.'
        - macro: '{$ARANET.BATT.VOLTAGE.MIN.CRIT}'
          value: '2'
          description: 'Battery voltage critical threshold.'
        - macro: '{$ARANET.BATT.VOLTAGE.MIN.WARN}'
          value: '1'
          description: 'Battery voltage warning threshold.'
        - macro: '{$ARANET.CO2.MAX.CRIT}'
          value: '1000'
          description: 'CO2 critical threshold.'
        - macro: '{$ARANET.CO2.MAX.WARN}'
          value: '600'
          description: 'CO2 warning threshold.'
        - macro: '{$ARANET.HUMIDITY.MAX.WARN}'
          value: '70'
          description: 'Maximum humidity threshold.'
        - macro: '{$ARANET.HUMIDITY.MIN.WARN}'
          value: '20'
          description: 'Minimum humidity threshold.'
        - macro: '{$ARANET.LAST_UPDATE.MAX.WARN}'
          value: 1h
          description: 'Data update delay threshold.'
        - macro: '{$ARANET.LLD.FILTER.GATEWAY_ID.MATCHES}'
          value: .+
          description: 'Filter of discoverable sensors by gateway id.'
        - macro: '{$ARANET.LLD.FILTER.GATEWAY_NAME.MATCHES}'
          value: .+
          description: 'Filter of discoverable sensors by gateway name.'
        - macro: '{$ARANET.LLD.FILTER.GATEWAY_NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude discoverable sensors by gateway name.'
        - macro: '{$ARANET.LLD.FILTER.SENSOR_ID.MATCHES}'
          value: .+
          description: 'Filter of discoverable sensors by id.'
        - macro: '{$ARANET.LLD.FILTER.SENSOR_NAME.MATCHES}'
          value: .+
          description: 'Filter of discoverable sensors by name.'
        - macro: '{$ARANET.LLD.FILTER.SENSOR_NAME.NOT_MATCHES}'
          value: CHANGE_IF_NEEDED
          description: 'Filter to exclude discoverable sensors by name.'
