gboudreau / nest-api

Unofficial Nest Learning Thermostat API
GNU Lesser General Public License v3.0
300 stars 93 forks source link

pass variable as parameter #113

Closed vjooris closed 4 years ago

vjooris commented 4 years ago

Hello, I'm developing a php based on your class. (this class is GREAT) I would like to pass variable $setTmp = 20.5 (this variable contains the target temperature I want to set. if I enter $success = $nest->setTargetTemperature($setTmp);, into my php code, I've a "nice" 500 error. but with $success = $nest->setTargetTemperature(20.5); it works perfectly.

Is it possible to pass a variable ? Thank you

bauzer714 commented 4 years ago

Do a var_dump() on your variable. I'm betting it's not what you think it is.

vjooris commented 4 years ago

Hello, Thank you for your VERY FAST response. this is the result of the var_dump() string(4) "21.5"

Sinds I'm NOT a developper, if you can telle me with I've to code for this ....

bauzer714 commented 4 years ago

Can you paste your code?

kueblc commented 4 years ago

You will need to convert that string to a number

vjooris commented 4 years ago

yes, this is what I expected, but do you know (I didn't found it on Google) the function to convert text to number ?

kueblc commented 4 years ago

Try

$success = $nest->setTargetTemperature((float) $setTmp)

This isn't really an issue with @gboudreau's nest-api, rather you might benefit from studying some PHP programming guides/tutorials.

vjooris commented 4 years ago

Can you paste your code?

please. Thank you for your help, this is a RAW code...

Nest.php.txt

vjooris commented 4 years ago

Try

$success = $nest->setTargetTemperature((float) $setTmp)

This isn't really an issue with @gboudreau's nest-api, rather you might benefit from studying some PHP programming guides/tutorials.

I'd tried float ($setTmp) without success, but pour syntax works perfectly ! THANK YOU.

P.S. : of course this was not an issue, but just help needed ...

vjooris commented 4 years ago

P.S. : of course this was not an issue, but just help needed ...

kueblc commented 4 years ago

P.S. : of course this was not an issue, but just help needed ...

This is not the place to ask for help with learning PHP. There are countless forums and resources out there to help you learn to program. Continuing to open issues on projects to ask for help with unrelated problems is an abuse of maintainer time. Please stop and do some basic research.

vjooris commented 4 years ago

ok, I'm do not want to abuse anyone. I thought here was the best place to ask a specific question on the development. I already searched on Google without success.... I'll stop asking questions. Anyway, thank you for your help