Trigger is not working


#41

Nope that does not work, here i have set items

Items    
    Temp 1
    Digital Actuator

    Then trigger 1:
    If Temp1 over 40 Then Digital Actuator 1 (On)

    Then set another trigger 2
    If Digital Actuator 1 then Send notifications sms/email

On Temperature change to 40 in Trigger1 Digital Actuator does not change state, if i press Digital Actuator manually it goes to On, and i receive Trigger notification for both SMS/Mail.

So this mode and “combo” does not work, only digital are able to make trigger fire.
Analog to digital does not work internaly, neither analog are recognised when setting up triggers (In app) in web they are recognised, but even if you set them they dont work. So there must be a reason that app is saying that devices with mqtt lib are not usable.

Also the values MIN MAX
14-43-29
reset every time trigger is saved and when i open it it again show min -500 max 500


#42

its just a work around to get a notification to when temp reaches above 40 cause i am not sure why the trigger is not firing. may be @rsiegel can help you out here.
the workaround is in your code add a if condition so as to when temp reaches 40 change the value of two state widget to 1 and then set a trigger when two state widget is 1 send a notification.
on another channel you can show the value of the temp if you want.


#43

Point is, if same process worked with Cayenne Arduino lib, why is not working with MQTT


#44

Some info about this issue?

One more notice:
If you create a trigger using device and save it, then after that you open project page, and select Triggers & Alerts, then edit that same trigger lets say reduce alert temperature by 5c and save, after saving instead of one trigger like before edit there are 2 separate trigers. Is that normal behaviour?


#45

@rsiegel maybe this can help to resolve this issue

I have done some testing today with different hardware and software setups and i have found that device trigger notifications do no recycle PINS USED for it or delete them on server side for some reason.

Case 1 Works:
You setup new device named Device1 mqtt adds channels, you go to trigger and setup notification for some channel/pin to send Email or SMS or both on some event. Its works

Case 2 Does not work:
You go to that same Device1, delete pin/dashboard that was using trigger from previous Case delete trigger for it, after that mqtt adds same pin/dashboard from previous Case. When you now add trigger for that pin which was temporarely deleted, the trigger notification does not work

So evereytime you want to edit trigger, you need edit code for the esp and change pin on which data are sent then add new trigger. Not very practical :anger:

Case tests were made using mqttesp lib and stand-alone esp module reading temperature values from 3 different sensors and writing valuse of them to 3 different cayenne pins.


Trigger nor working in some cases
#46

Definitely seems like a bug. I will test it out now and post back if I get the same results. Thanks for putting so much detail in to this report!


#47

Confirmed.

  1. create mqtt device
  2. connect to it (sketch below)
  3. add temp widgets with +
  4. create trigger when channel 5 is over 10 turn on channel 6
  5. delete channel 5 (has to be the source of the trigger, deleting destination doesn’t cause this bug)
  6. delete trigger
  7. add widget with + again
  8. recreate trigger
  9. trigger doesn’t ever fire

Code:

// This example shows how to connect to Cayenne using an ESP8266 and send/receive sample data.
// Make sure you install the ESP8266 Board Package via the Arduino IDE Board Manager and select the correct ESP8266 board before compiling. 

//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

// WiFi network info.
char ssid[] = "";
char wifiPassword[] = "";

// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "";
char password[] = "";
char clientID[] = "";

int counter = 0;

unsigned long lastMillis = 0;

void setup() {
	Serial.begin(9600);
	Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}

void loop() {
	Cayenne.loop();
  delay(1000);
  counter++;
}

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
	// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
	Cayenne.virtualWrite(5, counter, "analog_sensor", "null");
	// Some examples of other functions you can use to send data.
	//Cayenne.celsiusWrite(1, 22.0);
	//Cayenne.luxWrite(2, 700);
	//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
 Cayenne.virtualWrite(6, 0, "digital_actuator", "d");
}

// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
	CAYENNE_LOG("Channel %u, value %s", request.channel, getValue.asString());
	//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}

Will trigger work for manually sent mqtt sensor data?
#48

Also worth noting I has some weird issues with the deleted channels sticking around for a bit:


#49

@adam Same situation here, deleted or renamed they still hang around for a few minutes, probably until synchronisation is done, but that is not a big issue since it goes by it self.

