Access to Customize Triggers or Run Python Scripts


#1

This may already be part of the planned trigger/scheduling update, but I would really like to have access to customize the actions that take place on a trigger. Ideally as part of the trigger setup there should be an option to create custom python code do do whatever we want it to do instead of predefined functions.


Event trigger custom script
#2

Thank you for your suggestion I will pass this on to our team


#3

we have identified to integrate existing macro feature into webiopi, but we want to make it the more user friendly possible.


#4

will you support this suggestion? I also would love to hit a button and it run a python script?!!


#5

Yes, I’ll be organizing an online meetup so we can get your input on this very soon. I’ll be sure to notify you so you can participate :slight_smile:


#6

@helder-rodrigues @ats1080s We’d love to get your feedback here. Online Meetup - 03/24/16 12pm - 1pm PDT


#7

I would also love this option as well.
So much easier for some of us to just write a quick script or make a script to run the gpio/relays in a set to make lights blink a certain way ect…
nothing against your triggers menu but some of us would love this feature.


#8

Is there any news regarding this topic?


#9

@mase.hacker @teddfan This is behind a few other features that we are working on at the moment. Probably will get this going beginning of 2017!

-B


#10

Any updates on this?


#11

Hi @julian,

I’ve been able to run Python scripts on my Pi triggered by a button on the Cayenne dashboard using the MQTT API and the Cayenne Python MQTT library.

I’ll make an example today and post it in The Library, then link it here so you can see how I’m accomplishing this.


#12

Hi again @julian,

Please find the post I mentioned detailing how to trigger python scripts from a Pi custom button widget here. If you have any questions or trouble with it, please let me know.


#13

Thanks a lot!


#14

I tried this tutorial but when I run the code I get an error message saying:

self.on_connect(self._userdata, flags_dict, result)
TypeError: on_connect() takes 3 positional arguments but 4 were given

This seems to be a problem in the cayenne.client code.

If you want the entire error message let me know and I can include it.


#15

I ran into this on one of my Pi’s last week. It turned out to be that we use a package called paho-mqtt, and we’re expecting version 1.2.3 with the example code with have in Github. When version 1.3.0 is installed, it left that error message. While we need to adjust our code so it will play nice with 1.3.0, in the meantime this can be worked around by simply installing v1.2.3 of the paho-mqtt package.

You can first check to make sure that it is the same thing, if you have paho-mqtt 1.3.0 running:

pip show paho-mqtt

Assuming you are, to change it to version 1.2.3:

sudo pip install paho-mqtt==1.2.3

Again you could run pip show paho-mqtt to verify the change was made correctly. At this point you should be able to run our example code without that error message about the number of arguments.


Executing custom code on your Raspberry Pi from Cayenne
#16

Thanks a lot. Will I have to update this again to 1.3.0 later or will that be automatic?


#17

For where the code stands right now, you actually want it to say on 1.2.3, so I’d say the real question is the opposite: will running some update on the Pi update you to 1.3.0 (which you don’t want right now) and break the example agent code?

Fortunately I think the answer is no unless you very specifically went into pip and started running updates. You can easily toggle between the two (or any other version) with the same commands though, so

sudo pip install paho-mqtt==1.3.0 to install 1.3.0
or
sudo pip install paho-mqtt==1.2.3 to install 1.2.3

and so on.


#18

Does updating the Pi always mean that it might break something on Cayenne? Or is there a way to make this future proof so that there is 0 risk of it breaking? What if I made a project for someone less tech savvy and give them instructions on how to run, it is there a way to guarantee that it’ll always work for them?


#19

One of the features of software is that updates always have the risk of breaking. You have to update to keep compatibility with the server and fix security, bugs, performance, etc. In short, there’s no way to guarantee anything with any product, however, if done correctly on server and client you shouldn’t have any problems.


#20

Has the code been adjusted so that version 1.3.0 works or should I still use 1.2.3?