Show sensor within next 7 days

I have a few sensors with date values, Sat 02 Mar, 2019 for example. I’m looking for a way to show only the sensors that have a value within the next 7 days. Something like auto-entities card might work, but not exactly sure how to do this.

The values are taken from a webpage and saved to a text file, and then using a command_line sensor and sed to reference a specific line in the file, I grab the value for the sensor. I can also modify this output if needed to remove the day and the comma after the month if needed.

I’m open to any and all suggestions.

can you get a unix style timestamp for them?

This is a condition I use here:

          - condition: template
            value_template: ' {{ as_timestamp(now())
              - as_timestamp(''2017-09-24 00:00:00'')) / 86400)|int % 28 == 0 }}'

so you could read the date for the as_timestamp and do a int % 7 <7 ? maybe… that’s where I’d start

It’s scrapped from a website, and the format is Sat 02 Mar, 2019. I was just looking at the date command in linux. I might be able to do something with that. Just trying to work out how to add that on a command line after sed does its thing.

So if you can put it in the same format as I show in my template, and then set that as a state for an entity, you should be able to use that by comparing the as_timestamp(states.entity.states) with now as per the above. Definitely doable.

Ok, so with a combination of using sed, awk and sed again, I got the date format to be 2019-03-02 00:00:00. Now, having a play in the template editor I have 2 options. Both seem to result the same.

value_template: {{ (as_timestamp('2019-03-03 00:00:00') - as_timestamp(now())) / 86400 | int < 7 }}

or

value_template: {{ (as_timestamp('2019-03-03 00:00:00') - as_timestamp(now())) | int < 604800 }}

You forgot the int % 7 which does a mod 7 on the date…
Check it in the template editor

The 86400 is the number of seconds in a day… then mod 7 to give the number of days and <7 to see if within 7 days…