This triggers are more of a issue, i am glad or not :smile: that you were able to reproduce this bug, i would be more happy if you did not so i could blame it on my fast fingers or extra bracket in the code, but :tired_face: its not. I did not have this issues with arduino library it poped up when transfered to mqtt.


Triggers are not working for "bring your own thing Cayenne MQTT"
#50

Just to better understand: are Triggers working on MQTT or not?

I finally setup the whole hardware and dashboard, and thought that triggers would be not a problems… but in no way I can see my MQTT MCU 8266 in the list of triggers on the app, and in web version even if I see the device in the list and I can configure a trigger, it simply doesn’t work… no changes also in the execution count. I didn’t have any triggers created before.

I tried to totally delete any trigger I just created, device and proect in my account but still no way… in the app It was just recognized as a source an old device, not MQTT, like somebody else said.

Without triggers my whole setup is useless… so doesn’t it work with Cayenne on MQTT library or it’s just me? Workarounds?

Thanks


#51

Triggers work but the bug seems to be if you delete a channel at any point in time you can’t ever trigger on that channel again. Try creating a new MQTT device and re-create your triggers there, or use channels that you haven’t used before.

Also worth noting that some widget types cannot be triggers or trigger targets. Ex: digital sensor can be a trigger, but digital actual cannot. Digital sensor cannot be a trigger target, but digital actual can.


#52

Thanks Adam

I left the device as it was for 2 days, and now… everything’s working! Any magic hand on your side or…? :wink: Maybe the deletion of all my stuff helped, and needed “some time” to take effect…

Pretty confused on what happened, but since there’s a bug around I’m not that surprised… hope that it’ll be fixed soon, probably it will cause some issues here and there, but at least now I can go on with my project :slight_smile:

Thanks!


#53

Not sure on a fix being released, but glad to hear it’s working!


#54

That’s really bad news

As suspected, the issue has returned: I didn’t change anything in the setup, but today triggers are not working anymore.

Really a pity, I really like Cayenne but i guess I have to find a different service for my setup :frowning:

Thanks anyway!


#55

Hello,
very interesting and helpful project, I hope the issue will be solved soon :slight_smile:


#56

Here is the procedure I followed to install and setup triggers.
Installed new device as a byot, (HUZZAH ESP8266) with only minimal code in the sketch. Device showed up at the dashboard. Then added a 2 state digital widget to the dashboard. Went back to the sketch, added code for the widget. Uploaded. Widget worked. Added trigger which does not work. What am I missing here? Thanks for any insight you can provide.

Usual log in stuff here-------------------:

#define SENSOR_PIN 5 // Do not use digital pins 0 or 1 since those conflict with the use of Serial.
#define VIRTUAL_CHANNEL 7

//unsigned long lastMillis = 0;

void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}

void loop() {
Cayenne.loop();
}

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
//Cayenne.virtualWrite(0, millis());
// Some examples of other functions you can use to send data.
//Cayenne.celsiusWrite(1, 22.0);
//Cayenne.luxWrite(2, 700);
//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
Cayenne.virtualWrite(VIRTUAL_CHANNEL, digitalRead(5), “digital”, “d”);
}

// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG(“Channel %u, value %s”, request.channel, getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(“Error message”);
}


#57

Hi Adam, just wondering if the rules above regarding what Widget types are allowed to fire triggers and what Widget types are allowed to BE targets of a trigger is new. I had not seen any documentation on these rules.

A month ago, after converting my 4 NodeMCU ESP8266’s devices over to MQTT format, the triggers would not fire as digital sensors. Previously, they had worked fine when they were set up as Arduino’s As a result, I had to reconfigure the code in each device to declare all of the virtual channels as digital actuators in order to make them work. (I noted this workaround in a previous post.)

Four days ago, all of my triggers died. I have been holding off on submitting an issue about this since a few others had recently posted about their triggers quit working too. Is this the result of some rules changes being applied on your end?

I would appreciate if you could elaborate further on this topic or perhaps point me to the appropriate documentation. If I do need to start over again I want to be clear on the standards I need to follow. I’m sure others would be grateful as well.

Thanks much!


#58

@margettepv @jfb820 try this method.
create a new device with bring your own thin.
then add your mqtt credential into the below code and upload.

