|
[{"id":"748a9a123fb82754","type":"tab","label":"Pollen","disabled":false,"info":"","env":[]},{"id":"66efc8ab3e071258","type":"http request","z":"748a9a123fb82754","name":"Get data for a nearest hour","method":"GET","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":560,"y":680,"wires":[["30e44156c3b3b844"]]},{"id":"30e44156c3b3b844","type":"csv","z":"748a9a123fb82754","name":"Parse Data","sep":",","hdrin":true,"hdrout":"none","multi":"one","ret":"\\n","temp":"time,latitude,longitude,vertCoord,cnc_POLLEN_ALDER_m22,cnc_POLLEN_GRASS_m32,cnc_POLLEN_MUGWORT_m18,cnc_POLLEN_RAGWEED_m18","skip":"0","strings":true,"include_empty_strings":"","include_null_values":"","x":810,"y":680,"wires":[["be35c11d6f8f37a2"]]},{"id":"d4b5c57364b95d6b","type":"ha-sensor","z":"748a9a123fb82754","name":"Birch","entityConfig":"1c54e03ec90d1c75","version":0,"state":"payload[\"cnc_POLLEN_BIRCH_m22[unit=number/m3]\"]","stateType":"msg","attributes":[],"inputOverride":"merge","outputProperties":[],"x":1490,"y":480,"wires":[[]]},{"id":"7befc5d90f31ecef","type":"function","z":"748a9a123fb82754","name":"Generate URL","func":"// Create a new Date object\nvar currentTimestamp = new Date();\n\n// Get the current year, month, day, and hour\nvar year = currentTimestamp.getUTCFullYear();\nvar month = currentTimestamp.getUTCMonth() + 1; // Month starts from 0, so add 1\nvar day = currentTimestamp.getUTCDate();\nvar hour = currentTimestamp.getUTCHours();\n\n// Format the values as two-digit strings\nvar formattedMonth = month.toString().padStart(2, '0');\nvar formattedDay = day.toString().padStart(2, '0');\nvar formattedHour = hour.toString().padStart(2, '0');\n\n// Construct the time_start and time_end strings\nvar timeStart = year + '-' + formattedMonth + '-' + formattedDay + 'T' + formattedHour + '%3A00%3A00Z';\nvar timeEnd = year + '-' + formattedMonth + '-' + formattedDay + 'T' + formattedHour + '%3A59%3A59Z';\n\n// Store the time variables in flow context or global context\nflow.set('timeStart', timeStart);\nflow.set('timeEnd', timeEnd);\n\n// Construct the complete URL with the time variables\nvar baseUrl = 'https://silam.fmi.fi/thredds/ncss/silam_europe_pollen_v5_9/silam_europe_pollen_v5_9_best.ncd';\nvar latitude = '55.4';\nvar longitude = '37.4';\nvar vertCoord = '12.5';\nvar accept = 'csv';\n\nvar url = baseUrl +\n '?var=cnc_POLLEN_ALDER_m22&var=cnc_POLLEN_BIRCH_m22&var=cnc_POLLEN_GRASS_m32&var=cnc_POLLEN_HAZEL_m23' +\n '&var=cnc_POLLEN_MUGWORT_m18&var=cnc_POLLEN_OLIVE_m28&var=cnc_POLLEN_RAGWEED_m18' +\n '&latitude=' + latitude +\n '&longitude=' + longitude +\n '&time_start=' + timeStart +\n '&time_end=' + timeEnd +\n '&vertCoord=' + vertCoord +\n '&accept=' + accept;\n\n// Set the URL in the output message\nmsg.url = url;\n\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":680,"wires":[["66efc8ab3e071258"]]},{"id":"19de65bf11d3d39c","type":"inject","z":"748a9a123fb82754","name":"","props":[{"p":"payload"}],"repeat":"3600","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":110,"y":680,"wires":[["7befc5d90f31ecef"]]},{"id":"4b9d292a1de24852","type":"ha-sensor","z":"748a9a123fb82754","name":"Adler","entityConfig":"f9d23a0f04bdf521","version":0,"state":"payload[\"cnc_POLLEN_ALDER_m22[unit=number/m3]\"]","stateType":"msg","attributes":[],"inputOverride":"merge","outputProperties":[],"x":1490,"y":560,"wires":[[]]},{"id":"670f155890ec0a38","type":"ha-sensor","z":"748a9a123fb82754","name":"Mugwort","entityConfig":"d01c5a15fa9707ee","version":0,"state":"payload[\"cnc_POLLEN_MUGWORT_m18[unit=number/m3]\"]","stateType":"msg","attributes":[],"inputOverride":"merge","outputProperties":[],"x":1500,"y":740,"wires":[[]]},{"id":"22c58fa3f3b5f126","type":"ha-sensor","z":"748a9a123fb82754","name":"Olive","entityConfig":"f94ecb710f8ebb6f","version":0,"state":"payload[\"cnc_POLLEN_OLIVE_m28[unit=number/m3]\"]","stateType":"msg","attributes":[],"inputOverride":"merge","outputProperties":[],"x":1490,"y":800,"wires":[[]]},{"id":"4d06f621814ca963","type":"ha-sensor","z":"748a9a123fb82754","name":"Hazel","entityConfig":"5cadcbaf30d908c8","version":0,"state":"payload[\"cnc_POLLEN_HAZEL_m23[unit=number/m3]\"]","stateType":"msg","attributes":[],"inputOverride":"merge","outputProperties":[],"x":1490,"y":620,"wires":[[]]},{"id":"0be6c4960f613371","type":"ha-sensor","z":"748a9a123fb82754","name":"Grass","entityConfig":"a1c4296e079f7008","version":0,"state":"payload[\"cnc_POLLEN_GRASS_m32[unit=number/m3]\"]","stateType":"msg","attributes":[],"inputOverride":"merge","outputProperties":[],"x":1490,"y":680,"wires":[[]]},{"id":"b2ed93e7e74fdfbf","type":"ha-sensor","z":"748a9a123fb82754","name":"Ragweed","entityConfig":"8abd148ac6f1560d","version":0,"state":"payload[\"cnc_POLLEN_RAGWEED_m18[unit=number/m3]\"]","stateType":"msg","attributes":[],"inputOverride":"merge","outputProperties":[],"x":1500,"y":860,"wires":[[]]},{"id":"f641c0c44ca4113f","type":"debug","z":"748a9a123fb82754","name":"Json","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1270,"y":480,"wires":[]},{"id":"be35c11d6f8f37a2","type":"function","z":"748a9a123fb82754","name":"Round all data to 0.01","func":"// Input msg object contains your data\nvar data = msg.payload;\n\n// Round the values in cnc_ fields to 0.01\nif (data['cnc_POLLEN_ALDER_m22[unit=number/m3]'] !== undefined) {\n data['cnc_POLLEN_ALDER_m22[unit=number/m3]'] = data['cnc_POLLEN_ALDER_m22[unit=number/m3]'] === 0 ? 0 : Number(data['cnc_POLLEN_ALDER_m22[unit=number/m3]'].toFixed(2));\n}\nif (data['cnc_POLLEN_BIRCH_m22[unit=number/m3]'] !== undefined) {\n data['cnc_POLLEN_BIRCH_m22[unit=number/m3]'] = data['cnc_POLLEN_BIRCH_m22[unit=number/m3]'] === 0 ? 0 : Number(data['cnc_POLLEN_BIRCH_m22[unit=number/m3]'].toFixed(2));\n}\nif (data['cnc_POLLEN_GRASS_m32[unit=number/m3]'] !== undefined) {\n data['cnc_POLLEN_GRASS_m32[unit=number/m3]'] = data['cnc_POLLEN_GRASS_m32[unit=number/m3]'] === 0 ? 0 : Number(data['cnc_POLLEN_GRASS_m32[unit=number/m3]'].toFixed(2));\n}\nif (data['cnc_POLLEN_HAZEL_m23[unit=number/m3]'] !== undefined) {\n data['cnc_POLLEN_HAZEL_m23[unit=number/m3]'] = data['cnc_POLLEN_HAZEL_m23[unit=number/m3]'] === 0 ? 0 : Number(data['cnc_POLLEN_HAZEL_m23[unit=number/m3]'].toFixed(2));\n}\nif (data['cnc_POLLEN_MUGWORT_m18[unit=number/m3]'] !== undefined) {\n data['cnc_POLLEN_MUGWORT_m18[unit=number/m3]'] = data['cnc_POLLEN_MUGWORT_m18[unit=number/m3]'] === 0 ? 0 : Number(data['cnc_POLLEN_MUGWORT_m18[unit=number/m3]'].toFixed(2));\n}\nif (data['cnc_POLLEN_OLIVE_m28[unit=number/m3]'] !== undefined) {\n data['cnc_POLLEN_OLIVE_m28[unit=number/m3]'] = data['cnc_POLLEN_OLIVE_m28[unit=number/m3]'] === 0 ? 0 : Number(data['cnc_POLLEN_OLIVE_m28[unit=number/m3]'].toFixed(2));\n}\nif (data['cnc_POLLEN_RAGWEED_m18[unit=number/m3]'] !== undefined) {\n data['cnc_POLLEN_RAGWEED_m18[unit=number/m3]'] = data['cnc_POLLEN_RAGWEED_m18[unit=number/m3]'] === 0 ? 0 : Number(data['cnc_POLLEN_RAGWEED_m18[unit=number/m3]'].toFixed(2));\n}\n\n// Output the modified data\nmsg.payload = data;\nreturn msg;\n","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":1040,"y":680,"wires":[["f641c0c44ca4113f","d4b5c57364b95d6b","4b9d292a1de24852","4d06f621814ca963","0be6c4960f613371","670f155890ec0a38","22c58fa3f3b5f126","b2ed93e7e74fdfbf"]]},{"id":"1c54e03ec90d1c75","type":"ha-entity-config","server":"1fa5fc45.f8cc84","deviceConfig":"30de6d12df8e96f8","name":"Birch Sensor","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Birch sensor"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"number/m³"},{"property":"state_class","value":"measurement"}],"resend":false,"debugEnabled":false},{"id":"f9d23a0f04bdf521","type":"ha-entity-config","server":"1fa5fc45.f8cc84","deviceConfig":"30de6d12df8e96f8","name":"Adler Sensor","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Adler Sensor"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"number/m³"},{"property":"state_class","value":"measurement"}],"resend":false,"debugEnabled":false},{"id":"d01c5a15fa9707ee","type":"ha-entity-config","server":"1fa5fc45.f8cc84","deviceConfig":"30de6d12df8e96f8","name":"Mugwort Sensor","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Concentration Mugwort"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"number/m³"},{"property":"state_class","value":"measurement"}],"resend":true,"debugEnabled":false},{"id":"f94ecb710f8ebb6f","type":"ha-entity-config","server":"1fa5fc45.f8cc84","deviceConfig":"30de6d12df8e96f8","name":"Olive Sensor","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Olive Sensor"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"number/m³"},{"property":"state_class","value":"measurement"}],"resend":false,"debugEnabled":false},{"id":"5cadcbaf30d908c8","type":"ha-entity-config","server":"1fa5fc45.f8cc84","deviceConfig":"30de6d12df8e96f8","name":"Hazel sensor","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Hazel sensor"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"number/m³"},{"property":"state_class","value":"measurement"}],"resend":false,"debugEnabled":false},{"id":"a1c4296e079f7008","type":"ha-entity-config","server":"1fa5fc45.f8cc84","deviceConfig":"30de6d12df8e96f8","name":"Grass Sensor","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Grass Sensor"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"number/m³"},{"property":"state_class","value":"measurement"}],"resend":false,"debugEnabled":false},{"id":"8abd148ac6f1560d","type":"ha-entity-config","server":"1fa5fc45.f8cc84","deviceConfig":"30de6d12df8e96f8","name":"Ragweed Sensor","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Ragweed Sensor"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"number/m³"},{"property":"state_class","value":"measurement"}],"resend":false,"debugEnabled":false},{"id":"1fa5fc45.f8cc84","type":"server","name":"Home Assistant","addon":true},{"id":"30de6d12df8e96f8","type":"ha-device-config","name":"Polen Sensor (device)","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""}] |
Updated from silam_europe_v5_8_2 to silam_europe_v5_9