more G-Labs products

Author Topic: Program info from another Prorgam  (Read 511 times)

October 15, 2016, 10:19:47 PM
Read 511 times

IanR

  • **
  • Information
  • Jr. Member
  • Posts: 31
Hello
Can you run a program and get the value from an other program.
Let me explain.
e.g.
Program 1: I have a program that checks the outside light level.
Program 2: I have a program I am working on. when an internal PIR is activated it will switch on the corresponding light, at a preset level.
Can I check the light level by calling the value from program 1 and use that value in program 2 or do I have to query the light level again in program 2.
Ian

October 16, 2016, 07:16:28 AM
Reply #1

mvdarend

  • *****
  • Information
  • Hero Member
  • Posts: 431
If I understand you correctly, you have an internal PIR and want to read the value from two programs?

You're better off querying the PIR itself in my opinion.

But if you're trying to activate an event based on light level, you're better off 'catching' the value as it changes, here's a C# example:

Program code:
Code: [Select]
When.ModuleParameterChanged( (module, parameter) =>
{                             
  if (module.Is("Attic Multisensor")){         
    if(parameter.Name == "Sensor.Luminance"){
      // Do something
      }
  }
  return true;
});

In HomeGenie you can hook into all Module change events when they occur, in this case whenever my multi sensor in the attic (Attic Multisensor) changes value, I want to do something when the light level changes (Sensor.Luminance) when that happens, then //Do something.

But I might be misunderstanding your question, if I am, please clarify.

« Last Edit: October 16, 2016, 07:52:06 PM by mvdarend »

October 16, 2016, 09:04:30 PM
Reply #2

IanR

  • **
  • Information
  • Jr. Member
  • Posts: 31
Thank you.
I will query the light level any time I get a change in PIR.

The use was so when child want to use bathroom at night the light will come on dimmed automatically. But when the some one walks around in the day the light will not activated.
Both PIRs and Light level sensors (LDR) are on Arduinos.

The Light sensor has a program that gets the level every 5 mins so I was thinking of using this info, but as you sead it would be better to query the light level every time the PIR is activated.
Thank you
Ian