Website down or up

It’s not working for me. I seem to be able to show the binary sensor as “connected” but i just tested by turning one of the services OFF and it does not show as “disconnected” even after many minutes… any ideas on how to fix?

I couldn’t figure out how to use the value_template so I found a webpage that gave me a command to reduce the output to just the HTTP code. Using OSX in a terminal command I issued the CURL lines to figure out what each HTTP code was what for each service when it was live. Sometime “-I” works and other times “-i” worked for me.

I’ve used the code below:

binary_sensor:
  - platform: command_line
    command: curl -I http://192.168.86.61:9091/gui/ 2>/dev/null | head -n 1 | cut -d$' ' -f2
    name: 'Service 1'
    device_class: connectivity
    payload_on: 400
  - platform: command_line
    command: curl -I http://192.168.86.60:8989/ 2>/dev/null | head -n 1 | cut -d$' ' -f2
    name: 'Service 2'
    device_class: connectivity
    payload_on: 200
  - platform: command_line
    command: curl -I http://192.168.86.61:8096/ 2>/dev/null | head -n 1 | cut -d$' ' -f2
    name: 'Service 3'
    device_class: connectivity
    payload_on: 302
  - platform: command_line
    command: curl -i http://192.168.86.61:81 2>/dev/null | head -n 1 | cut -d$' ' -f2
    name: 'Service 4'
    device_class: connectivity
    payload_on: 302
1 Like