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?