Page 1 of 1

gpio doorbel mute at night time

Posted: Thursday 30 May 2019 11:50
by ATICT
Hello everyone,

I have make my phisical doorbel connected to the gpio of my raspberry pi. This works very well, when you push the doorbel button outsite, domoticz send a message to my phone and run directly a phython script that makes my doorbel ring for a half second.

Now is my question how can I make in a script the physical doorbel mute at night time?

I have make a try, but it was unfortunately not a lucy try.
Is there someone thats can help me further to fix this, please?

Code: Select all

#!/bin/sh
fireup()
{  
  while :; do
   currenttime=$(date +%H:%M)
   if [[ "$currenttime" > "07:00" ]] || [[ "$currenttime" < "22:00" ]]; then
     python /home/pi/domoticz/scripts/python/gpio_deurbel.py
   else
     do_something_else_or_nothing
   fi
   test "$?" -gt 128 && break
  done &
}
Thank you in advance!
Kind regards.

Re: gpio doorbel mute at night time

Posted: Friday 31 May 2019 21:45
by Gerwin
Make a dummy switch an set a timer example 07:00 on and 23:00 off
Make a blocky if the dummy switch and the Bell is on send a message

Gerwin

Re: gpio doorbel mute at night time

Posted: Saturday 01 June 2019 8:21
by hoeby
I am not a bash specialist.
But is the || not an OR command?
Shouldn't this be an AND command?

If so, then i think your problem is in this line:

Code: Select all

if [[ "$currenttime" > "07:00" ]] || [[ "$currenttime" < "22:00" ]]; then
When the || is an OR command, then,
Some examples:
When it is 6:00hour:
"$currenttime" > "07:00:" --> false
"$currenttime" < "22:00" --> true

When it is 23:00hour:
"$currenttime" > "07:00:" --> true
"$currenttime" < "22:00" --> false


So you made a 24hour function.
What happens if you try changing || in &&?