I want to be able to read this json file, find the times for today and then when a specific time comes like (“Imsak(AM)”: “3:58”) I want to play media on google home at 3:58 or 10 minutes before this time.
ok, that helps a lot.
if I understand well, you want to look for the Imsak(AM) time for the date matching today and have an announcement at that specific time, right?
I’m not at home so can’t test, but I’d have an automation that runs every min, with a conditions that goes through the list of entries using a for loop, something like:
{% for RamadanDate in states.sensor.ramadanjson.state %}
{%- if
(RamadanDate["Greg"].split("/")[0] | int) == (as_timestamp(now()) | timestamp_custom("%m") | int) and
(RamadanDate["Greg"].split("/")[1] | int) == (as_timestamp(now()) | timestamp_custom("%d") | int) and
(RamadanDate["Greg"].split("/")[2] | int) == (as_timestamp(now()) | timestamp_custom("%Y") | int) and
(RamadanDate["Imsak(AM)"].split(":")[0] | int) == (as_timestamp(now()) | timestamp_custom("%H") | int) and
(RamadanDate["Imsak(AM)"].split(":")[1] | int) == (as_timestamp(now()) | timestamp_custom("%M") | int)
-%}
True
{%- endif -%}
Again Bear in mind I’m not at home so haven’t tested this, but hopefully it gives you something to start playing with.
Now for the full automation, assuming above works:
If you’re interested in an afternoon time, be sure to add +12 to the time read from your sensor.
If you want a 10 min reminder, simply subtract 10 min to the now minutes time in the condition. I would personally add a separate automation for the 10 min reminder else it will become quite complicated…
maybe stupid, but make sure you rename ramadanjson to match the name of your actual sensor and rename media_player.google_mini to be the name of your actual google home device