 		}
 		//set current state to inactive
 		currentRoomState = INACTIVE;
-		returnCode = publish("state", "inactive");
+		returnCode = publishToBroker("state", "inactive");
 	}
 	//else if emergency button pressed
 	else if (newRoomState == EMERGENCY) {

//MQTT constants
#define MQTTCLIENT_QOS2 1
const char* mainTopic = "londonbridge";
MQTT::QoS qos = MQTT::QOS2;
bool retained = true;

//Room State

	//establish Ethernet connection
	Ethernet.begin(mac);
	//connect to MQTT broker
	while (!mqttClient.isConnected()){
		connect();
	}
	//set current room state to inactive
	currentRoomState = INACTIVE;
	publishToBroker("state", "inactive");
}

void loop() {
	if (!mqttClient.isConnected()) {
		connect();
	} else {
		checkSwitches();
	}
}