more G-Labs products

Author Topic: momentary push button  (Read 1521 times)

April 19, 2016, 06:00:30 PM
Read 1521 times

fra290

  • *
  • Information
  • Newbie
  • Posts: 15
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

April 19, 2016, 07:44:01 PM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
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.

April 20, 2016, 01:04:21 AM
Reply #2

fra290

  • *
  • Information
  • Newbie
  • Posts: 15
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?

April 20, 2016, 02:51:22 PM
Reply #3

fra290

  • *
  • Information
  • Newbie
  • Posts: 15
I'm not sure if this is the right way..
I have created one new widget made from default template
this is the javascript:
Code: [Select]
............
      // 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:

Code: [Select]
  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 ?
 

April 20, 2016, 04:14:37 PM
Reply #4

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
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.

April 24, 2016, 11:47:10 AM
Reply #5

fra290

  • *
  • Information
  • Newbie
  • Posts: 15
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) 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


April 24, 2016, 06:09:00 PM
Reply #6

Acorlin

  • **
  • Information
  • Jr. Member
  • Posts: 44
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.