I have a scraped sensor that I created in Configuration.Yaml which scrapes the Minutecast information from Accuweather’s webpage. It works great when used as a card in lovelace but when I try to use it in an automation the only attribute I can call up is “Friendly_name”. I was hoping to use it to alert me when its about to rain in the next hour.
Is there any way to get the scraped data to show up in an attribute?
I guess “No precipitation for at least 120 minutes” is the data you’ve scraped, right? In which case you can access it in your automation using the code I posted above; or if you want to us it as, for example, a trigger, you can do
trigger:
- platform: state
entity_id: sensor.minutecast
state: 'No precipitation for at least 120 minutes'
This example will trigger an automation when the minutecast forecast is as you showed it above.
If you want to further process the number of minutes given - for example, if you want to know if the number is anything less than or equal to 60 - you can do that by using some combination of slice notation and Jinja filters.
For example, if the boilerplate is always the same, you could use
states("sensor.minutecast").split(" ")[4]
which will produce ‘120’.
Then, for example, your automation could trigger whenever the state of sensor.minutecast changes, and could have the following condition:
(|float converts the string ‘120’ into the number 120, which is needed for the less than or equal comparison to work)
If the boilerplate changes - for example, if it sometimes says “Rain expected in next 60 minutes” - then you would need to come up with another way of extracting the number from the string.
Yeah it seems like there is no real boilerplate response, but could I potentially match a response to a given value? For example if states(sensor.minutecast) = ‘Rain expected in 10 minutes’ then do such an such? (assuming that “Rain expected in x minutes” is a valid response)