Trigger is not working

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

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”);
}

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!

1 Like

@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.

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?

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

@margettepv made some changes to your code and start with a new device and DO NOT add the widget from dashboard (add new). this code will automatically add a widget. then add the trigger.

int counter = 0;

unsigned long lastMillis = 0;

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

void loop() {
Cayenne.loop();

	if (millis() - lastMillis > 10000) {
		lastMillis = millis();
                counter++;
		//Write data to Cayenne here. This example just sends the current uptime in milliseconds.
		Cayenne.virtualWrite(0, counter);

	}
}
// 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”);
}

I wasn’t sure what you wanted me to trigger so I set it up as an email notify. Did not trigger. The run count on that trigger still shows 0.

Shramik,

I followed your provided instructions to add a new NodeMCU ESP8266 device and then tested three trigger variations on it - to fire the Widget button to ON when the set threshold value was reached. When it didn’t fire, I deleted the button widget and created a new button widget using a different channel number, deleted the initial triggers and then recreated new corresponding triggers. They also failed to fire.

Additionally, I deleted one of my REAL devices, updated the motion sensor code with the following: “Cayenne.virtualWrite(motionSMSON, HIGH, “digital_sensor”, “d”);”. I also used the automatically added digital sensor widget for the channel by clicking on the + sign and then created a trigger to fire an SMS when the widget went HIGH. The motion sensor widget on my device DOES properly indicate motion On and Off on the dashboard. However, the trigger does not fire…

Again, I had 10+ triggers set up for my four ESP’s that had worked without error for more than a month. ALL of them simultaneously stopped firing five days ago.

Below is the screenshots from the tests I just completed.



I am new to cayenne, only been on for a week now. I have never been able to get triggers to work. i thought i was doing something wrong but im sure now there is a bug.

let me check whether there is a bug with triggers and i will get back here.

Thanks for checking into it! If someone would like access to my account to check on it just let me know.

my triggers still dont work, has anyone looked into it?

The solution that works for me is that it seems that you should use plot for triggering not the meters for example. I mean if you use meters for triggering just add a plot and use the new plot for triggering. It works for me and a little bit strange thing!!! :slight_smile:

Hi

I was tested the triggers, the text notification. I make if the the temp below -2 C the send me a massge. But it doesnt work, just when i open the app or the we site, then send it. It always need to run in background or need always open the dashboard??? It doesnt good.
I wanna to make a complete ventilaton control system, but it neccesary to run without i Will open the app. For example, need change the ventilator speed belove -5 C to dont freeze the heat exchanger.
What do you think, it would be work or need find something else solution?

It was works, just need some delay

Hi @ericjsimerman,

We have looked into it and pushed some changes, can you test again?

~Benny

Hi @margettepv,

We’ve made some changes for triggers, can you see if you are able to use triggers?

~benny

Hi @jfb820,

We pushed some changes for triggers, can you check again and see if they are back to working for you?

~Benny

1 Like

YES! We have triggers. It seems the only one that isn’t working is the on-off line.
Thank You!
John