Bonjour, j’ai installé le code de mon électrolyseur ePool pour récupérer les données, au début tout va bien et au bout de 5min, perte de connexion. J’ai essayé plein de trucs mais rien ne fonctionne:
- esp à 4m de la borne wifi
- ip fixe
- allumage extinction pour réactiver « 5 minutes » l’ESP mais après ça se coupe
Si je lance le log pendant le blocage, j’ai ça
INFO ESPHome 2024.4.2
INFO Reading configuration /config/esphome/justsalt.yaml...
INFO Detected timezone 'Europe/Paris'
INFO Starting log output from 192.168.1.240 using esphome API
WARNING Can't connect to ESPHome API for justsalt @ 192.168.1.240: Timeout while connecting to [AddrInfo(family=<AddressFamily.AF_INET: 2>, type=<SocketKind.SOCK_STREAM: 1>, proto=6, sockaddr=IPv4Sockaddr(address='192.168.1.240', port=6053))] (TimeoutAPIError)
INFO Trying to connect to justsalt @ 192.168.1.240 in the background``
voici le code de mon ESP
# JustSalt
substitutions:
mac_justsalt: "F4:B3:B1:0B:CA:18"
service_uuid: '09912756-7b32-4629-aeb1-b309d9a338ae'
characteristic_uuid: 'ef785c24-22bb-463d-b651-0b7445ba091c'
characteristic_uuid_write: '4d32c5e5-2bb5-45c6-8c89-6f59bb3930d2'
esphome:
name: justsalt
friendly_name: justsalt
esp32:
board: esp32dev
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
ota:
password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "xxxxxxxxxxxxxxt"
password: "xxxxxxxxxxxx"
captive_portal:
bluetooth_proxy:
active: true
time:
- platform: homeassistant
id: homeassistant_time
on_time:
- seconds: 0
minutes: /5
then:
- switch.turn_off: ble_switch_com
- delay: 20s
- switch.turn_on: ble_switch_com
esp32_ble_tracker:
on_ble_advertise:
- mac_address:
- ${mac_justsalt}
then:
- lambda: |-
//ESP_LOGD("ble_adv", "New BLE device");
//ESP_LOGD("ble_adv", " address: %s", x.address_str().c_str());
//ESP_LOGD("ble_adv", " name: %s", x.get_name().c_str());
id(ble_name2).publish_state(x.get_name().c_str());
ble_client:
- mac_address: ${mac_justsalt}
auto_connect: true
id: JustSaltPro
on_connect:
then:
- ble_client.numeric_comparison_reply:
id: JustSaltPro
accept: True
binary_sensor:
- platform: ble_presence
mac_address: ${mac_justsalt}
name: Electolyseur
text_sensor:
- platform: version
name: ESPHome Version
- platform: wifi_info
ssid:
name: WiFi
# - id: ble_name
# name: "Name BLE"
# platform: template
- id: ble_name2
name: "Name"
platform: template
- id: version_logiciel
name: "version logiciel"
platform: template
- id: slave
name: "Slave"
platform: template
- id: idcode
name: "ID Code"
platform: template
- platform: template
name: "MAC bt"
id: JustSalt_macbt_textsensor
- platform: template
name: "nom bt"
id: JustSalt_nombt_textsensor
- platform: template
name: "SN"
id: JustSalt_sn_textsensor
- platform: template
name: "temp9D"
id: JustSalt_9d_textsensor
- platform: template
name: "tempE1"
id: JustSalt_e1_textsensor
- platform: template
name: "tempA3"
id: JustSalt_a3_textsensor
select:
- platform: template
name: Selection concigne PH
id: JustSalt_ph_consigne_select
icon: mdi:ph
options:
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "7.5"
- "7.6"
- "7.7"
- "7.8"
- "7.9"
restore_value: True
optimistic: true
on_value:
then:
- lambda: !lambda |-
auto state = id(JustSalt_ph_consigne_select).state.c_str();
float statefloat = std::stof(id(JustSalt_ph_consigne_select).state);
uint8_t statehex = statefloat *10;
//if (statehex != id(JustSalt_ph_consigne_sensor)){
ESP_LOGD("select_ph", "Option of my select: %s", state);
id(phwrite).turn_on();
//}
sensor:
- platform: wifi_signal
name: Wifi signal
update_interval: 60s
- platform: uptime
name: Uptime
- platform: template
name: "temp02"
id: JustSalt_temp02_sensor
- platform: template
name: "temp03"
id: JustSalt_temp03_sensor
- platform: template
name: "temp08"
id: JustSalt_temp08_sensor
- platform: template
name: "temp0B"
id: JustSalt_temp0b_sensor
- platform: template
name: "temp0C"
id: JustSalt_temp0c_sensor
- platform: template
name: "temp0D"
id: JustSalt_temp0d_sensor
- platform: template
name: "temp0e"
id: JustSalt_temp0e_sensor
- platform: template
name: "minutes de fonctionement"
id: JustSalt_temp0f_sensor
unit_of_measurement: "min"
accuracy_decimals: 0
- platform: template
name: "temp10"
id: JustSalt_temp10_sensor
- platform: template
name: "temp11"
id: JustSalt_temp11_sensor
- platform: template
name: "temp12"
id: JustSalt_temp12_sensor
- platform: template
name: "temp13"
id: JustSalt_temp13_sensor
- platform: template
name: "temp1f"
id: JustSalt_temp1f_sensor
- platform: template
name: "temp28"
id: JustSalt_temp28_sensor
- platform: template
name: "temp29"
id: JustSalt_temp29_sensor
- platform: template
name: "temp2A"
id: JustSalt_temp2a_sensor
- platform: template
name: "temp31"
id: JustSalt_temp31_sensor
- platform: template
name: "temp50"
id: JustSalt_temp50_sensor
- platform: template
name: "temp51"
id: JustSalt_temp51_sensor
- platform: template
name: "temp5F"
id: JustSalt_temp5f_sensor
- platform: template
name: "temp69"
id: JustSalt_temp69_sensor
- platform: template
name: "temp6A"
id: JustSalt_temp6a_sensor
- platform: template
name: "temp8F"
id: JustSalt_temp8f_sensor
- platform: template
name: "temp92"
id: JustSalt_temp92_sensor
- platform: template
name: "temp93"
id: JustSalt_temp93_sensor
- platform: template
name: "temp94"
id: JustSalt_temp94_sensor
- platform: template
name: "temp9B"
id: JustSalt_temp9b_sensor
- platform: template
name: "temp9C"
id: JustSalt_temp9c_sensor
- platform: template
name: "temp9D"
id: JustSalt_temp9d_sensor
- platform: template
name: "tempB0"
id: JustSalt_tempb0_sensor
- platform: template
name: "tempD1"
id: JustSalt_tempd1_sensor
- platform: template
name: "tempFE"
id: JustSalt_tempfe_sensor
- platform: ble_rssi
mac_address: ${mac_justsalt}
name: "JustSalt RSSI"
- platform: template
name: "volume piscine"
id: JustSalt_volume_sensor
unit_of_measurement: "m3"
- platform: template
name: "Alarme ORP"
id: JustSalt_Alarmeorp_sensor
unit_of_measurement: "h"
- platform: template
name: "inversion"
id: JustSalt_inversion_sensor
unit_of_measurement: "h"
- platform: template
name: "Temperature eau"
id: JustSalt_temperature_sensor
unit_of_measurement: "°C"
accuracy_decimals: 1
state_class: measurement
device_class: temperature
- platform: template
name: "Temperature Int"
id: JustSalt_temperature_int_sensor
unit_of_measurement: "°C"
accuracy_decimals: 1
state_class: measurement
device_class: temperature
- platform: template
name: "pH"
id: JustSalt_ph_sensor
unit_of_measurement: "pH"
accuracy_decimals: 1
state_class: measurement
icon: mdi:ph
- platform: template
name: "pH consigne"
id: JustSalt_ph_consigne_sensor
unit_of_measurement: "pH"
accuracy_decimals: 1
state_class: measurement
icon: mdi:ph
- platform: template
name: "ORP"
id: JustSalt_orp_sensor
unit_of_measurement: "mV"
accuracy_decimals: 0
state_class: measurement
device_class: voltage
- platform: template
name: "ORP consigne"
id: JustSalt_orp_consigne_sensor
unit_of_measurement: "mV"
accuracy_decimals: 0
state_class: measurement
device_class: voltage
- platform: template
name: "TDS"
id: JustSalt_tds_sensor
unit_of_measurement: "g/L"
accuracy_decimals: 1
state_class: measurement
icon: mdi:water-opacity
- platform: template
name: "taux acide"
id: JustSalt_acide_sensor
unit_of_measurement: "%"
accuracy_decimals: 0
state_class: measurement
icon: mdi:Skull-Crossbones
- platform: template
name: "production"
id: JustSalt_production_sensor
unit_of_measurement: "%"
accuracy_decimals: 0
state_class: measurement
icon: mdi:Cog-Outline
# - platform: ble_client
# ble_client_id: JustSaltPro
# id: device_name
# service_uuid: '1800' # Generic Access Profile
# characteristic_uuid: '2a00' # Device Name
# type: characteristic
# lambda: |-
# std::string data_string(x.begin(), x.end());
# id(ble_name).publish_state(data_string.c_str());
# return (float)x.size();
- platform: ble_client
ble_client_id: JustSaltPro
name: "traitement"
id: sensor_state
service_uuid: ${service_uuid} #'09912756-7b32-4629-aeb1-b309d9a338ae'
characteristic_uuid: ${characteristic_uuid} #'ef785c24-22bb-463d-b651-0b7445ba091c'
type: characteristic
update_interval: 60s
notify: true
lambda: |-
//ESP_LOGD("ble_client.receive", "start - value received with %d bytes: [%.*s]", x.size(), x.size(), &x[0]);
std::string value2(x.begin(), x.end());
std::string rawhex = format_hex_pretty((uint8_t *) value2.c_str(), value2.size()).c_str();
ESP_LOGD("raw_hex", "%s", rawhex.c_str());
rawhex.erase(std::remove(rawhex.begin(), rawhex.end(), '.'), rawhex.end());
//ESP_LOGD("raw_hex_stripped", "value received with %d bytes: [%.*s]", rawhex.size(), rawhex.c_str());
int index = 3;
while (index +2 < x.size()) {
uint8_t idvaleur = x[index];
int taillevaleur = x[index + 1 ];
//ESP_LOGD("raw_hex_boucle", "idvaleur %d", idvaleur);
//ESP_LOGD("raw_hex_boucle", "taillevaleur %d", taillevaleur);
// std::string rawvaleur = value2.substr(index + 2, taillevaleur );
//ESP_LOGD("raw_hex_boucle", "value received with %d bytes: [%.*s]", rawvaleur.size(), rawvaleur.c_str());
//ESP_LOGD("raw_hex_boucle", "%s", rawvaleur.c_str());
switch (idvaleur) {
case 0x00: {
}break;
case 0x01: {
uint8_t phhex = x[index + 2];
float ph = static_cast<float>(phhex)/10;
id(JustSalt_ph_sensor).publish_state(ph);
}break;
case 0x02: {
uint8_t temphex = ((x[index + 2]<< 8) + (x[index +3]));
float temp = static_cast<float>(temphex);
id(JustSalt_temp02_sensor).publish_state(temp);
}break;
case 0x03: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_temp03_sensor).publish_state(temp);
}break;
case 0x06: {
uint16_t orphex = ((x[index + 2]<< 8) + (x[index +3]));
float orp = static_cast<float>(orphex);
id(JustSalt_orp_sensor).publish_state(orp);
}break;
case 0x08: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_temp08_sensor).publish_state(temp);
}break;
case 0x09: {
uint16_t tempeauhex = ((x[index + 2]<< 8) + (x[index +3]));
float tempeau = static_cast<float>(tempeauhex)/10;
id(JustSalt_temperature_sensor).publish_state(tempeau);
}break;
case 0x0A: {
uint8_t selhex = x[index + 2] ;
float sel = static_cast<float>(selhex)/10;
id(JustSalt_tds_sensor).publish_state(sel);
}break;
case 0x0B: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_temp0b_sensor).publish_state(temp);
}break;
case 0x0C: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_temp0c_sensor).publish_state(temp);
}break;
case 0x0D: {
uint8_t temphex = ((x[index + 2]<< 8) + (x[index +3]));
float temp = static_cast<float>(temphex);
id(JustSalt_temp0d_sensor).publish_state(temp);
}break;
case 0x0E: {
uint8_t temphex = ((x[index + 2]<< 8) + (x[index +3]));
float temp = static_cast<float>(temphex);
id(JustSalt_temp0e_sensor).publish_state(temp);
}break;
case 0x0F: {
uint8_t temphex = ((x[index + 2]<< 8) + (x[index +3]));
float temp = static_cast<float>(temphex);
id(JustSalt_temp0f_sensor).publish_state(temp);
}break;
case 0x10: {
uint8_t temphex = ((x[index + 2]<< 8) + (x[index +3]));
float temp = static_cast<float>(temphex);
id(JustSalt_temp10_sensor).publish_state(temp);
}break;
case 0x11: {
uint16_t volhex = ((x[index + 2]<< 8) + (x[index +3]));
float vol = static_cast<float>(volhex);
id(JustSalt_volume_sensor).publish_state(vol);
}break;
case 0x12: {
uint32_t temphex = (x[index + 2]<< 24) + (x[index + 3]<< 16)+ (x[index + 4]<< 8) + (x[index +5]);
float temp = static_cast<float>(temphex);
id(JustSalt_temp12_sensor).publish_state(temp);
}break;
case 0x13: {
uint32_t temphex = (x[index + 2]<< 24) + (x[index + 3]<< 16)+ (x[index + 4]<< 8) + (x[index +5]);
float temp = static_cast<float>(temphex);
//std::string tempstr = value_accuracy_to_string (temp,0);
id(JustSalt_temp13_sensor).publish_state(temp);
}break;
case 0x1F: {
uint8_t temphex = ((x[index + 2]<< 8) + (x[index +3]));
float temp = static_cast<float>(temphex);
id(JustSalt_temp1f_sensor).publish_state(temp);
}break;
case 0x28: {
uint8_t temphex = ((x[index + 2]<< 8) + (x[index +3]));
float temp = static_cast<float>(temphex);
id(JustSalt_temp28_sensor).publish_state(temp);
}break;
case 0x29: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_temp29_sensor).publish_state(temp);
}break;
case 0x2A: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_temp2a_sensor).publish_state(temp);
}break;
case 0x30: {
uint8_t phchex = x[index + 2] ;
float phc = static_cast<float>(phchex)/10;
auto phcstr = value_accuracy_to_string (phc,1);
id(JustSalt_ph_consigne_sensor).publish_state(phc);
id(JustSalt_ph_consigne_select).publish_state(phcstr);
}break;
case 0x31: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_temp31_sensor).publish_state(temp);
}break;
case 0x32: {
uint8_t acidehex = x[index + 2] ;
float acide = static_cast<float>(acidehex);
id(JustSalt_acide_sensor).publish_state(acide);
}break;
case 0x33: {
uint8_t prodhex = x[index + 2] ;
float prod = static_cast<float>(prodhex);
id(JustSalt_production_sensor).publish_state(prod);
}break;
case 0x35: {
uint8_t orpchex = x[index + 2] ;
float orpc = static_cast<float>(orpchex)*10;
id(JustSalt_orp_consigne_sensor).publish_state(orpc);
}break;
case 0x37: {
uint8_t alarmeorphex = x[index + 2] ;
float alarmeorp = static_cast<float>(alarmeorphex);
id(JustSalt_Alarmeorp_sensor).publish_state(alarmeorp);
}break;
case 0x39: {
uint8_t inversionhex = x[index + 2] ;
float inversionval = static_cast<float>(inversionhex);
id(JustSalt_inversion_sensor).publish_state(inversionval);
}break;
case 0x50: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_temp50_sensor).publish_state(temp);
}break;
case 0x51: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_temp51_sensor).publish_state(temp);
}break;
case 0x5F: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_temp5f_sensor).publish_state(temp);
}break;
case 0x69: {
uint32_t temphex = (x[index + 2]<< 24) + (x[index + 3]<< 16)+ (x[index + 4]<< 8) + (x[index +5]);
float temp = static_cast<float>(temphex);
id(JustSalt_temp69_sensor).publish_state(temp);
}break;
case 0x6A: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_temp6a_sensor).publish_state(temp);
}break;
case 0x8F: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_temp8f_sensor).publish_state(temp);
}break;
case 0x92: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_temp92_sensor).publish_state(temp);
}break;
case 0x93: {
uint8_t temphex = ((x[index + 2]<< 8) + (x[index +3]));
float temp = static_cast<float>(temphex);
id(JustSalt_temp93_sensor).publish_state(temp);
}break;
case 0x94: {
uint8_t temphex = ((x[index + 2]<< 8) + (x[index +3]));
float temp = static_cast<float>(temphex);
id(JustSalt_temp94_sensor).publish_state(temp);
}break;
case 0x95: {
uint32_t idcodehex = (x[index + 2]<< 24) + (x[index + 3]<< 16)+ (x[index + 4]<< 8) + (x[index +5]);
float idcodefloat = static_cast<float>(idcodehex);
std::string idcodestr = value_accuracy_to_string (idcodefloat,0);
id(idcode).publish_state(idcodestr);
}break;
case 0x96: {
std::string verlog = rawhex.substr((index + 2 )* 2, 4);
id(version_logiciel).publish_state(verlog);
}break;
case 0x97: {
std::string slaveval = rawhex.substr((index + 2 )* 2, 4);
id(slave).publish_state(slaveval);
}break;
case 0x99: {
//99.16.47.45.4E.5F.30.35.32.32.2D.30.34.33.39.35.33.2D.30.30.33.00.00.00.
std::string tempstring = value2.substr((index + 2 ), taillevaleur);
id(JustSalt_nombt_textsensor).publish_state(tempstring.c_str());
}break;
case 0x9A: {
//9A.10.30.35.32.32.2D.30.34.33.39.35.33.2D.30.30.33.00.
std::string tempstring = value2.substr((index + 2 ), taillevaleur);
id(JustSalt_sn_textsensor).publish_state(tempstring.c_str());
}break;
case 0x9B: {
uint8_t temphex = ((x[index + 2]<< 8) + (x[index +3]));
float temp = static_cast<float>(temphex);
id(JustSalt_temp9b_sensor).publish_state(temp);
}break;
case 0x9C: {
uint8_t temphex = ((x[index + 2]<< 8) + (x[index +3]));
float temp = static_cast<float>(temphex);
id(JustSalt_temp9c_sensor).publish_state(temp);
}break;
case 0x9D: {
// 9D.08.00.00.00.00.00.00.01.FF
std::string tempstring = rawhex.substr((index + 2 )* 2, 8);
id(JustSalt_9d_textsensor).publish_state(tempstring);
}break;
case 0xA3: {
// E1.0F.18.04.11.11.00.33.00.00.88.00.F8.00.00.00.00
std::string tempstring = rawhex.substr((index + 2 )* 2, 15);
id(JustSalt_a3_textsensor).publish_state(tempstring);
}break;
case 0xB0: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_tempb0_sensor).publish_state(temp);
}break;
case 0xB1: {
std::string tempstring = rawhex.substr((index + 2 )* 2, 12);
id(JustSalt_macbt_textsensor).publish_state(tempstring);
}break;
case 0xD1: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_tempd1_sensor).publish_state(temp);
}break;
case 0xFE: {
uint8_t temphex = x[index + 2];
float temp = static_cast<float>(temphex);
id(JustSalt_tempfe_sensor).publish_state(temp);
}break;
case 0xE1: {
// E1.0F.18.04.11.11.00.33.00.00.88.00.F8.00.00.00.00
std::string tempstring = rawhex.substr((index + 2 )* 2, 30);
id(JustSalt_e1_textsensor).publish_state(tempstring);
}break;
default: {
ESP_LOGW("raw_hex_boucle", "idvaleur Non implementee %d", idvaleur);
};
}
index = index + 2 + taillevaleur ;
}
return 1;
switch:
- platform: restart
name: JustSalt_Gatway restart
- platform: ble_client
id: ble_switch_com
ble_client_id: JustSaltPro
name: "Enable com JustSalt"
- platform: template
name: "PH write"
id: phwrite
turn_on_action:
- ble_client.ble_write:
id: JustSaltPro
service_uuid: ${service_uuid}
characteristic_uuid: ${characteristic_uuid_write}
value: !lambda |-
float state = std::stof(id(JustSalt_ph_consigne_select).state);
ESP_LOGI("Switch_ph_consigne", "Option of my select: %d", state);
uint8_t statehex = state * 10;
return {0x00, 0x06, 0x03, 0x30, 0x01, statehex, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Je ne comprends pas pourquoi je n’arrive pas garder la connexion plus de 5 min, merci de toute aide
