{"id":3054,"date":"2025-12-28T18:30:33","date_gmt":"2025-12-28T17:30:33","guid":{"rendered":"https:\/\/dalstroka-innafor.net\/?p=3054"},"modified":"2025-12-28T18:30:33","modified_gmt":"2025-12-28T17:30:33","slug":"opne-data-og-linux","status":"publish","type":"post","link":"https:\/\/dalstroka-innafor.net\/?p=3054","title":{"rendered":"Opne data og linux"},"content":{"rendered":"\n<p>Joda. Det finst app. Det finst nettside og. Men yr.no i tekstformat, det er og veldig hendig.<\/p>\n\n\n\n<p>Kvar gong eg loggar meg p\u00e5 ei maskin via SSH, eller kvar gong eg startar eit terminalvindu, s\u00e5 f\u00e5r eg opp<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/dalstroka-innafor.net\/wp-content\/uploads\/2025\/12\/image-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"771\" height=\"472\" src=\"https:\/\/dalstroka-innafor.net\/wp-content\/uploads\/2025\/12\/image-1.png\" alt=\"\" class=\"wp-image-3056\" srcset=\"https:\/\/dalstroka-innafor.net\/wp-content\/uploads\/2025\/12\/image-1.png 771w, https:\/\/dalstroka-innafor.net\/wp-content\/uploads\/2025\/12\/image-1-300x184.png 300w, https:\/\/dalstroka-innafor.net\/wp-content\/uploads\/2025\/12\/image-1-768x470.png 768w\" sizes=\"auto, (max-width: 771px) 100vw, 771px\" \/><\/a><\/figure>\n\n\n\n<p> siste oppdaterte verdata fr\u00e5 yr.no. Korleis? Eit lite shell-skript;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/bin\/bash\n\n# URL for the weather data (replace this with the actual URL where you are fetching the data from)\nAPI_OBSERVASJONAR=\"https:\/\/www.yr.no\/api\/v0\/locations\/5-42940\/observations\/day\"\nAPI_GJELDANDE=\"https:\/\/www.yr.no\/api\/v0\/locations\/5-42940\/forecast\/currenthour\"\n\n# Fetch the data using wget\nwget -q -O weather_data.json \"$API_OBSERVASJONAR\"\nwget -q -O currenthour.json \"$API_GJELDANDE\"\n\n# Check if wget was successful\nif &#91; $? -ne 0 ]; then\n    echo \"Failed to fetch data\"\n    exit 1\nfi\n\n# Parse the JSON and extract the 'max_temp' value using jq\nmax_temp=$(jq '.historical.summary.temperature.max.value' weather_data.json)\nmin_temp=$(jq '.historical.summary.temperature.min.value' weather_data.json)\nprecipitation=$(jq '.historical.summary.precipitation.total.value' weather_data.json)\nwind=$(jq '.historical.summary.wind.maxWind.value' weather_data.json)\nwindGust=$(jq '.historical.summary.wind.maxGust.value' weather_data.json)\ncurrent_temp=$(jq '.temperature.value' currenthour.json)\nfeelslike_temp=$(jq '.temperature.feelsLike' currenthour.json)\n\n# Check if jq successfully extracted the value\nif &#91; $? -ne 0 ]; then\n    echo \"Failed to parse JSON\"\n    exit 1\nfi\n\n# Output the result\nclear\necho \"M\u00c5LEDATA FOR SINNES M\u00c5LESTASJON, METEROLOGISK INSTITUTT\"\necho\necho \"Gjeldande temperatur: $current_temp\u00b0\"\necho \"Temperatur kjennest som: $feelslike_temp\u00b0\"\necho\necho \"Makstemp siste 24 timer: $max_temp\u00b0\"\necho \"Minimumstemp siste 24 timer: $min_temp\u00b0\"\necho\necho \"Nedb\u00f8r siste 24 timar: $precipitation mm\"\necho\necho \"Vind siste d\u00f8gn: $wind m\/s (maks vindkast: $windGust m\/s)\"\necho\n\n# Clean up by removing the downloaded JSON file\nrm weather_data.json\nrm currenthour.json\n<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Joda. Det finst app. Det finst nettside og. Men yr.no i tekstformat, det er og veldig hendig. Kvar gong eg loggar meg p\u00e5 ei maskin via SSH, eller kvar gong eg startar eit terminalvindu, s\u00e5 f\u00e5r eg opp siste oppdaterte verdata fr\u00e5 yr.no. Korleis? Eit lite shell-skript;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_share_on_mastodon":"0"},"categories":[4],"tags":[995,440,970,993,994],"class_list":["post-3054","post","type-post","status-publish","format-standard","hentry","category-ikt","tag-kode","tag-linux","tag-script","tag-shell","tag-yr"],"share_on_mastodon":{"url":"https:\/\/snabelen.no\/@dalstroka\/115798378836407158","error":""},"_links":{"self":[{"href":"https:\/\/dalstroka-innafor.net\/index.php?rest_route=\/wp\/v2\/posts\/3054","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalstroka-innafor.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalstroka-innafor.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalstroka-innafor.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalstroka-innafor.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3054"}],"version-history":[{"count":1,"href":"https:\/\/dalstroka-innafor.net\/index.php?rest_route=\/wp\/v2\/posts\/3054\/revisions"}],"predecessor-version":[{"id":3057,"href":"https:\/\/dalstroka-innafor.net\/index.php?rest_route=\/wp\/v2\/posts\/3054\/revisions\/3057"}],"wp:attachment":[{"href":"https:\/\/dalstroka-innafor.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3054"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalstroka-innafor.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3054"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalstroka-innafor.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3054"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}