Skip to content

Instantly share code, notes, and snippets.

@thematrixdev
Last active February 27, 2025 14:06
Show Gist options
  • Save thematrixdev/af4c0a643ecf75e158a827ccfaf2f6de to your computer and use it in GitHub Desktop.
Save thematrixdev/af4c0a643ecf75e158a827ccfaf2f6de to your computer and use it in GitHub Desktop.
GNews for HA.md
- sensor:
name: "News World"
scan_interval: 604800
command: >
curl --silent "https://gnews.io/api/v4/top-headlines?category=world&lang=zh&country=hk&max=10&from=$(date +\"%Y-%m-%dT00:00:00Z\")&apikey=" |
jq '{articles: [.articles[] | {title: .title}]}'
value_template: "OK"
json_attributes:
- articles
- sensor:
name: "News Nation"
scan_interval: 604800
command: >
curl --silent "https://gnews.io/api/v4/top-headlines?category=nation&lang=zh&country=hk&max=10&from=$(date +\"%Y-%m-%dT00:00:00Z\")&apikey=" |
jq '{articles: [.articles[] | {title: .title}]}'
value_template: "OK"
json_attributes:
- articles
- sensor:
name: "News Technology"
scan_interval: 604800
command: >
curl --silent "https://gnews.io/api/v4/top-headlines?category=technology&lang=zh&country=hk&max=10&from=$(date +\"%Y-%m-%dT00:00:00Z\")&apikey=" |
jq '{articles: [.articles[] | {title: .title}]}'
value_template: "OK"
json_attributes:
- articles
- sensor:
name: "News Science"
scan_interval: 604800
command: >
curl --silent "https://gnews.io/api/v4/top-headlines?category=science&lang=zh&country=hk&max=10&from=$(date +\"%Y-%m-%dT00:00:00Z\")&apikey=" |
jq '{articles: [.articles[] | {title: .title}]}'
value_template: "OK"
json_attributes:
- articles
- sensor:
name: "News Health"
scan_interval: 604800
command: >
curl --silent "https://gnews.io/api/v4/top-headlines?category=health&lang=zh&country=hk&max=10&from=$(date +\"%Y-%m-%dT00:00:00Z\")&apikey=" |
jq '{articles: [.articles[] | {title: .title}]}'
value_template: "OK"
json_attributes:
- articles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment