Skip to content

Commit

Permalink
Merge pull request #28 from itsabdelrahman/master
Browse files Browse the repository at this point in the history
Use `time` display option instead of `date_time`
  • Loading branch information
ibrahim-zehhaf-mawaqit committed May 13, 2023
2 parents a16971d + f443ae6 commit 4973a16
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ sensor:
- platform: template
value_template: >
{% set before = (as_timestamp(states("sensor.fajr_mawaqit")) - 20 * 60) | timestamp_custom("%H:%M", True) %}
{% set time = states("sensor.date_time").split(" ")[1] %}
{% set time = states("sensor.time") %}
{{ time == before }}
action:
# turn on the light of the bedroom
Expand All @@ -62,7 +62,7 @@ sensor:
platform: template
value_template: >
{% set isha_time = as_timestamp(states("sensor.isha_mawaqit")) | timestamp_custom("%H:%M", True) %}
{% set time = states("sensor.date_time").split(" ")[1] %}
{% set time = states("sensor.time") %}
{{ time == isha_time }}
action:
- service: mqtt.publish
Expand Down
25 changes: 12 additions & 13 deletions configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ sensor:
- platform: time_date
display_options:
- 'time'
- 'date_time'

template:
- sensor:
Expand All @@ -30,8 +29,8 @@ automation:
trigger:
platform: template
value_template: >
{% set a1 = states("sensor.date_time").split(" ")[1].split(":")[0] %}
{% set b1 = states("sensor.date_time").split(":")[1] %}
{% set a1 = states("sensor.time").split(":")[0] %}
{% set b1 = states("sensor.time").split(":")[1] %}
{% set a = states("sensor.maghrib_adhan").split(" ")[1].split(":")[0] %}
{% set b = states("sensor.maghrib_adhan").split(":")[1] %}
{{ b | int == b1 | int and a | int == a1 | int }}
Expand All @@ -48,8 +47,8 @@ automation:
trigger:
platform: template
value_template: >
{% set a1 = states("sensor.date_time").split(" ")[1].split(":")[0] %}
{% set b1 = states("sensor.date_time").split(":")[1] %}
{% set a1 = states("sensor.time").split(":")[0] %}
{% set b1 = states("sensor.time").split(":")[1] %}
{% set a = states("sensor.asr_adhan").split(" ")[1].split(":")[0] %}
{% set b = states("sensor.asr_adhan").split(":")[1] %}
{{ b | int == b1 | int and a | int == a1 | int }}
Expand All @@ -66,8 +65,8 @@ automation:
trigger:
platform: template
value_template: >
{% set a1 = states("sensor.date_time").split(" ")[1].split(":")[0] %}
{% set b1 = states("sensor.date_time").split(":")[1] %}
{% set a1 = states("sensor.time").split(":")[0] %}
{% set b1 = states("sensor.time").split(":")[1] %}
{% set a = states("sensor.dhuhr_adhan").split(" ")[1].split(":")[0] %}
{% set b = states("sensor.dhuhr_adhan").split(":")[1] %}
{{ b | int == b1 | int and a | int == a1 | int }}
Expand All @@ -84,8 +83,8 @@ automation:
trigger:
platform: template
value_template: >
{% set a1 = states("sensor.date_time").split(" ")[1].split(":")[0] %}
{% set b1 = states("sensor.date_time").split(":")[1] %}
{% set a1 = states("sensor.time").split(":")[0] %}
{% set b1 = states("sensor.time").split(":")[1] %}
{% set a = states("sensor.isha_adhan").split(" ")[1].split(":")[0] %}
{% set b = states("sensor.isha_adhan").split(":")[1] %}
{{ b | int == b1 | int and a | int == a1 | int }}
Expand All @@ -102,8 +101,8 @@ automation:
trigger:
platform: template
value_template: >
{% set a1 = states("sensor.date_time").split(" ")[1].split(":")[0] %}
{% set b1 = states("sensor.date_time").split(":")[1] %}
{% set a1 = states("sensor.time").split(":")[0] %}
{% set b1 = states("sensor.time").split(":")[1] %}
{% set a = states("sensor.fajr_adhan").split(" ")[1].split(":")[0] %}
{% set b = states("sensor.fajr_adhan").split(":")[1] %}
{{ b | int == b1 | int and a | int == a1 | int }}
Expand All @@ -126,7 +125,7 @@ automation:
{% set before3 = (as_timestamp(states('sensor.dhuhr_adhan')) - 10 * 60) | timestamp_custom("%H:%M") %}
{% set before4 = (as_timestamp(states('sensor.fajr_adhan')) - 60 * 60) | timestamp_custom("%H:%M") %}
{% set before5 = (as_timestamp(states('sensor.fajr_adhan')) - 10 * 60) | timestamp_custom("%H:%M") %}
{% set b1 = states("sensor.date_time").split(" ")[1] | timestamp_custom("%H:%M") %}
{% set b1 = states("sensor.time") | timestamp_custom("%H:%M") %}
{{ b1 == before1 or b1 == before2 or b1 == before3 or b1 == before4 or b1 == before5 }}
action: # the action below is given as an example and is to adapt based on on your homeassistant installation
- service: mqtt.publish
Expand All @@ -147,7 +146,7 @@ automation:
{% set before3 = (as_timestamp(states('sensor.dhuhr_adhan')) - 1 * 60) | timestamp_custom("%H:%M") %}
{% set before4 = (as_timestamp(states('sensor.fajr_adhan')) - 1 * 60) | timestamp_custom("%H:%M") %}
{% set before5 = (as_timestamp(states('sensor.fajr_adhan')) - 1 * 60) | timestamp_custom("%H:%M") %}
{% set b1 = states("sensor.date_time").split(" ")[1] | timestamp_custom("%H:%M") %}
{% set b1 = states("sensor.time") | timestamp_custom("%H:%M") %}
{{ b1 == before1 or b1 == before2 or b1 == before3 or b1 == before4 or b1 == before5 }}
action: # the action below is given as an example and is to adapt based on on your homeassistant installation
service: mqtt.publish
Expand Down

0 comments on commit 4973a16

Please sign in to comment.