HomeGenie Forum
General Category => General Discussion => Topic started by: fra290 on April 19, 2016, 06:00:30 PM
-
which is the best way to have one momentary push button?
I need it for make one button for the electric door lock that needs a pulse of half a second.
thank you in advance.
MArco
-
What is your hardware configuration? If using an RPi, you could simply use a GPIO with a momentary button and a simple script to do whatever you need done. If you are using ZWave for instance, they have remote buttons that could be used to do something that might help. X10 has RF remotes that could be used to send a command and HG could interpret that as a trigger to do something. You have left lots to the imagination as far as your goal.
-
Yes sorry...
The hardware is very simple: home genie running on raspberry and I use the gpio for control relay connected on door lock.
I need one button on genie gui, where when I select it coles relay for half second in order to open the door.
I have added one new module "switch gpio", in setup I can find switch, light, sensor, etc.
I suppose I need to create one new item for this list "push button" but I not understand where this list keap data, from widget? Program?
Or
I need to create one new module fro control gpio?
What is the best way?
-
I'm not sure if this is the right way..
I have created one new widget made from default template
this is the javascript:
............
// handle ui elements events
widget.find('[data-ui-field=on]').bind('click', function(){
_this.statusText.html('ON was clicked!');
_this.iconImage.attr('src', 'pages/control/widgets/homegenie/generic/images/light_on.png');
HG.Control.Modules.ServiceCall("Control.On", module.Domain, module.Address, null, function (data) { });
wait(5000); // -------- I NEED WAIT HERE
_this.statusText.html('OFF was clicked!');
_this.iconImage.attr('src', 'pages/control/widgets/homegenie/generic/images/light_off.png');
HG.Control.Modules.ServiceCall("Control.Off", module.Domain, module.Address, null, function (data) { });
});
......... etc. etc.
i added one new own function in widget javascript:
function wait(ms){
var start = new Date().getTime();
var end = start;
while(end < start + ms) {
end = new Date().getTime();
}
}
but when a select the ON button HG wait 5 second then execute all code quikly..
I' m confused.. I'm very dummy with Javascript, could someone help me ?
-
You can use the switch type with your GPIO as long as you have RPi GPIO enabled. I would then use the delayed off APP to turn the switch off after 5 seconds.
-
Almost solved..
I changed the approach, thank you bkenobi.. I'm not codeman and is the first time in Home Genie, sorry.
I have created one GPIO switch (doorlock) and one script program (on doorlock, 2s pause, off doorlock) i put this program on dashboard withount any custom widget.
work fine but (for undestend beter the HG) I want to use Python instead of script and I wouldn't create the switch for doorlock but use only a program in python.
can I address the GPIO directly in a Python (I have installed rasperry GPIO module)
I shoud tray to use API (http://hg_address/api/RaspberryPi.GPIO/1/Control.On (http://hg_address/api/RaspberryPi.GPIO/1/Control.On)) but I think is possible have access directly to GOPI with something like:
hg.Modules.WithName('GOPI 24').On()
I test it but not work, what is the right syntax??
TNK
-
I use a Fortress MIMOlite to act as a push button switch at a remote location. It is fully adjustable for dwell time. It functions perfectly from within HG.