Could you confirm that, when entering the code in Local.py to service a feedback button (eg FB-1), the text that is to appear in the two states of the button MUST be entered in lower case, even though when displayed on the button the first letter of each word is capitalised ? and is this documented anywhere ? I have spent a lot of time sorting this out - could it be that I should have rtfh (Read That Formidable Handbook) ?
Well, yes. It was decided to do this to remove the lower case / upper case conundrum. And no, it isn't documented anywhere, but it will be shortly! I've got to go look through the Feedback button code in the App and figure out what it does so I can put it in the RTFH!
Here's an example of the code that we use. Note that we convert the Button name into lower case, do our comparisons and the convert back to "title" format with: responseData = responseData.title()
The state of the Fan is in a file so other processes can read the current fan state. The default section is there because there is a possibility in the case of an Internet hiccup the button can go blank.
This is a section of code that toggles a Fan on and off on GPIO18.
# FB-12 - turn on GPIO 18 (fan) if (objectServerID == "FB-12"):
#check for validate request # validate allows RasPiConnect to verify this object is here if (validate == "YES"): outgoingXMLData += Validate.buildValidateResponse("YES") outgoingXMLData += BuildResponse.buildFooter() return outgoingXMLData
# not validate request, so execute
responseData = "XXX" if (objectName is None): objectName = "XXX"
responseData = "turn fan on" responseData = responseData.title()
# defaults to fan on (meaning fan is off) else: lowername = "turn fan on" GPIO.setup(15, GPIO.OUT) GPIO.output(15, True) time.sleep(0.3) GPIO.output(15, False) f = open("/home/pi/ProjectCuracao/main/state/fanstate.txt", "w") f.write("0") f.close()
Thanks for your very helpful reply. I had wondered what 'lowername' actually meant - all now clear. (I shall put a comment in my own code here to remind me in future). I have learnt a lot from your code example. What an excellent system this is !