more G-Labs products

Author Topic: Problem with Toggle Button on Sensor Widget  (Read 1133 times)

July 16, 2016, 01:53:14 PM
Read 1133 times

robyes

  • *
  • Information
  • Newbie
  • Posts: 2
Hello to all,
It is my first post, but it is more than a year I read all of your posts, and I have fun with Home Genie ... But I must say that my wife is not really happy about that !!!  :-\

... I hope someone help me with a problem I can not solve despite recent sleepless nights.

In short, I modified Widgets "Light" to be used with Pin GPIO set to "ON" (thus a sensor).
In this widget I only the "Toggle" Button, which when pressed I should turn for half a second a GPIO that is connected to a relay.
Given the last 3 nights without finding the solution (I am not a programmer), I decided to ask my first help:


What code I need to add after the standard code to achieve what is described above?


  // toggle button action
      widget.find('[data-ui-field=toggle]').on('click', function () {
        HG.Control.Modules.ServiceCall("Control.Toggle", module.Domain, module.Address, null, function (data) { });
      });         

  // HERE I NEED HELP!!


Grazie a tutti!!


July 17, 2016, 02:44:35 AM
Reply #1

robyes

  • *
  • Information
  • Newbie
  • Posts: 2
No one, from those who saw the post, knows how to do the above?

However, if it can be useful to someone, I solved by creating a small program (1020) that triggers for 1 second the GPIO connected to the relay.
In the modified widget I added the following code to the toggle button action:

var progs = HG.Automation.Programs;
        progs.Run(1020, { });

Maybe is apparently useless, but a sensor widget that contains a toggle button, is very useful to control and monitor the status of a light on a traditional electrical system using a single widget.
The light has a wall button connected to a normal two-way relay.
The second way of the relay is a dry contact that is connected to a GPIO configured as INPUT and is used to know the status of LIGHT.
The toggle button, located on the same sensor widget, is used to control an economic Relay Board for Raspberry, that you have to connect in parallel to the two-way relay.

SO, WE CAN NOT KNOW THE STATE OF THE LIGHT THROUGH THE RELAY BOARD, BUT THROUGH THE STATE OF THE TWO-WAY RELAY  CONNECTED TO GIPIO CONFIGURED AS INPUT (SENSOR) !!

For clarification, I'm at the disposal.

N.B. Of course if rather than creating a macro for each ignition, there was sooner or later someone so kind to suggest a way to create the parameter in the widget to indicate which GPIO trigger for 1 second would be perfect !!

I thank all those who work to HomeGenie.
I will make soon a small donation, because after trying it for some time with some sensor and relay, I am increasingly convinced that I will use this system to my new home currently under construction !!