#Stop playing music during prayer time?

1 messages · Page 1 of 1 (latest)

hushed lion
#

I want to use Islamic prayer time intergration to stop playing music on my vlc-telnet player. it will resume when prayer time ends. ``` alias: VLC Prayer Time Control
description: "Pause VLC at Islamic prayer times, then always play MP3 after prayer ends"
mode: restart
trigger:

  • platform: state
    entity_id: sensor.next_prayer # from islamic_prayer_times integration

variables:
player: media_player.vlc_telnet

action:

  • choose:
    • conditions: "{{ trigger.to_state.state in ['fajr','dhuhr','asr','maghrib','isha'] }}"
      sequence:

      Pause VLC at prayer start

      • service: media_player.media_pause
        target:
        entity_id: "{{ player }}"

      Wait until prayer is over (when next_prayer changes again)

      • wait_for_trigger:
        • platform: state
          entity_id: sensor.next_prayer

      Always start the MP3 after prayer

      • service: media_player.play_media
        target:
        entity_id: "{{ player }}"
        data:
        media_content_id: media-source://media_source/local/my-media/happy-birthday-357371.mp3
        media_content_type: music```

is this automtion correct?
https://www.home-assistant.io/integrations/islamic_prayer_times/

Home Assistant

Instructions on how to integrate the Islamic Prayer Times integration within Home Assistant.

analog blaze
#

Generally, most of us avoid using long waits, so that's something you may want to consider.

However, I don't think that the automation is going to work the way you seem to think it will but, you will need to tell us how you configured the next_prayer sensor for us to know for sure.

Assuming the next_prayer sensor updates at the start of every prayer time...

  1. At dawn it will change from "fajr" to "dhuhr", firing the automation.
  2. The media player will be paused.
  3. Then the automation will sit in the Wait action for 6-7 hours until noon when the sensor changes from "dhuhr" to "asr".
  4. Then the media player should start again.... except it won't because the automation is using restart as its mode, so the trigger described in Step 3 cancels this run and we're back at Step 1.

From what you have shared, it seems like what you actually need is a trigger to indicate the end of prayer time.