gpio doorbel mute at night time

All kinds of 'OS' scripts

Moderator: leecollings

Post Reply
ATICT
Posts: 1
Joined: Wednesday 20 March 2019 11:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

gpio doorbel mute at night time

Post 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.
Gerwin
Posts: 84
Joined: Friday 12 August 2016 13:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: gpio doorbel mute at night time

Post 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
hoeby
Posts: 528
Joined: Saturday 02 June 2018 11:05
Target OS: Raspberry Pi / ODroid
Domoticz version: V2022.1
Location: Echt, Netherlands
Contact:

Re: gpio doorbel mute at night time

Post 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 &&?
Thin-client --> Docker Domoticz main environment
Pi3A+ --> Google home (GAssistPi)
Pi3B+ --> Docker (P1monitor, Domoticz test environment, Ubiquity controller)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests