matt (support) wrote:Also make sure you use dumb quotes instead of smart quotes.
matt (support) wrote:Also make sure you use dumb quotes instead of smart quotes.
matt (support) wrote:Not automatically if you type it, but I imagine if you copy/paste from the forum (which is showing smart quotes) they will be smart.
DaveL17 wrote:I would also suggest that it would be better to use ['batteryLevel'] rather than ['batteryLevel.ui'].
States that end in 'ui' are the ones that are used by Indigo for display in the UI and control pages. You won't necessarily run into trouble, but you might. For example, the UI value might include symbols or other characters.
Dave
batteryLevel : 85 (integer)
batteryLevel.ui : 85% (string)
DU Lou wrote:I actually intentionally picked the .ui so I could see the "%" symbol in the email message. Is that bad?
theSubject = “Foyer battery level is %s%” % (batteryLevel)
DaveL17 wrote:DU Lou wrote:I actually intentionally picked the .ui so I could see the "%" symbol in the email message. Is that bad?
Absolutely not.
But one day, you might be pulling a value to do some math or logic test and the .ui value might trip you up. What I do (just as a matter of good practice IMO) is to pull the value without the "%" and add the "%" in after the value is inserted using '%s':
- Code: Select all
theSubject = “Foyer battery level is %s%” % (batteryLevel)
theSubject = “Foyer battery level is %s%” % (batteryLevel)
DU Lou wrote:DaveL17 wrote:That makes sense although when I useIndigo returns "embedded script: incomplete format"
- Code: Select all
theSubject = “Foyer battery level is %s%” % (batteryLevel)
theSubject = “Foyer battery level is %s\%” % (batteryLevel)
theSubject = “Foyer battery level is %s%%” % (batteryLevel)
FlyingDiver wrote:DU Lou wrote:DaveL17 wrote:That makes sense although when I useIndigo returns "embedded script: incomplete format"
- Code: Select all
theSubject = “Foyer battery level is %s%” % (batteryLevel)
Heh. The % is a special character in print type statements, so that happens. You actually need:
- Code: Select all
theSubject = “Foyer battery level is %s\%” % (batteryLevel)
The backslash says to just use the %, don't treat it special. At least, I think Python works that way. If you get an error, try "%%" instead of "\%".
Users browsing this forum: No registered users and 1 guest