I just want to check if a web server is working and if it is down, send an e-mail.
There are many helpful posts related to using REST but it often isn’t clear where the pieces go.
This is in configuration.yaml:
rest_command:
check_dbsk:
url: "http://dadler.dynalias.org:81/dbsk"
method: GET
I put this in automation.yaml based on an example I found:
- id: '1731083834226'
alias: Test DBSK server0
description: ''
triggers: []
conditions: []
actions:
- action: rest_command.check_dbsk
response_variable: dbsk_response
- if: "{{ dbsk_response['status'] == 404"
then:
- action: notify.dwa12457_gmail_com
metadata: {}
data:
message: server failed
title: Checking server
target: [email protected]
else:
- action: notify.dwa12457_gmail_com
metadata: {}
data:
message: server ok
title: Checking server
target: [email protected]
mode: single
Nothing fails when I run this from Developer tools but it doesn’t succeed. Is there any place to look Developer tools for what happened? If I go into Automations I see:
I tried to create an automation but it wasn’t obvious how to do it.
Then I created this script:
alias: script1
sequence:
- action: rest_command.check_dbsk
data: {}
response_variable: dbsk_response
- condition: template
value_template: "{{dbsk_response['status']}} == 200"
- action: notify.dwa12457_gmail_com
metadata: {}
data:
message: Server operational
title: Server test
target: [email protected]
description: ""
It fails.
It seems like this should be a trivial exercise but clearly I don’t know what I am doing!