Workaround for triggers (some Rube Goldberg logic)

One of my projects leans heavily on triggers and scheduling and despite all efforts put in by @rsiegel and others they are not yet working flawlessly.
The triggers problem is simple it is not possible yet to create multiple triggers with the same IF. So a user (@shramik_salgaonkar) suggested to create a new (even two) buttons which includes the multiple actions later called some Rube Goldberg logic, hence my topic.
In my simplicity and sometime ignorance what the best coding is to achieve this I am using the code:

CAYENNE_IN(V10) // Because 2 is a crowd for triggers, 1 trigger for all Night Time events GO-GO-GO in testing
{
Cayenne.virtualWrite(V5, getValue.asInt());
Cayenne.virtualWrite(V6, getValue.asInt());
}

However did only does partly the trick, because the buttons V5 and V6 will turn on/off to the same status of V10 however without doing the actions behind V5 and V6. I was hoping it would do similar as if you would do a scheduling or a trigger. Example code (the action behind):

CAYENNE_IN(V5) // action switch lamp V5
{
Flamingo_Send(V5, getValue.asInt()); // ON/OFF
delay(time2wait);
}

So looking for a solution without adding addition lines, true in this example it is only 2 lines for each action extra and I can be sloppy with programming because I am using an ESP8266 (Wemos D1 R2). But I need to copy this about ten times and not all sensors have the same coding.

Another really dirty solution is to add a delay so the connection with the server is lost and during “reboot” everything is set to the latest status (but this will result in loosing connection continuously)

you can use Cayenne.virtualWrite(V5, 0); or Cayenne.virtualWrite(V5, 1); as well, but it won’t be dynamic. You can also set a global variable which would make it dynamic. Cayenne.virtualWrite(V5, someGlobalVariable); What you have there will indeed always be the value of V10.

You can also make a function and call it there

void someFunctionOne(){
  //do some stuff
}

void someFunctionTwo(){
  //do some stuff
}

CAYENNE_IN(V10) // Because 2 is a crowd for triggers, 1 trigger for all Night Time events GO-GO-GO in testing
{
  someFunctionOne();
  someFunctionTwo();
}

Hi @adam Think I have some problems to explain my problem.

The objective is for the trigger is: IF (night time) than (V10 equal GO)
and (GO) wil do the actions (V5) and (V6)
as you can see in my testproject it does!
(but only partly)

  • Push on GO and V5 and V6 will get the same value, push again ditto

However if does only set the status of V5 and V6 and does not perform anything caputered inside CAYENNE_IN(V5) and CAYENNE_IN(V6) whereas the trigger IF (night time) than (V5) will do this.
You can test this by pushing V5 and one of the actions is the increase of the value of “Did V5 run?”
(it will also turn light in my room so i know you, or somebody else is working on it)

So the real question is: How can I set V5 and V6 and perform all actions captured inside CAYENNE_IN(V5) and CAYENNE_IN(V6) without duplicating these actions!

I hope we can enable to build the project exactly how you want. It sounds pretty cool :slight_smile:
~Benny

Hi @bestes thanks for your reaction.

At the moment I need to do these workarounds due to the present misbehavior of scheduling and triggers. My “GO”-solution is a good example but it only works partially; it sets the right status of the widget but it does not perform the actions behind this widget-status and captured in CAYENNE_IN(Vxx). It is likely that my T&E-approach did not find the correct solution; any ideas (without copying the actions)?

I can create an external workaround because my switches excepts multiple codes so I can give them all an extra code but then I will not batter you guys anymore and you will not hear of problems your users (=me) encounter.

But lays the problems at your side? In example I receive today a notification of a schedule but the schedule itself is not actually performed, a 2nd schedule ditto, however a single trigger performed like clockwork. Likely the schedule roundish 23:40 will perform without a problem. So what is causing this problem?

Sketch – Device –WIFI - LAN – WAN –SERVER ?

Thoughts:

  • BTW the problems re-started again after a recompile of the sketch, coincidence?
  • Could it be that while during the timer loop (up to 1 second) all Cayenne actions are ignored? However this loop is only done on a 60 second basis.

Keep up the good work, you all provided an excellent “playground”.

1 Like