London Unified Prayer Timetable integration

This might be of value for those who might subscribe to the London Unified Prayer Timetable (ELM/LCM) (which can’t easily be calculated), as it might have been lost in the more generic adhaan automation thread:

@SuBo @Bilal_Ahmad - if you have any questions or feedback please us this thread.

@shak_il - not sure if your question was regarding UK times (which I’m not sure makes a lot of sense) or London times. If the latter, this may interest you.

@sshaikh - Do you have a way to show the next prayer timings on a lovelace card ?

The next prayer times are held in attributes - does that help?

Salaam all,

After a lot of time spent trying to get any one of the integrations to work for Salah times and Adhan playing through my speakers, I finally managed to get this one working by doing the following. Instructions below which I’m hoping helps any other brothers/sisters that are also struggling.

Caveat; I’m further North than London, however I noticed that my local mosque is almost exactly 10 minutes later than the times pulled by this integration (+/- 2 minutes).

  1. Download zip file with the custom_components folder and extract to your custom_components folder within HASS.
  2. Configure as required, although I didn’t change anything for my setup, the defaults were perfect.
  3. Convert the attributes provided by LUPT into sensors by adding the below code into your configuration.yaml. The +600 in the below adds 10 minutes to the time from LUPT as mentioned above. Make sure to change this to match your requirements.
# Salah Times
  - platform: template
    sensors:
      fajr_prayer:
        friendly_name: Fajr Prayer
        value_template: "{{ (as_timestamp(state_attr('lupt.lupt', 'next_fajr')) + 600 ) | timestamp_custom('%H:%M') }}"
      dhuhr_prayer:
        friendly_name: Dhuhr Prayer
        value_template: "{{ (as_timestamp(state_attr('lupt.lupt', 'next_zuhr')) + 480 ) | timestamp_custom('%H:%M') }}"
      asr_prayer:
        friendly_name: Asr Prayer
        value_template: "{{ (as_timestamp(state_attr('lupt.lupt', 'next_asr')) + 540 ) | timestamp_custom('%H:%M') }}"
      maghrib_prayer:
        friendly_name: Maghrib Prayer
        value_template: "{{ (as_timestamp(state_attr('lupt.lupt', 'next_maghrib')) + 600 ) | timestamp_custom('%H:%M') }}"
      isha_prayer:
        friendly_name: Isha Prayer
        value_template: "{{ (as_timestamp(state_attr('lupt.lupt', 'next_ishā')) + 1140 ) | timestamp_custom('%H:%M') }}"
  1. To add a card to your Dashboard with the times, use the below to create a Glance Card
    image
show_name: true
show_icon: true
show_state: true
type: glance
entities:
  - entity: sensor.fajr_prayer
    format: time
    name: Fajr
    icon: mdi:weather-sunset-up
  - entity: sensor.dhuhr_prayer
    format: time
    name: Dhuhr
    icon: mdi:white-balance-sunny
  - entity: sensor.asr_prayer
    format: time
    name: Asr
    icon: mdi:weather-sunset
  - entity: sensor.maghrib_prayer
    format: time
    name: Maghrib
    icon: mdi:weather-sunset-down
  - entity: sensor.isha_prayer
    format: time
    name: Isha
    icon: mdi:moon-waning-crescent
state_color: true
  1. Download an Azan MP3/MP4 of your preference, and upload it to your /www folder
  2. To create an Automation which plays the Adhan at the specified times you can use the below. Make sure to change the entity for the media player to one of your choosing along with the time delay on the salah times and volume settings if required. This is just one example. You can duplicate and amend for the other prayers.
alias: "Kitchen: Adhan Isha"
description: ""
trigger:
  - platform: state
    entity_id:
      - lupt.lupt
    attribute: next_ishā
condition: []
action:
  - delay:
      hours: 0
      minutes: 19
      seconds: 0
      milliseconds: 0
  - service: media_player.volume_set
    data:
      volume_level: 0.4
    target:
      entity_id:
        - media_player.kitchen_display
  - service: media_player.play_media
    data:
      media_content_id: http://192.168.1.251:8123/local/azan.mp3
      media_content_type: audio
      enqueue: play
    target:
      entity_id:
        - media_player.kitchen_display
  - delay:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
  - service: media_player.volume_set
    data:
      volume_level: 0.1
    target:
      entity_id: media_player.kitchen_display
mode: single

There are probably better/cleaner ways to set this up, but after days of trying with very little experience with YAML/Code this is where I ended up.

Hope it helps any of you struggling with getting the times right and Adhan playing in the UK.

1 Like

Thanks for the interest! I did think of better ways of exposing times and concluded that exposing them as sensors wasn’t the right approach. But this is great if that’s what’s required.

Can the glance cards etc not use attributes directly?

Also I recommend using the existing state changes for your adhan automations. I’m pretty sure I included an offset you can use… Triggers also exist which can be offset.

Apologies I did actually tweak my setup a bit as I noticed some of the times weren’t getting updated (for example Dhuhr) on my sensors, as I’m only grabbing the time and not the date. I’ve updated my comment above to reflect these changes on the Automation so they are now triggering from the existing state changes.

The offsets vary by each Salah (amended this in the above post as well) I originally posted with the same 10 minutes across the board to make it easier for other users. My actual values are above now. I don’t think I saw a way to do this with the integration unless I missed it. Apologies if I did.

Regarding Glance cards, I couldn’t see a way to display the attributes cleanly as per the above image. The sensors I’m only using for the card anyway, all of my automation is triggering from your integration, but as the display is in my Kitchen/Living/Dining room (open plan) I thought it would be good to see the times as well.

Okay - thanks for the feedback. I presumed attributes could be used everywhere but I guess not. I’m still unsure about rendering static reference times like these as sensors but I guess if that’s how HA does things then it’s a fair workaround.

Sorry for replying to such an old thread. I was just wondering if you would be able to add this to HACS, or if you already have? I was in the process of setting this up and saw that you have a file related to HACS in your repo. I might message back here if I run into any trouble setting up my prayer times, as I want it sorted before Ramadan starts. Thanks for creating this btw :smiley:

I seem to be having issues with finding the correct URL. I attempted at first to use “https://www.londonprayertimes.com/”. This did not work. I then attempted at using “Prayer times | East London Mosque”. This seems to be a valid URL, but I then cannot see any entities being added into Home Assistant.

Please point me in the right direction, as I have Googled and Googled to no end, without being able to find a URL that works

Ok, it seems I misunderstood how this integration works. For anyone reading this after Googling, it seems the ELM URL is the one that works.

The integration adds one entity, that is visible within the entities tab of where integrations are configured. The entity is not visible when clicking on the integration and its entries. This is what confused me.

After adding in an entity card to my dashboard and adding in the “LUPT” entity, you can see the current prayer time that it is.

Hope that clears up any confusion for anyone that stumbles upon this

Hi @sshaikh

I updated to the latest version of HA and it broke the integration, unable to load. removing and re-adding the integration didn’t fix it. Had to restore my backup and rollback to the version I was using originally. Have you experienced this?

Shak

My notifications don’t seem to work so just saw this. Glad you figured it out and thanks for sharing the solution.

I can’t recall needing to set up anything after installing the integration and I think the card came up automatically. What exactly did you expect to happen/see?

I’m using 2024.4.0 and didn’t need to do anything special to have it working - is there anything in the logs to say what the issue is?