Scraping shows no value

Thank you for sharing. (logbook filters)
I have not come across it before.

In regards to the praying times, there is a 24 hour format provided by this website,
an affiliate of MUIS.
However, I did not successfully manage to retrieve/scrape the timings from that website.

How do we know whether the 12 hour format praying times are for AM or PM:
I would say it’s because of the arrangement and the meaning of the prayers.
Subuh means dawn
Syuruk means sunrise
etc

Ah! I misunderstood and assumed these names to be city names with every city each own local time for a prayer…
OK, so these names are the six prayers to be done each day at the given time, and these are all always either in the morning or in the afternoon?
If so, then this might be a solution:

sensor:
  - platform: rest
    name: Singapore Prayer times
    resource: https://www.muis.gov.sg/api/pagecontentapi/GetPrayerTime
    scan_interval: 28800
    json_attributes:
      - Subuh
      - Syuruk
      - Zohor
      - Asar
      - Maghrib
      - Isyak

template:
  - sensor:
      - name: Subuh praying time
        state: "{{ as_timestamp(strptime(state_attr('sensor.singapore_prayer_times', 'Subuh')~' AM', '%I:%M %p')) | timestamp_custom('%H:%M') }}"
      - name: Isyak praying time
        state: "{{ as_timestamp(strptime(state_attr('sensor.singapore_prayer_times', 'Isyak')~' PM', '%I:%M %p')) | timestamp_custom('%H:%M') }}"

Like this you can create template sensors for each prayer with the correct AM or PM code.
What this template does is:

  1. it reads the 12-hour time as a string from the rest sensor
  2. it adds either “ AM” or “ PM” to complete the 12-hour string format
  3. it converts this 12-hour format string to a timestamp
  4. it converts that timestamp into a 24-hour format
1 Like

Thank you, you’re awesome!!

I will be trying these out. I would love to learn more about this, do you have notes/documentation for the template you just created?

(just to correct you, it’s five prayer times)
“Syuruk” indicates to us humans that the time period to perform the subuh period at its appropriate time has ended.

I do have some documentation sources that I collected (see below), but I learned, and still do learn, the most from trying to understand code that is posted in this community by others.

Some applicable coding sources:
HA Templating
HA Template integration
Jinja Template Designer Documentation
Expressions
Python - datetime — Basic date and time types

1 Like

Hello guys, great solution by the way. it works in getting the prayer times, but the timing that i get is from 29 Dec 2023

sensor:
  - platform: rest
    name: Singapore Prayer times
    resource: "https://www.muis.gov.sg/api/pagecontentapi/GetPrayerTime?v={{ as_timestamp(now()) | int }}"
    scan_interval: 28800
    json_attributes:
      - Subuh
      - Syuruk
      - Zohor
      - Asar
      - Maghrib
      - Isyak
      - PrayerDate
      - Hijri

template:
  - sensor:
      - name: Zuhur praying time
        state: "{{ strptime(state_attr('sensor.singapore_prayer_times', 'Zohor')~' PM', '%I:%M %p').strftime('%H:%M') }}"
  - sensor:
      - name: Subuh praying time
        state: "{{ strptime(state_attr('sensor.singapore_prayer_times', 'Subuh')~' AM', '%I:%M %p').strftime('%H:%M') }}"
  - sensor:
      - name: Syuruk praying time
        state: "{{ strptime(state_attr('sensor.singapore_prayer_times', 'Syuruk')~' AM', '%I:%M %p').strftime('%H:%M') }}"
  - sensor:
      - name: Asar praying time
        state: "{{ strptime(state_attr('sensor.singapore_prayer_times', 'Asar')~' PM', '%I:%M %p').strftime('%H:%M') }}"
  - sensor:
      - name: Maghrib praying time
        state: "{{ strptime(state_attr('sensor.singapore_prayer_times', 'Maghrib')~' PM', '%I:%M %p').strftime('%H:%M')  }}"
  - sensor:
      - name: Isyak praying time
        state: "{{ strptime(state_attr('sensor.singapore_prayer_times', 'Isyak')~' PM', '%I:%M %p').strftime('%H:%M') }}"
  - sensor:
      - name: Prayer Date
        state: "{{ state_attr('sensor.singapore_prayer_times', 'PrayerDate') }}"
  - sensor:
      - name: Hijri Date
        state: "{{ state_attr('sensor.singapore_prayer_times', 'Hijri') }}"
  - sensor: 
      - name: Time Now
        state: '{{ now().strftime("%H:%M") }}'

This is working