Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call Particle Proton Function #7

Open
scottsuine opened this issue Oct 23, 2016 · 2 comments
Open

Call Particle Proton Function #7

scottsuine opened this issue Oct 23, 2016 · 2 comments

Comments

@scottsuine
Copy link

I have installed homebridge-particle and have it successfully subscribed to events and working. I am trying to get a successful function call

my Proton has the following function exposed
get ACStatus
it accepted a string Args and I have made is accept a string in the format "1=1" and "1=0". If I type these strings into the particle iPhone app, the function works as expected

my accessoryr section in config.json is
"accessory": "Airconditioner",
"name": "Air Conditioner",
"deviceid": "removed for privacy",
"type": "LIGHT",
"function_name": "setACStatus",
"args": "1={STATE}"

The accessory is visible in Homekit and I can toggle the button, however the function is not sucessfully called and is not triggered, what am I doing wrong

thanks

@danlee6992
Copy link

you need to call your function argument. For example if you have a function in your particle code with the "on" argument, you would need to set that as the args. below is a quick sample particle code showing the "on" argument being passed.

`void setup() {
Spark.function("on", on);
Spark.function("off", off);
pinMode(relay, OUTPUT);
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);

}

void loop() {
/*
digitalWrite(relay,HIGH);
delay(2000);
digitalWrite(relay, LOW);
*/

}

int on(String command)
{

       digitalWrite(relay,HIGH);
        digitalWrite(led,HIGH); 
        digitalWrite(led2, HIGH); 

}`

@matthieunelmes
Copy link

I'm really struggling to understand the above example and how it relates to "args" parameters in the particle devices section in the config.json

Can anyone provide a working example to toggle a switch on/off both config.json and particle firmware.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants