Reputation: 11
I have tried for several days to get my RPi button press accessible through Dataplicity on my phone. I know it is a custom action with on/off, but I am unable to get the interface with on/off to control my button press. The example is for a red and green light on/off. I essentially have a cluster of lights hooked up through a relay to pin 17. Pin 18 controls the button and pin 17 works the relay. One press of the button turns the Christmas lights on for the allotted amount of time I specified. Any suggestions? The link to the example code is: https://docs.dataplicity.com/docs/custom-actions-gpio
Just not sure how to merge the two. This is my first major project and I have no background in programming. the button press code is as follows:
from gpiozero import Button
from gpiozero import OutputDevice
from time import sleep
relay1 = OutputDevice(17)
button = Button(18)
x = 0
relay1.off()
while x < 1:
print("Lights off...")
button.wait_for_press()
print("The button was pressed!")
relay1.on()
print("Lights on...")
print("Waiting...")
sleep(60)
relay1.off()
I tried leaving the red portion out of the code in Dataplicity, but I am not sure how to get it to include the relay portion
Right now, under custom actions on my phone it says Control LEDs Green LED and then it shows a spinning wheel that never loads
Any suggestions are appreciated =(
Upvotes: 1
Views: 48
Reputation: 31
Could it be that at the end of the button press you're not returning an "OK" status for the custom action?
Similarly as per the example in the document that you linked:
# Custom Action executed succesfully
echo "[[[ReturnOK]]]"
Best regards,
Dataplicity 🤗
Upvotes: 1