<commit_before>/* AFE Firmware for smart home devices
  LICENSE: https://github.com/tschaban/AFE-Firmware/blob/master/LICENSE
  DOC: http://smart-house.adrian.czabanowski.com/afe-firmware-pl/ */

#include "AFE-Contactron.h"

AFEContactron::AFEContactron(){};

AFEContactron::AFEContactron(uint8_t id) { begin(id); }

void AFEContactron::begin(uint8_t id) {
  AFEDataAccess Data;
  ContactronConfiguration = Data.getContactronConfiguration(id);
  MQTT MQTTConfiguration;
  MQTTConfiguration = Data.getMQTTConfiguration();
  pinMode(ContactronConfiguration.gpio, INPUT_PULLUP);
  state = digitalRead(ContactronConfiguration.gpio);
  state = state;
  sprintf(mqttTopic, "%s%s/", MQTTConfiguration.topic,
          ContactronConfiguration.name);
  if (ContactronConfiguration.ledID > 0) {
    ContactronLed.begin(ContactronConfiguration.ledID - 1);
  }
  _initialized = true;
}

void AFEContactron::convert() {
  if (ContactronConfiguration.outputDefaultState == CONTACTRON_NO) {
    if (state) {
      ContactronLed.on();
      _state = CONTACTRON_OPEN;
    } else {
      ContactronLed.off();
      _state = CONTACTRON_CLOSED;
    }
  } else {
    if (state) {
      ContactronLed.on();
      _state = CONTACTRON_CLOSED;
    } else {
      ContactronLed.off();
      _state = CONTACTRON_OPEN;
    }
  }
}

byte AFEContactron::get() { return _state; }

const char *AFEContactron::getName() { return ContactronConfiguration.name; }

const char *AFEContactron::getMQTTTopic() {<commit_msg>changed led light<commit_after>/* AFE Firmware for smart home devices
  LICENSE: https://github.com/tschaban/AFE-Firmware/blob/master/LICENSE
  DOC: http://smart-house.adrian.czabanowski.com/afe-firmware-pl/ */

#include "AFE-Contactron.h"

AFEContactron::AFEContactron(){};

AFEContactron::AFEContactron(uint8_t id) { begin(id); }

void AFEContactron::begin(uint8_t id) {
  AFEDataAccess Data;
  ContactronConfiguration = Data.getContactronConfiguration(id);
  MQTT MQTTConfiguration;
  MQTTConfiguration = Data.getMQTTConfiguration();
  pinMode(ContactronConfiguration.gpio, INPUT_PULLUP);
  state = digitalRead(ContactronConfiguration.gpio);
  state = state;
  sprintf(mqttTopic, "%s%s/", MQTTConfiguration.topic,
          ContactronConfiguration.name);
  if (ContactronConfiguration.ledID > 0) {
    ContactronLed.begin(ContactronConfiguration.ledID - 1);
  }
  _initialized = true;
  convert();
}

void AFEContactron::convert() {
  if (ContactronConfiguration.outputDefaultState == CONTACTRON_NO) {
    if (state) {
      ContactronLed.on();
      _state = CONTACTRON_OPEN;
    } else {
      ContactronLed.off();
      _state = CONTACTRON_CLOSED;
    }
  } else {
    if (state) {
      ContactronLed.off();
      _state = CONTACTRON_CLOSED;
    } else {
      ContactronLed.on();
      _state = CONTACTRON_OPEN;
    }
  }
}

byte AFEContactron::get() { return _state; }

const char *AFEContactron::getName() { return ContactronConfiguration.name; }

const char *AFEContactron::getMQTTTopic() {
{'fraction_non_alphanumeric': 0.12227805695142378, 'fraction_numerical': 0.002680067001675042, 'mean_word_length': 4.2020905923344944, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '914837', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1018, 'n_words': 165}