Monitor webpage for specific content?

I’m trying to use Home Assistant to monitor a webpage for specific text. The end goal is to have Home Assistant generate a notification when this content changes.

The example: A webpage for a booking service has the following text: “Now booking to March 31st, 2024”. Should this date ever change, I want to be notified of it as soon as possible so I can book an appointment.

Currently, I have a sensor defined in my YAML configuration file using a curl command. Every ten minutes, the command line sends a curl command and uses grep to filter for the date. If it finds it, it prints echoes “Not yet updated” to the sensor. If it does not find that date, it echoes “New dates!” to the sensor.

command_line:
  sensor:
    command: 'curl -s https://website.com/page | grep "March 31st, 2024" > /dev/null && echo "Not yet updated" || "New dates!"'
    name: Date Monitor
    interval: 600

I have this sensor displayed on my dashboard, but I’m looking for a way to automate the monitoring of this sensor. I wanted to create an automation that would run every 10 minutes with IFTTT logic for: if the sensor is equal to a string value of “New dates!”; then send a notification to my device. This isn’t possible though as the IFTTT logic only allows device states, not entity states, to be used as the input.

Q: How can I monitor my sensor to be notified of when this webpage changes the date?

1 Like

simple automation like this:

 automation:
   - alias: notify_date_changed
     mode: single
     trigger:
     - platform: state
       entity_id: sensor.date_monitor
     condition:
     - condition: template
       value_template: '{{ states("sensor.date_monitor") == "“New dates!”" }}'
     action:
     - service: notify.my_device
       data:
         message: "New update on website!"

of course, it depends what kind of notification mechanism you want to use. The example above depends on a notification device defined as ‘my_device’, but you could also replace the action with a persistent notification within HA like this:

    - service: persistent_notification.create
      data:
        message: "New update on website!"
1 Like

This is exactly what I’m looking for, thank you so much for the details, examples, and effort!

Finished result posted here!