Webhook publishes but never triggers subscription- Fixed

I am trying to convert some particle functions to use webhooks instead. I have successfully created the webhooks and i know they are working because I can see them getting triggered in the dashboard at the correct time. The thing is, the subscribe function never seems to be activated in the firmware…
Below is the relevant code sample.

void gotWeatherReply(const char *name, const char *data) 
  String condit = String(data);
	#ifdef USE_SERIAL_OUTPUT   //Allow Serial Output
		Serial.print("Setting outdoor temp from web to ");
	// I abbreviated the rest since the serial never prints anything so I don't think it's ever being called

void gotAppendReply(const char *name, const char *data) 
    String str = String(data);
    // We're really just processing a return code

void setup()

	#ifdef USE_SERIAL_OUTPUT   //Allow Serial Output
	 	while (!Serial.available()) Particle.process();
	 	//Particle.process() replaces SPARK_WLAN_Loop()
// Limit names to 12
	Particle.function("set_setpoint", setSetPointFromString);			// Simple function which can set the setpoint externally.
//	Particle.function("set_condits" , setConditsFromString);			// Deprecated renamed to gotWeatherReply and converted to webhook // (1) Sets all weather info conditions and forecast
//	Particle.function("set_forecast", setForecastFromString);			//Deprecated, replaced by NComboWeather in google script.
	Particle.function("set_ti_read",  settInfoReadFromString);    // (3)could be eliminated if trigger from inside

 	Particle.variable("setpoint_tmp", &desiredSetPoint, INT);
 	Particle.variable("indoor_temp", &indoorTemperature, INT); 	// Can be reported in JSON with other info. DO it with internal info read or created by Photon
	Particle.variable("outdoor_temp", &outdoorTemperature, INT);
	Particle.variable("is_heat_on", &isHeatOn, INT);  				// Could change to string with heat on and how many seconds today
	Particle.variable("tempInfo", resultstr, STRING); 					// (2) When reading this varible, then write a TRUE to tInfoRead to mark that it has been read
 	Particle.variable("infoLog", results2, STRING);				//(deprecated?)The variable does not need an & if it is defined as an array of char since this is the native

	Particle.subscribe("hook-response/get_weather", gotWeatherReply);
	// Lets listen for the hook response
  Particle.subscribe("hook-response/append_2sheet", gotAppendReply);

 		//																													type for this method

    // publish the event that will trigger our Webhook
  delay(2000);  give it some time to run bofre the loop
//	nextWeatherTime = (currentSecs - (currentSecs % (LOG_INTERVAL)) + (LOG_INTERVAL) -120);  // 15 Minutes;((1458569013)+900)-MOD(A66,900)
	nextLogTime = currentSecs - (currentSecs % (LOG_INTERVAL)) + (LOG_INTERVAL);  //Sets logging to be at even 10 minute intervals 
	nextWeatherTime = nextLogTime - 120;  //Update weather 2 minutes before the log

I never see the serial prints that would indicate the function being called

You are missing a Serial.begin(9600); in setup()

It’s there in the if def statement. I have serial turned on and am getting info.

On the Photon Serial is always on, so seeing Serial output is no valid indicator that your #ifdef branch actually got compiled.
So try having an unconditional feedback inside that handler.

BTW, I can’t see the #endif for the #ifdef USE_SERIAL_OUTPUT in setup().

I’ll take that out, but I do know that it’s not being executed because it gets populated on my screen, and logged to flash drvie and none of this is happening. However, I will remove the if defs, they are really an artifact now from using a core for this code previously. (Basically ran out of space).
The endif was there but seemed to disappear in this post

All of my serial outputs work except for the ones in the function that is to be called.

Hmm… It might be better not to perform Serial.print() in the function handler for subscribing to events.

I can try to see if Serial works in the function handler for subscribe.

Update: Indeed Serial is not working in the function handler. Wondering if this is a bug…

Ping @BDub

Hmmm. I made the changes and still see nothing. As i said, I have it update variables that get printed on a display (weather Data). The display never updates so yes, I threw in the Serial to see what was going on, I still wonder if i am just having a fundamental misunderstanding of what I should expect.

I have had this working with Google scripts on a timer getting the weather parsing Json, and calling a particle function to take the CSVs and populate my variables . I changed it to be a webhook handler to do the same thing but this time, I call the weather script from within the Photon (The script is now published as a google web app. I can call that HTTPS… from the webhook.
It seems to be working from cli:> particle subscribe mine.

i see the weather hook called on the 8’s and bunch of stuff from the append webhook that looks like errors due to there being missing weather data.
I was prepared to have problems with the appending top sheet due to permissions, but the weather needs nothing as far as authentication and seems to be returning the string of csv, but nothing goes on in the photon. I assumed it was publish working right but subscribe not working.

BTW, in the cli particle subscribe doesn’t show up as a keyword if you say particle list
Seems like it should.

The IFTTT docs use Serial.println() explicitly in the handler example so I would have to say it’s a bug… OR the handler isn’t being called at all…

I have a series of variables to parse in my real handler , and none of those are ever touched. (I set out of sane range values as initial valies to make any failure to update obvious (like -80 for the low temp of the day … These values are untouched for things that the handler should update (generally a bad parse would have zeros or something else.)

@svartbjorn In some previous firmwares a while back, I sometimes had to adjust delays after the subscribe statement to get it to work, and more recently I ran into this: https://github.com/spark/firmware/issues/738 , which potentially could be related. At the risk of it just being a red herring, maybe you could see what would happen if you decreased the delay a few lines after subscribe to just half a second and/or replace the hard delay of 2 seconds with a soft delay of half a second, eg.,

uint32_t lastTime = millis();
while (millis()-lastTime < 500) {Particle.process();}

subscribes might also be subject to such failures of registration as are variables, who knows?

Thanks for the suggestions, I implemented the change in timing but I also added ,MY_DEVICES to the argumant list on the subscription. I now do get the function triggered, unfortunateley I get a mass of HTML instead of my string because i am trying to call google api script that is asking for credentials. Looks like I need to try an IFTTT or something else entirely. The weather script really needs no login but it is still demanding one. Adding a row to the spreadsheet will need something that allows a login.

So i guess as far as this goes I have to call it fixed because it returns, I just have to keep going to get what I want.