EventHelper ModuleChangedHandler return false

8 years 10 months ago #1794 by medyk8ns
Hello,

I have a question about EventHelper.
I am using ModuleChangedHandler to send data to ESP. Every time when virtual AnalogInput value is changed data is sent to ESP. I would like to be notified when for some reason data cannot be set(ESP is powered off, not connected to network or any Exception occured). How to achieve that?

I've tried following code, but that does not work as expected. Method sendDataToEsp returns true if data is successfully sent, otherwise false.
public void Setup()
{        
  EventHelper.ModuleChangedHandler((o, m, p) =>
    {   
      bool returnValue = true;
      if (m.Domain == "Virtual" && p.Property == "Sensor.AnalogValue")
      {
           returnValue = sendDataToEsp(m.Address, p.Value);         
      }            
      return returnValue;
      });      
}

Is there any documentation for
public EventHelper ModuleChangedHandler(Func<object, Module, DriverPropertyChangedData, bool> handler)?

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

8 years 10 months ago #1796 by EasyIoT

medyk8ns wrote: Hello,

I have a question about EventHelper.
I am using ModuleChangedHandler to send data to ESP. Every time when virtual AnalogInput value is changed data is sent to ESP. I would like to be notified when for some reason data cannot be set(ESP is powered off, not connected to network or any Exception occured). How to achieve that?

I've tried following code, but that does not work as expected. Method sendDataToEsp returns true if data is successfully sent, otherwise false.

public void Setup()
{        
  EventHelper.ModuleChangedHandler((o, m, p) =>
    {   
      bool returnValue = true;
      if (m.Domain == "Virtual" && p.Property == "Sensor.AnalogValue")
      {
           returnValue = sendDataToEsp(m.Address, p.Value);         
      }            
      return returnValue;
      });      
}

Is there any documentation for
public EventHelper ModuleChangedHandler(Func<object, Module, DriverPropertyChangedData, bool> handler)?


Return value in EventHelper is not important. If you are using Arduino ESP8266 library then value is always returned back. If you are using ESP8266 alone (without Arduino) you should check value on ESP8266 inside your automation program. First send value to ESP8266 and then somehow read this value to check if it was written.

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

8 years 10 months ago #1798 by medyk8ns
I'm using ESP8266 alone. I am reading response from ESP8266 after sending data. If response is ok, then everything is fine. But if there is no response, connection error occurred or any exception is thrown then I would like to be notified about it.
I can use MailHelper or something, but is there a way to be notified about it in UI? Like builtin popup error message "Unable to set value for N1S0"?
I can create virtual node and set its value every time error occurs. But there is no way to set its value to string.

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

8 years 10 months ago #1804 by EasyIoT

medyk8ns wrote: I'm using ESP8266 alone. I am reading response from ESP8266 after sending data. If response is ok, then everything is fine. But if there is no response, connection error occurred or any exception is thrown then I would like to be notified about it.
I can use MailHelper or something, but is there a way to be notified about it in UI? Like builtin popup error message "Unable to set value for N1S0"?
I can create virtual node and set its value every time error occurs. But there is no way to set its value to string.


You can notify in virtual node and you can set string value.
The following user(s) said Thank You: medyk8ns

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

8 years 10 months ago #1810 by medyk8ns
Ok thank you. So it seems that this the way.

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

Time to create page: 0.462 seconds

Forum latest

  • No posts to display.