code

9 years 1 week ago #1100 by piman
Replied by piman on topic code
:woohoo: Thanks Harry,
That seemed to have done the trick thanks a lot, I have modified the code slightly so that it switches the buzzer off when the door is closed, here is an example just in case someone else was having the same problem I was. I think I've got it now thanks to Harry.

public void Setup()

{

    {

EventHelper.ModuleChangedHandler((o, m, p) =>
    {
    	Console.WriteLine(m.Address + " in program id "+ Program.ProgramId.ToString()+ " property "+ p.Property + " value " + p.Value);
	
      
    if (m.Domain == Domains.MYSENSORS && m.Address == "N11S3" && p.Property == "Sensor.DoorWindow" && p.Value == "1")
      
	 
 	DriverHelper.ProcessCommad(Domains.RPIGPIO, "Pin_P1_07", "ControlOn","");
      
     
   if (m.Domain == Domains.MYSENSORS && m.Address == "N11S3" && p.Property == "Sensor.DoorWindow" && p.Value == "0")

	DriverHelper.ProcessCommad(Domains.RPIGPIO, "Pin_P1_07", "ControlOff","");
      
        return true;
    });
      
    } 
}
Next step email notification.

Please Log in or Create an account to join the conversation.

9 years 1 week ago #1106 by piman
Replied by piman on topic code
:huh: email helper working, and sending out email on alerts, however emails seem to be coming in continuously any ideas.?

Andy.

Please Log in or Create an account to join the conversation.

9 years 1 week ago #1108 by HarryDutch
Replied by HarryDutch on topic code
Andy,

Please post the automation code you have right now. I know what's the problem. Will send you tomorrow the right code.

Please Log in or Create an account to join the conversation.

9 years 1 week ago - 9 years 1 week ago #1109 by piman
Replied by piman on topic code
This is where I have got to.
public void Setup()

{

EmailHelper.SetupSmtp("me@gmail.com", "password", "smtp.gmail.com", 587, true);

    {



EventHelper.ModuleChangedHandler((o, m, p) =>
    {
    	Console.WriteLine(m.Address + " in program id "+ Program.ProgramId.ToString()+ " property "+ p.Property + " value " + p.Value);
	
      
    if (m.Domain == Domains.MYSENSORS && m.Address == "N11S3" && p.Property == "Sensor.DoorWindow" && p.Value == "1")
     
      
 	DriverHelper.ProcessCommad(Domains.RPIGPIO, "Pin_P1_07", "ControlOn","");
      EmailHelper.SendEmail("me@gmail.com", "tome@gmail.com", "EasyIoT server", "Module Door Open status alarm"); 
	     
    
   
                 
   if (m.Domain == Domains.MYSENSORS && m.Address == "N11S3" && p.Property == "Sensor.DoorWindow" && p.Value == "0")

	DriverHelper.ProcessCommad(Domains.RPIGPIO, "Pin_P1_07", "ControlOff","");
      
	 
        return true;
    });
       
	 
      
    } 
}
Their also seems to be a delay before the buzzer actually goes off.

Please Log in or Create an account to join the conversation.

9 years 1 week ago #1116 by HarryDutch
Replied by HarryDutch on topic code
Try this code:
int i = 0;

public void Setup() {

	EmailHelper.SetupSmtp("me@gmail.com", "password", "smtp.gmail.com", 587, true);

EventHelper.ModuleChangedHandler((o, m, p) =>
    {
    Console.WriteLine(m.Address + " in program id "+ Program.ProgramId.ToString()+ " property "+ p.Property + " value " + p.Value);
	
      
    if (m.Domain == Domains.MYSENSORS && m.Address == "N11S3" && p.Property == "Sensor.DoorWindow")
	
		if(p.Value == "1" && i == 0) {
      
			DriverHelper.ProcessCommad(Domains.RPIGPIO, "Pin_P1_07", "ControlOn","");
			EmailHelper.SendEmail("me@gmail.com", "tome@gmail.com", "EasyIoT server", "Module Door Open status alarm"); 
			i = 1;
		}
	     
		if(p.Value == "0" && i == 1) {

			DriverHelper.ProcessCommad(Domains.RPIGPIO, "Pin_P1_07", "ControlOff","");
			i = 0;
		}
      
	 
        return true;
    });      	      
    
}
The following user(s) said Thank You: piman

Please Log in or Create an account to join the conversation.

9 years 6 days ago #1123 by piman
Replied by piman on topic code
Thanks Harry, The code works fine, everything is doing what I'm expecting it to do, with your help over the last couple of days. It has helped to make the project fun and exciting and I've learnt quite a bit don't get me wrong, it's nice to rack your brain at times, but it's so reassuring to know that help is not that far away. Hopefully with what I've learnt and understood I also could be of some help to the community in the near future.
Great work thank you.Andy:)

Please Log in or Create an account to join the conversation.

Time to create page: 0.266 seconds

Forum latest

  • No posts to display.