Axa raamuitzetter

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 …

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

#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