Skip to content

Instantly share code, notes, and snippets.

@artipixel
Last active November 8, 2023 20:16
Show Gist options
  • Save artipixel/376c6bb568aa8578c25f248b00c56097 to your computer and use it in GitHub Desktop.
Save artipixel/376c6bb568aa8578c25f248b00c56097 to your computer and use it in GitHub Desktop.
התראות פיקוד העורף - Pikud Ha Oref Alerts - Home assistant
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
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("יבנה")}}
@nimroddolev
Copy link

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.

@artipixel
Copy link
Author

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

@las3r12
Copy link

las3r12 commented Oct 31, 2023

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?

@yonidagan
Copy link

yonidagan commented Nov 7, 2023

@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