Need help understanding variables and how to use them


#1

1) Give a description of the problem
I have no idea how to use variables, but want to learn. I copied part of this piston from a different example, but the variables are not being read out loud by LANnouncer.

2) What is the expected behavior?
All information, including variable, is read out loud.
“The time is 4:30pm. It’s 72 degrees and sunny outside. Tonight’s low is 50 degrees. It is a comfortable 70 degrees inside.”

3) What is happening/not happening?
Basic text is read out loud, but not variable.
“The time is ____. It’s __ degrees and __________ outdoors. Tonight’s low is __ degrees. It is a comfortable __ degrees inside.”

4) Post a Green Snapshot of the piston!


#2

I’m not a programmer/coder so some of the information I provide may be too simple.

A variable is a placeholder for something that varies or changes. We plug that variable in within fixed parts of a sentence like you have above.

In the image you posted above, currentOutsideTemp would normally be filled in by a device that has access to your outside temperature. That device can be a sensor mounted outside or from a weather data source like weather underground using the built in webcore/ST integration.

Right now your device is not speaking the correct info because there is no data inside the variables. You will need to provide that to complete the sentence.


#3

OK, so I guess my real question is how do I get data into the variables? Or is there a better way to get the desired result for this piston? Ultimately, I just want the information spoken when a switch is turned on. Is using variables the best way to do that?


#4

Something like this might get you started…

You can see how it evaluates in the expression box below:

There’s a bunch of weather related features on the wiki at:
https://wiki.webcore.co/Weather


#5

@allrak’s example is a good one for setting weather related variables. There’s also the webcore task called, you guessed it, Set variable. You can set a variable value to the result of calculations etc.


#6

That code looks mighty familiar… :sunglasses:


I can’t share the whole piston, but this is how I gathered a few of those variables:

It is important to note that my snippet above does not show hiLowString, popString, or bodyTemp.
(I cut those sections out so as not to confuse)


#7

I appreciate all the help so far, but I’ still missing something.
@WCmore yes, your other post inspired me to try this. The difference is I’m not using Tasker and notifications or an Echo device. My setup is all on an Android tablet using LANnouncer.

Anyway, I have tried a few different ways to do this, but it’s still not working. Right now, it speaks "Good morning! The time is 11:47am. It is _____, and zero degrees outside. It is a comfortable zero degrees inside.’

Updated piston screenshot below. Thoughts?


#8

Your syntax looks good. I imported it, and it ran perfectly for me as a PUSH notification.

temp

The only real difference between our two pistons is that I put a 1 second delay between the gathering of data and the reading it back. This might not be needed, but I wanted to give that extra moment for the data to be retrieved and written. (there are some versions of Nest that take a bit to respond with current info, so maybe that is causing the hiccup)

Are your variables populating up top in the define section after the piston runs?


Side note:
I wonder if the degree symbol on line 32 is confusing your LANnouncer


#9

OK, I don’t know what happened, but it works now. I didn’t do anything besides go work on a different piston and then come back to this one. :thinking:
Yes, the variables are populating in the define section now, and LANnouncer is talking just like I want it to. Thank you again to everyone here!