Last active
November 8, 2023 20:16
-
-
Save artipixel/376c6bb568aa8578c25f248b00c56097 to your computer and use it in GitHub Desktop.
התראות פיקוד העורף - Pikud Ha Oref Alerts - Home assistant
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias: Red alert | |
description: '' | |
trigger: | |
- platform: state | |
entity_id: binary_sensor.oref_alert | |
from: 'off' | |
to: 'on' | |
condition: | |
- condition: or | |
conditions: | |
- condition: zone | |
entity_id: person.me | |
zone: zone.home | |
- condition: zone | |
entity_id: person.her | |
zone: zone.home | |
action: | |
- service: tts.google_translate_say | |
data: | |
entity_id: media_player.speaker_group | |
message: red alert! red alert! red alert! red alert! red alert! red alert! | |
- service: light.turn_on | |
target: | |
entity_id: light.living_room_light | |
data: {} | |
mode: single |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sensor: | |
- platform: rest | |
name: redalert | |
resource: https://www.oref.org.il/WarningMessages/alert/alerts.json | |
scan_interval: 5 | |
value_template: > | |
{{ value }} | |
verify_ssl: false | |
headers: | |
Referer: https://www.oref.org.il/ | |
X-Requested-With: XMLHttpRequest | |
Content-Type: 'application/json' | |
binary_sensor: | |
- platform: template | |
sensors: | |
oref_alert: | |
value_template: > | |
{{ states('sensor.redalert')|regex_search("יבנה")}} |
Hi @nimroddolev, You need to make the request with the appropriate headers, without those it will not work:
Referer: https://www.oref.org.il/
X-Requested-With: XMLHttpRequest
Hi @nimroddolev, You need to make the request with the appropriate headers, without those it will not work:
Referer: https://www.oref.org.il/ X-Requested-With: XMLHttpRequest
So you are falsificating request?
@artipixel - where there are alerts, the received json may grow, and in such case I'm getting an error in HA:
Invalid state with length 493. State max length is 255 characters.
Any idea how to work around that ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there. When you request the resource 'https://www.oref.org.il/WarningMessages/alert/alerts.json' is it from a whitelisted IP? When I try I received an 'Access Denied' response.