1.0.5 • Published 5 years ago

line-weather-notify v1.0.5

Weekly downloads
8
License
MIT
Repository
github
Last release
5 years ago

Line氣象通知

開發給家人群組用的氣象通知

Demo影片

Demo影片

安裝

yarn global add line-weather-notify

執行

只要指定JSON設定檔即可執行

line-weather-notify --config=/path/to/config/file

透過cron tab可以設定成固定時間通知

或是使用我開發的cron-service來設定

JSON設定檔說明

範例可參考meta/config.example.json

{
  "debug": true,
  "puppeteer": {
    "executablePath": "/usr/bin/google-chrome",
    "screenShotStorePath": "/foo/bar"
  },
  "lineNotify": {
    "tokens": [
      "token"
    ]
  },
  "airbox": {
    "screenshot": [
      airboxLocation,
      airboxLocation,
      airboxLocation,
    ]
  },
  "cwb": {
    "city": [
      cityItem,
      cityItem,
      cityItem,
    ],
    "token": "token"
  }
}
  • debug(optional): Boolean, 開啟debug模式, 開啟後puppeteer會關閉chrome的headless模式, 預設為false
  • puppeteer:
    • executablePath(optional): String, puppeteer的chrome的執行檔位置
    • screenShotStorePath(required): String, 截圖暫存路徑
  • lineNotify:
    • tokens(required): Array, Line Notify要通知的對象(可多個)
  • airbox:
    • screenshot(Required): Array, airboxLocation陣列, 可以設定airbox中要截圖的區域
  • cwb: 中央氣象局API設定
    • city: Array, cityItem陣列, 設定需要做預報的縣市及其鄉鎮
    • token(required): String, API token

airboxLocation

{
  "location": "台中",
  "actions": ["+", "+", "+", [210, 470]]
}
  • location(Required): String, 區域名稱, 此名稱將會顯示在line通知上
  • actions(Optional): Array, 操作chrome來控制airbox中的移動/拖曳動作(建議開啟debug模式確認位置), 移動/操作完成後將進行截圖,下列為動作種類說明
    • +: 放大地圖
    • -: 縮小地圖
    • Number, Number: 移動地圖(以目前頁面為中心移動), 第一個為x軸, 第二個為y軸

cityItem

{
  "title": "台中",
  "dataset": "F-D0047-073",
  "towns": ["太平區", "北屯區"],
  "data": {
    "AT": true,
    "PoP6h": true
  }
}
  • title(optional): String, 縣市名稱, 單純為了開發方便, 因為只用dataset不容易辨認縣市
  • dataset(required): String, 鄉鎮預報的資料集編號, 所有資料集編號請詳見中央氣象局開放資料平臺之資料擷取API
  • towns(required): Array, 要做預報的鄉鎮名稱陣列, 各縣市的鄉鎮名稱請參考中央氣象局文件附錄A『全臺縣市鄉鎮對照表』
  • data(optional): Object, 要呈現的氣象資料屬性, 預設為全部呈現, 以下為可用的氣象資料屬性
    • Wx: 天氣現象
    • WeatherDescription: 天氣預報綜合描述
    • AT: 體感溫度
    • PoP6h: 6小時降雨機率
    • PoP12h: 12小時降雨機率

功能

  • 空氣盒子截圖(全台、台中)
  • 鄉鎮氣象預報

Demo

空氣盒子截圖功能簡介

使用puppeteer開啟空氣盒子

並截取全台、台中的空氣品質截圖

接著透過curl使用Line Notify API將截圖發送出去

以下是開啟debug模式中執行截圖的Demo影片

可以清楚的看到puppeteer操作chrome的過程

鄉鎮氣象預報

可指定多個鄉鎮

並取得每個鄉鎮的氣象資料再發出Line通知

Demo

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago