めめめ

たまに書くメモです

Wundergroundを使う場合。(Huginn)

Wundergroundを使う場合。

準備

まず開発者登録。
https://www.wunderground.com/weather/api/ Key IDを使うんでメモ。

Weather Agent

locationはwundergroundで検索した時のURLに含まれてるzmw:00000.1.47772みたいなのとか緯度経度とか好きなものを。

{
  "service": "wunderground",
  "api_key": "Key ID",
  "location": "各々",
  "which_day": "1",
  "language": "JP",
  "expected_update_period_in_days": "2"
}

そしたら下みたいなJSON返ってくるんで

{
  "date": {
    "epoch": "1485165600",
    "pretty": "7:00 PM JST on 一月 23, 2017",
    "day": 23,
    "month": 1,
    "year": 2017,
    "yday": 22,
    "hour": 19,
    "min": "00",
    "sec": 0,
    "isdst": "0",
    "monthname": "一月",
    "monthname_short": "1月",
    "weekday_short": "月曜日",
    "weekday": "月曜日",
    "ampm": "PM",
    "tz_short": "JST",
    "tz_long": "Asia/Tokyo"
  },
  "period": 1,
  "high": {
    "fahrenheit": "40",
    "celsius": "4"
  },
  "low": {
    "fahrenheit": "30",
    "celsius": "-1"
  },
  "conditions": "",
  "icon": "nt_partlycloudy",
  "icon_url": "http://icons.wxug.com/i/c/k/nt_partlycloudy.gif",
  "skyicon": "",
  "pop": "20",
  "qpf_allday": {
    "in": 0.12,
    "mm": 3
  },
  "qpf_day": {
    "in": 0.12,
    "mm": 3
  },
  "qpf_night": {
    "in": 0.0,
    "mm": 0
  },
  "snow_allday": {
    "in": 0.6,
    "cm": 1.5
  },
  "snow_day": {
    "in": 0.6,
    "cm": 1.5
  },
  "snow_night": {
    "in": 0.0,
    "cm": 0.0
  },
  "maxwind": {
    "mph": 10,
    "kph": 16,
    "dir": "北西",
    "degrees": 309
  },
  "avewind": {
    "mph": 8,
    "kph": 13,
    "dir": "北西",
    "degrees": 309
  },
  "avehumidity": 63,
  "maxhumidity": 0,
  "minhumidity": 0,
  "title": "月曜日の夜",
  "fcttext": "所により曇り。 最低気温30℉。 西の風は変わりやすい。",
  "fcttext_metric": "所により曇り。 最低気温-1℃。 西の風は変わりやすい。",
  "location": "緯度, 経度"
}

Slack Agent

例えば

{
  "webhook_url": "各々",
  "channel": "各々",
  "username": "各々",
  "icon": "各々",
  "message": "{{date.month}}月{{date.day}}日({{date.weekday | replace: '曜日', ''}})の天気は{{conditions}}\n最高気温/最低気温 : {{high.celsius}}℃/{{low.celsius}}℃\n降水確率 : {{pop}}%",
  "attachments": [
    {
      "image_url": "{{icon_url}}"
    }
  ]
}

おわり

こんなん。

降水確率ついてるの便利。