Automation just stops working

9 years 2 weeks ago - 9 years 2 weeks ago #1082 by joeye
Hi,
I'm to move forward with transition to EasyIOT
I setup a MySensors Sensor with a button (S2) and 2 led's acting as single switch S1.
I want the button to make the the leds switch on (red) off (Yellow)
Sketch is here https://codebender.cc/sketch:86965

I have setup automation to toggle between red and yellow. Problem is that it only works some of the time. At some point it claims to send command but according to serial monitor it's not revived on sensor. Once that happens it no longer receives the button push on sensor although sensor seems to be sending it just fine. output in terminal just stops. If I manually via web UI switch the state of the led it will sometimes but not always come back to life.
Issue seems to happen a lot more when I push the button in less then 3 sec intervals. waiting 5 secs seems to make very hard to reproduce. Any ideas what could cause this?
Also it seems that the event is being called twice with the same value. Not really clear on what is going on.

My automation code and sample console output below
Thanks in advance of any help
/*
  This code is running one time when program is enabled
*/
public void Setup()
{
  
  //bool toggle = false;
  
   EventHelper.ModuleChangedHandler((o, m, p) =>

    {

      

      if (m.Domain == Domains.MYSENSORS && m.Address == "N1S2" && p.Property == "Sensor.DigitalValue") {
        ModuleParameter pVal = ModuleHelper.GetProperty(Domains.MYSENSORS, "N1S1", "Sensor.DigitalValue");
        bool on =false;
        if (pVal!= null) {
			Console.WriteLine("Value:" + pVal.Value);
            if (pVal.Value.Equals("1")) on = true;
        }
        
		//tring res = DriverHelper.ProcessCommad(Domains.MYSENSORS, "N1S1", "ControlOn", "");    
        if (on)  {
        	String res = DriverHelper.ProcessCommad(Domains.MYSENSORS, "N1S1", "ControlOff", "");  
            Console.WriteLine("!!!!- Sent Control OFF !!!! Res: "+res);
       
      	} else {
            String res = DriverHelper.ProcessCommad(Domains.MYSENSORS, "N1S1", "ControlOn", "");     
            Console.WriteLine("!!!!- Sent Control On !!!! Res: "+res);
       
      	} 
        
      }
        return true;
    });
  
}

/*
  This code is running periodicaly when program is enabled. 
  Cron job detirmine running period.
*/
public void Run()
{
}
                
Value: 0
!!!!- Sent Control On !!!! Res: 1
2015-03-22T05:43:57.3174890+02:00 INFO MySensors N1S2 Sensor.DigitalValue 1-
Value: 0
!!!!- Sent Control On !!!! Res: 1
2015-03-22T05:43:57.3404900+02:00 INFO MySensors N1S1 Sensor.DigitalValue 1-
2015-03-22T05:43:57.3574950+02:00 INFO MySensors N1S1 Sensor.DigitalValue 1-
2015-03-22T05:43:57.3725060+02:00 INFO MySensors N1S1 Sensor.DigitalValue 1-
2015-03-22T05:44:00.2974380+02:00 INFO MySensors N1S1 Sensor.DigitalValue 1-
2015-03-22T05:44:04.4744670+02:00 INFO MySensors N1S1 Sensor.DigitalValue 1-
2015-03-22T05:44:09.9954430+02:00 INFO MySensors N1S2 Sensor.DigitalValue 1-
Value: 1
!!!!- Sent Control OFF !!!! Res: 1
2015-03-22T05:44:10.0194840+02:00 INFO MySensors N1S2 Sensor.DigitalValue 1-
Value: 1
!!!!- Sent Control OFF !!!! Res: 1
2015-03-22T05:44:10.0425190+02:00 INFO MySensors N1S1 Sensor.DigitalValue 0-
2015-03-22T05:44:10.0595240+02:00 INFO MySensors N1S1 Sensor.DigitalValue 0-
2015-03-22T05:44:10.0735320+02:00 INFO MySensors N1S1 Sensor.DigitalValue 0-
2015-03-22T05:44:12.9995390+02:00 INFO MySensors N1S1 Sensor.DigitalValue 0-
2015-03-22T05:44:17.4064410+02:00 INFO MySensors N1S2 Sensor.DigitalValue 1-
Value: 0
!!!!- Sent Control On !!!! Res: 1
2015-03-22T05:44:17.4294430+02:00 INFO MySensors N1S2 Sensor.DigitalValue 1-
Value: 0
!!!!- Sent Control On !!!! Res: 1
2015-03-22T05:44:17.4524820+02:00 INFO MySensors N1S1 Sensor.DigitalValue 1-
2015-03-22T05:44:17.4695250+02:00 INFO MySensors N1S1 Sensor.DigitalValue 1-
2015-03-22T05:44:17.4855150+02:00 INFO MySensors N1S1 Sensor.DigitalValue 1-
2015-03-22T05:44:20.4104420+02:00 INFO MySensors N1S1 Sensor.DigitalValue 1-
2015-03-22T05:44:28.4964530+02:00 INFO MySensors N1S2 Sensor.DigitalValue 1-
Value: 1
!!!!- Sent Control OFF !!!! Res: 1
2015-03-22T05:44:28.5184610+02:00 INFO MySensors N1S2 Sensor.DigitalValue 1-
Value: 1
!!!!- Sent Control OFF !!!! Res: 1
2015-03-22T05:44:28.5385490+02:00 INFO MySensors N1S1 Sensor.DigitalValue 0-
2015-03-22T05:44:28.5535220+02:00 INFO MySensors N1S1 Sensor.DigitalValue 0-
2015-03-22T05:44:28.5706340+02:00 INFO MySensors N1S1 Sensor.DigitalValue 0-
2015-03-22T05:44:31.4964510+02:00 INFO MySensors N1S1 Sensor.DigitalValue 0-
2015-03-22T05:44:34.7844400+02:00 INFO MySensors N1S1 Sensor.DigitalValue 0-
2015-03-22T05:44:34.8015080+02:00 INFO MySensors N1S1 Sensor.DigitalValue 0-


<-- freezes at this point

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

9 years 2 weeks ago #1085 by EasyIoT
I can check why this happens, but I need more time.

But, question is if this is right way to solve your problem. If I understand you correctly you use push button on sensor node and EasyIoT automation to control LED state on the same node. Maybe is better to implement this logic on node side. That way node can also work independently of server in case of communication lost. You can always add additional control in server Web UI to control LED. Similar example is in ESP8266 thermostat. You control thermostat mode with one (touch screen) button with logic on Arduino node, additionally you can control thermostat mode in Web interface.

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

9 years 1 week ago #1142 by joeye
Replied by joeye on topic Automation just stops working
Thanks.
I was just playing around to understand how to implement the full system on which I have a controller that controller a water valve and on which the button logic is indeed implemented locally and 2 remote buttons that can switch the controller remotely. On these the LED's indicate success of switching so they really need to be controlled by controller.

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

Time to create page: 0.233 seconds

Forum latest

  • No posts to display.