# Axa raamuitzetter

**URL:** <https://community.homey.app/t/axa-raamuitzetter/36044>\
**Category:** Devices\
**Created:** [October 16, 2020, 1:05pm UTC](https://community.homey.app/t/axa-raamuitzetter/36044 "2020-10-16T13:05:45Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![Driesk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/driesk/32/10666_2.png) [@Driesk](https://community.homey.app/u/Driesk)\
**Post date:** [March 27, 2023, 8:45pm UTC](https://community.homey.app/t/axa-raamuitzetter/36044/7 "2023-03-27T20:45:32Z")

</div>

I’ve been working the past few days to control the axa remote 2.0 via a different way. At the moment I can open the windows with an open stop and close command via mqtt. In addition, I get the status back neatly via mqtt.  
a small piece of electronics is needed mpc2003 with some resistors and a nodemcu (wemos will also work)  
The batteries expire and are replaced by a cable, the electronics can be placed near the adapter or in the battery compartment of the axa (a small piece of the battery cover may have to be removed)  
I hope to be able to share a complete description in the coming days.

What I just haven’t succeeded yet and where I can use help with is making an advanced virtual device that looks like below but with the status that is returned via the mqtt topic. and, for example, an icon with an open and closed window.  
Perhaps someone can even write a simple axa app to add remotes. to be continued …

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/a/4a21273b76cb3a99aa6c6cb6c141eb43cae9428a.jpeg)

here’s the code, be gentle I’m not a programmer. Improvements are welcome 🙂

```auto
#include <ESP8266WiFi.h>
#include <PubSubClient.h>

// Definieer de gegevens voor toegang tot het Wi-Fi netwerk
const char* ssid = "wifissid";
const char* password = "password";

// Definieer de MQTT-server waar de ESP8266 mee verbinding maakt
const char* mqtt_server = "192.168.1.13";
const int mqtt_port = 1883;

// Initialiseer WiFiClient en PubSubClient
WiFiClient espClient;
PubSubClient client(espClient);

void setup() 
{

  // Initialiseer seriële communicatie
  Serial.begin(19200,SERIAL_8N2);

  // Maak verbinding met Wi-Fi
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) 
  {
    delay(500);
 // Serial.println("Connecting to WiFi..");
  }

  client.setServer(mqtt_server, mqtt_port);
  client.setCallback(MQTTcallback);
  while (!client.connected()) 
  {
 // Serial.println("Connecting to MQTT...");
    if (client.connect("axaremote_1")) // client id mqtt
    {
// Serial.println("connected");
    }
    else
    {
// Serial.print("failed with state ");
// Serial.println(client.state());
      delay(2000);
    }
  }
  // Abonneer op het topic "axaremote/state"
  client.subscribe("axaremote/commands");
}
// Deze functie wordt aangeroepen wanneer er een MQTT-bericht binnenkomt op het gespecificeerde topic
void MQTTcallback(char* topic, byte* payload, unsigned int length)
{
//Serial.print("Bericht ontvangen op topic: ");
//Serial.println(topic);
//Serial.print("Bericht: ");
String message;
for (int i = 0; i < length; i++)
{
message = message + (char)payload[i];
}
//Serial.print(message);
if (message == "open")
{
open_axa();
}
else if (message == "stop")
{
stop_axa();
}
else if (message == "close")
{
close_axa();
}
else if (message == "status")
{
status_axa();
}

}

void loop(){
// Verwerk binnenkomende MQTT-berichten
client.loop();
}

void open_axa() {
  Serial.println("\r");
  delay(100);
  Serial.print("O");
  delay(20);
  Serial.print("P");
  delay(20);
  Serial.print("E");
  delay(20);
  Serial.print("N");
  delay(20);
  Serial.println("\r");
}

void close_axa() {
  Serial.println("\r");
  delay(100);
  Serial.print("C");
  delay(20);
  Serial.print("L");
  delay(20);
  Serial.print("O");
  delay(20);
  Serial.print("S");
  delay(20);
  Serial.print("E");
  delay(20);
  Serial.println("\r");
}

void stop_axa() {
  Serial.println("\r");
  delay(100);
  Serial.print("S");
  delay(20);
  Serial.print("T");
  delay(20);
  Serial.print("O");
  delay(20);
  Serial.print("P");
  delay(20);
   Serial.println("\r");
}

void status_axa() {
  Serial.println("\r");
  delay(100);
  Serial.print("S");
  delay(20);
  Serial.print("T");
  delay(20);
  Serial.print("A");
  delay(20);
  Serial.print("T");
  delay(20);
  Serial.print("U");
  delay(20);
  Serial.print("S");
  delay(20);
  Serial.println("\r");
  //delay(100);

  static char buffer[80]; // Definieer een buffer van 80 bytes proefondervindelijk
  
  int count = 0;
  while (Serial.available() && count < 79) { // Lees inkomende data totdat de buffer vol is
    buffer[count++] = Serial.read();
  }
  buffer[count] = '\0'; // Voeg een nul-terminator toe om de string af te sluiten
  
  if (count > 0) {
    // Controleer of de string "open" of "dicht" bevat en publiceer de status via client.publish
    String res = String(buffer);
    if (res.indexOf("Strong Locked") != -1) {
      client.publish("axaremote/state", "locked");
    } else if (res.indexOf("UnLocked") != -1) {
      client.publish("axaremote/state", "opened");
    }
    else{client.publish("axaremote/state", "state unknown");
    }
  }
  
}

```

more info on the dutch section of the forum

> [@AXA remote 2.0 bedienen / klimaat regeling deel 2](https://community.homey.app/t/axa-remote-2-0-bedienen-klimaat-regeling-deel-2/47167/57):
>
> een nodemcu v2 zie de afbeelding hieronder. Dit is een 2e versie op basis van hetzelfde principe Nog wel een paar opmerkingen na een week in gebruik zonder problemen. -homey moet een vast ip adres hebben ivm de MQTT broker -Als de homey herstart of de broker, moeten de axa remotes opnieuw verbinding maken resetknopje indrukken is voldoende. Wie kan de code aanvullen met een stuk dat regelmatig de mqtt verbinding test en opnieuw verbindt. -Als je meerdere axa remotes wil aanstu…

---

_[View the full topic](https://community.homey.app/t/axa-raamuitzetter/36044)._
