Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Push button (or any other type of button) to activate a switch #204

Closed
Natrixz opened this issue Nov 9, 2018 · 14 comments
Closed

Push button (or any other type of button) to activate a switch #204

Natrixz opened this issue Nov 9, 2018 · 14 comments
Labels
wish for the far future

Comments

@Natrixz
Copy link

Natrixz commented Nov 9, 2018

Would it be possible to add some sort of push-type style button or some other button we can connect to the Raspberry Pi?
Either with a timer and/or a push to enable and push to disable?

A couple of my snakes need to be fed at night, so to do this I enable a red-night light in the enclosures and then feed them.
Would be nice if it's possible to do this with a switch I can attach somewhere near the enclosures.

@theyosh
Copy link
Owner

theyosh commented Nov 12, 2018

hmm, I get the idea. But I am not sure how to implement. There are more ways.

But for now, I see already two solution.

  1. Use a WeMo power switch. It can be controlled by TerrariumPI and it has a physical switch on the device. That means the WeMo should be accessible.

2 Use an old mobile with the web interface.

But I will see if I can think something out. Features:

  • Adding 1 or more push buttons
  • How long will the push button do it's action. (Timer)
  • Stop the timer when pressed for a second time
  • Does long holding trigger a different action??

So.. it will take some time. And need to figure out a way that work for multiple ways.

@theyosh
Copy link
Owner

theyosh commented Nov 16, 2018

This is also an option: https://energenie4u.co.uk/catalogue/product/ENER010-PI Only not sure if there are with european connectors

@Natrixz
Copy link
Author

Natrixz commented Nov 16, 2018

I have been looking at that as well, I can only find the single plug in European plug:(

@theyosh
Copy link
Owner

theyosh commented Nov 16, 2018

how about..... : https://www.conrad.nl/p/kabel-digitus-computer-stroom-apparaat-1x-engelse-stekker-1x-apparaatstekker-female-c13-10a-18-m-zwart-1556217 :)

I think that is workable... But I cannot read out the switch: #199 (comment) when you click the remote

@Natrixz
Copy link
Author

Natrixz commented Nov 16, 2018

Smart/good find!
I actually didn't search that way yet, nice =)

That would work yes.
Not sure how problematic it is to not be able to read out the switch.
As long as it resets to off and you keep track of the state you switched to it shouldn't be that bad right? :)

@theyosh
Copy link
Owner

theyosh commented Nov 16, 2018

like some challenge.. but I am just wondering that the RF module will take the hole pi. And you cannot add sensors.. So still it is all thinking out of the box...

I will not be accountable for wrong purchases :)

@Natrixz
Copy link
Author

Natrixz commented Nov 16, 2018

Yes im sort of wondering that too....as well because I use the 1-wire module for all my sensors readings =)
Hmmm, let me think about it a bit more, maybe im able to think up something else :)

I did stumble upon https://flic.io/
But 35$ for a BT button....meh, not sure if that's a good deal :P

@theyosh
Copy link
Owner

theyosh commented Nov 16, 2018

Hmmm... I see that there is some SDK and Python code for it... https://github.com/50ButtonsEach/fliclib-linux-hci

I think there pretty funny. Just a button. Nothing more, nothing less... tempting....

@Natrixz
Copy link
Author

Natrixz commented Nov 16, 2018

Yes there is :)
They are fun and simple, they also support long press or double clicking, atleast according to the info haha
Also, very easy placeable around enclosures without messing with cables :)

@theyosh theyosh added the wish for the far future label Nov 18, 2018
@ese23
Copy link

ese23 commented Jan 26, 2019

I buy this kind of relay board.
https://www.amazon.com/MagiDeal-Channel-Infrared-wireless-Control/dp/B06XS7FZGM
And if i have luck it will work. In description say, that you can independently switch relays, either with IR or GPIO from RAPI. Soo its little overoverride :-) but many users, that buy it, say it didnt work :-/
Soo next weak i will test it.

@jornobe
Copy link

jornobe commented Mar 10, 2019

Have added a hardware switch on pin 18 to trigger outlet 1 on the Energenie LAN (already controlled by TerrariumPI) whenever pushed.

4 steps:

  • Switch connected to pin 18 and a ground pin

  • Created this script (rain_on.sh) to login to the Energenie, switch the outlet on and logoff the management webpage again: (you can replace this with whatever code works for your plug)

#/bin/bash
wget --post-data 'pw=pwd' 'http://192.168.178.45/login.html' -O foo.html --delete-after
wget --post-data 'cte1=1&cte2=&cte3=&cte4=' 'http://192.168.178.45' -O foo.html --delete-after
wget 'http://192.168.178.45/login.html' -O foo.html –-delete-after
  • Created this Python script (rain_check.py) to monitor the pin and launch the script when button gets pressed:
import RPi.GPIO as GPIO
import time
import os
GPIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
    input_state = GPIO.input(18)
    time.sleep(5.0)
    if input_state == False:
        os.system("/home/pi/rain_on.sh")
        time.sleep(15.0)
        os.system(“/home/pi/rain_off.sh")

  • Launched the Python script in a screen called "rain" so it runs in the background and I can attach to it if:

screen -dmS rain python rain_check.py

@djarrard-zz
Copy link

You can also do this by using requests to the API to manipulate switches. I like this better because all of my devices run on schedules via Terrarium Pi. This means if I want to turn on a switch that’s scheduled to be off in Terrarium Pi, the system just reverts that switch to its scheduled state within a few seconds (unless manual mode is enabled). I created a script that turns manual mode on and then turns on the switch via the api (see #282). I’ve got a separate button that turns manual mode back off for all switches. I Works very well so far.

@theyosh
Copy link
Owner

theyosh commented Jul 7, 2019

Ok, after some long thinking, I came up with an example script. Which can be used in other scripts.

This makes it possible to make your own hardware button, and interact with the software. The script is pretty easy to read. It can just toggle the state, or set it to a requested state (on/off). But that will leave it in manual mode.

When running with 'on 40' it will stay on for 40 seconds, and then go off. And will also return to normal mode and not in manual mode. So you can over write the system for X amount of seconds.

So that will probably as far I can support this.

https://github.com/theyosh/TerrariumPI/blob/master/contrib/toggle_switch.py

@theyosh
Copy link
Owner

theyosh commented Jan 28, 2020

Ok, closing this, as the example toggle switch is the way to go. Supporting all kind of buttons is not part of the core system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wish for the far future
Projects
None yet
Development

No branches or pull requests

5 participants