More complex triggers?

Is there any way to get more options for trigger?

If “one thing” and “other thing” then do "something"
At 12:00 do “something” if “something”

I need to control outside lights using photoresistor and clock to turn lights on and off when time is right and when its dark…
But don’t know how to do it…

The short answer is, enhancements to the boolean logic in the trigger system are coming.

This is one of the most requested features on the community, and we’re finally getting to the end of all the back end / enterprise work that has kept our development team from knocking out these hotly community requested features.

That said, sometimes the solutions are a little hacky, but for certain types of conditional statements, people have been able to achieve these using multiple IF/THEN statements, and when time is involved, using the Cayenne Scheduler in conjunction with the Triggers feature.

Have a look at this idea from an older thread on the same subject to see one way this could be accomplished: Conditional triggers

1 Like

Hi, I’m looking to work with more complex triggers.

For example, if I have a ESP8266 with multiple temp sensors (ie zone 1 and zone 2), I would like to turn on a fan connected to another Esp8266 if the temperature in zone 1 is greater than the temperature in zone 2 AND the temperature in zone 2 is not below 0 celsius.

Any thoughts about how I can implement such a trigger?


Only with esp8266 a bit difficult. you can try to use cayenne rest API and get the latest data on a raspberry pi using Python code to access basic cayenne API. and then have a trigger to turn on the fan.

Puoi anche usare solo esp8266. Ce una miscussione con il codice x condividere

well, yes you can subscribe the two esp8266 publish topic. thanks @Massimotruglio83 for pointing it out.

Hi Shramik,

I have been working with the REST API that you pointed out to me. I can now read temperature from various sensors with the REST API, calculate their average and if they’re within a certain threshold, I want to turn on a fan. Using the cayenne dashboard, I’m using a slider to switch between 0 and 1 to turn the fan on and off. (using the button somehow didn’t work for me).
But, I’m now attempting to use the REST API to send a publish event to switch the slider from 0 to 1, however the esp8266 is not picking up on the change in state, even though if I refresh the Cayenne dashboard I can see that the slider has switched from 0 to 1.

In the publish event, I’m sending the device_id, channel, value, unit and type. For unit and type, I’m using unit = “Analog” and type =“analog_actuator” for the slider. Unfortunately, this doesn’t seem to work. Am I using the correct unit and type for the slider? I’m using the information found here: Data types for Cayenne MQTT API


to send actuator data use this:

curl --request POST \
  --url \
  --header 'authorization: Bearer access_token \
  --header 'content-type: application/json' \
  --data '{
  "channel": 5,
  "value": 1

It doesn’t appear that I can submit only channel and value with the device_id. I get a HTTP status 400 if I do this. Whereas if I provide the unit and type, I see HTTP status 200, the slider has moved in the Cayenne Dashboard, but the next time the esp8266 polls, the slider setting is not received. I’ll have to do some more debugging on the esp8266 to verify.

  --url \
  --header 'authorization: Bearer access_token' \
  --header 'content-type: application/json' \
  --data '{
  "channel": 5,
  "value": 1

it works fine for me. i get a 200 response. I even used it in one of my projects Jarvis Cayenne

Hi Shramik,

A couple things to note. I didn’t realize there was a difference to publish data for a sensor versus publishing for an actuator. So I added a function to publish for the actuator, with the appropriate URL to match what you provided.

I have confirmed that when using CURL I can get the actuator to switch, but when I use the python API code with the publish actuator function, the code still fails to publish to the actuator even though the authorization succeeds. Code snippet below. Any ideas how to debug this further?

print('Change state of fan ‘+device_id+’ on channel ‘+str(channel)+’ to ‘+str(value)+’ in: '+zone_id)

URL = ‘’+device_id+’/cmd
headers= {‘Authorization’: 'Bearer ’ + access_token}
data = [{‘channel’: channel,
‘value’: value

response =, json=data, headers=headers)

check the python code for this project.