// This example shows how to connect to Cayenne using an ESP8266 and send/receive sample data.
// Make sure you install the ESP8266 Board Package via the Arduino IDE Board Manager and select the correct ESP8266 board before compiling. 

//#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneMQTTESP8266.h>

// WiFi network info.
char ssid[] = "ssid";
char wifiPassword[] = "wifiPassword";
int x;
// Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
char username[] = "MQTT_USERNAME";
char password[] = "MQTT_PASSWORD";
char clientID[] = "CLIENT_ID";

unsigned long lastMillis = 0;

void setup() {
	Serial.begin(9600);
	Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}

void loop() {
	Cayenne.loop();

	//Publish data every 10 seconds (10000 milliseconds). Change this value to publish at a different interval.
	if (millis() - lastMillis > 10000) {
		lastMillis = millis();
    x++;
    Cayenne.virtualWrite(1, x);
	}
}

CAYENNE_IN_DEFAULT()
{
	CAYENNE_LOG("CAYENNE_IN_DEFAULT(%u) - %s, %s", request.channel, getValue.getId(), getValue.asString());
	//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError("Error message");
}

once uploaded you will see a value widget on your dashboard showing the value of x on channel 1.
add it to your dashboard by pressing ‘+’ .
next add a custom button widget with channel 2.
now add a trigger when channel 1 to turn on channel 2.
follow this step and step and your trigger should work.
this is just to check whether trigger are working. then try with your own code.
points to keep in mind.
add sensor widget with correct data types from the code and not from dashboard.
if trigger not working try deleting the previous sensor widget and change the channel number of the sensor and re-upload the code.


#59

Well, I may have messed up, but I believe I followed your instructions and it still doesn’t trigger. I assume my created button should trigger with every increase of value on the first one. Creating a new device does eliminate the carry over of used virtual channel numbers? In the process of trying to make this work I probably have used most single digit virtual channels at some point. JFB820 you have a chance to try it?


#60

So far nothing I tried has made a trigger work with the esp8266. Everything works great with the Uno which I installed about a week ago when I opened my account.
I tried an example Adam posted 2 weeks ago. Installed as new device. Doesn’t trigger. Widgets all appear normal, first one counts up, when it hits the trip number nothing happens.
Anyone have any ideas? Am I missing some ridiculously easy point?

Stop the press!!
What I just tried was to add another widget (ch7 in the code) and trigger it from the Uno. It WORKS!
Yet, when I add a trigger to the 8266 Ch 7 widget to email on trip nothing happens. Should this have worked? So the problem appears to be on the side that initiates the action?? A week ago I had no idea that Cayenne existed so I still could be missing something obvious. :slight_smile:

PS: I tried earlier triggering a Uno widget from the 8266 and that did not work.
______________________________________;

int counter = 0;

unsigned long lastMillis = 0;

void setup() {
Serial.begin(9600);
Cayenne.begin(username, password, clientID, ssid, wifiPassword);
}

void loop() {
Cayenne.loop();
delay(1000);
counter++;
}

// Default function for sending sensor data at intervals to Cayenne.
// You can also use functions for specific channels, e.g CAYENNE_OUT(1) for sending channel 1 data.
CAYENNE_OUT_DEFAULT()
{
// Write data to Cayenne here. This example just sends the current uptime in milliseconds on virtual channel 0.
Cayenne.virtualWrite(5, counter, “analog_sensor”, “null”);
// Some examples of other functions you can use to send data.
//Cayenne.celsiusWrite(1, 22.0);
//Cayenne.luxWrite(2, 700);
//Cayenne.virtualWrite(3, 50, TYPE_PROXIMITY, UNIT_CENTIMETER);
Cayenne.virtualWrite(6, 0, “digital_actuator”, “d”);
Cayenne.virtualWrite(7, 0, “digital_actuator”, “d”);

}

// Default function for processing actuator commands from the Cayenne Dashboard.
// You can also use functions for specific channels, e.g CAYENNE_IN(1) for channel 1 commands.
CAYENNE_IN_DEFAULT()
{
CAYENNE_LOG(“Channel %u, value %s”, request.channel, getValue.asString());
//Process message here. If there is an error set an error message using getValue.setError(), e.g getValue.setError(“Error message”);
}


number2
number3


Trigger sms not working currently can you check on it