Skip to content

Commit

Permalink
Merge pull request #3 from InnoGreenTech/triphase_historique
Browse files Browse the repository at this point in the history
base triphase historique
  • Loading branch information
hekmon authored Dec 6, 2022
2 parents 14738a0 + 3d9e3c8 commit e9961f7
Show file tree
Hide file tree
Showing 3 changed files with 194 additions and 2 deletions.
69 changes: 69 additions & 0 deletions res/Simulateur_linky/Simulateur_linky.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
int i=0;


void setup() {
Serial.begin(1200,SERIAL_7E1);
//Serial.begin(9600);

}

void loop() {


if (i==20){

Serial.print(trame_historique("ADCO", "123456789012"));
delay(13);
Serial.print(trame_historique("OPTARIF", "BASE"));
delay(13);
Serial.print(trame_historique("ISOUSC", "60"));
delay(13);
Serial.print(trame_historique("BASE", "000015000"));
delay(13);
Serial.print(trame_historique("PETC", "TH12"));
delay(13);
Serial.print(trame_historique("IINST1", "012"));
delay(13);
Serial.print(trame_historique("IINST2", "014"));
delay(13);
Serial.print(trame_historique("IINST3", "013"));
delay(13);
Serial.print(trame_historique("IMAX1", "060"));
delay(13);
Serial.print(trame_historique("IMAX2", "060"));
delay(13);
Serial.print(trame_historique("IMAX3", "060"));
delay(13);
Serial.print(trame_historique("PMAX", "09000"));
delay(13);
Serial.print(trame_historique("PAPP", "00700"));
delay(13);
Serial.print(trame_historique("HHPHC", "A"));
delay(13);
Serial.print(trame_historique("MOTDETAE", "000000"));
delay(13);
Serial.print(trame_historique("PPOT", "00"));
i=0;
}

delay(33);
Serial.print(trame_historique("ADIR1", "005"));
delay(13);
Serial.print(trame_historique("ADIR2", "003"));
delay(13);
Serial.print(trame_historique("ADIR3", "004"));
delay(13);
Serial.print(trame_historique("ADCO", "123456789012"));
delay(13);
Serial.print(trame_historique("IINST1", "034"));
delay(13);
Serial.print(trame_historique("IINST2", "028"));
delay(13);
Serial.print(trame_historique("IINST3", "053"));




delay(33);

}
27 changes: 27 additions & 0 deletions res/Simulateur_linky/TRAME_HISTORIQUE.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
String trame_historique(char *etiquette, char *donnee ){

String trame="";
String information="";


information = etiquette;
information += char(0x20);
information += donnee;


int lengh = information.length();

char checksum=0;
for (int i=0; i<lengh; i++)
{
checksum = checksum + char(information[i]);
}
checksum = (checksum & 0x3F) + 0x20;
trame=char(0x0A);
trame+=information;
trame+=char(0x20);
trame+=char(checksum);
trame+=char(0x0D);

return trame;
}
100 changes: 98 additions & 2 deletions sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,99 @@ async def async_setup_platform(
else:
# historic mode
if discovery_info[CONF_THREE_PHASE]:
_LOGGER.error(
"three-phase historic mode is not supported (yet ?): no entities will be spawned")
sensors = [
ADCOSensor(serial_reader),
RegularStrSensor(serial_reader,
"OPTARIF", "Option tarifaire choisie", "mdi:cash-check",
category=EntityCategory.CONFIG),
RegularIntSensor(serial_reader,
"ISOUSC", "Intensité souscrite",
category=EntityCategory.CONFIG,
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE),
EnergyIndexSensor(serial_reader,
"BASE", "Index option Base"),
EnergyIndexSensor(serial_reader,
"HCHC", "Index option Heures Creuses - Heures Creuses"),
EnergyIndexSensor(serial_reader,
"HCHP", "Index option Heures Creuses - Heures Pleines"),
EnergyIndexSensor(serial_reader,
"EJPHN", "Index option EJP - Heures Normales"),
EnergyIndexSensor(serial_reader,
"EJPHPM", "Index option EJP - Heures de Pointe Mobile"),
EnergyIndexSensor(serial_reader,
"BBRHCJB", "Index option Tempo - Heures Creuses Jours Bleus"),
EnergyIndexSensor(serial_reader,
"BBRHPJB", "Index option Tempo - Heures Pleines Jours Bleus"),
EnergyIndexSensor(serial_reader,
"BBRHCJW", "Index option Tempo - Heures Creuses Jours Blancs"),
EnergyIndexSensor(serial_reader,
"BBRHPJW", "Index option Tempo - Heures Pleines Jours Blancs"),
EnergyIndexSensor(serial_reader,
"BBRHCJR", "Index option Tempo - Heures Creuses Jours Rouges"),
EnergyIndexSensor(serial_reader,
"BBRHPJR", "Index option Tempo - Heures Pleines Jours Rouges"),
PEJPSensor(serial_reader),
RegularStrSensor(serial_reader,
"PTEC", "Période Tarifaire en cours", "mdi:calendar-expand-horizontal"),
RegularStrSensor(serial_reader,
"DEMAIN", "Couleur du lendemain", "mdi:palette"),
RegularStrSensor(serial_reader,
"PPOT", "Présence Phase"),
RegularIntSensor(serial_reader,
"IINST1", "Intensité Instantanée 1",
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
state_class=SensorStateClass.MEASUREMENT),
RegularIntSensor(serial_reader,
"IINST2", "Intensité Instantanée 2",
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
state_class=SensorStateClass.MEASUREMENT),
RegularIntSensor(serial_reader,
"IINST3", "Intensité Instantanée 3",
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
state_class=SensorStateClass.MEASUREMENT),
RegularIntSensor(serial_reader,
"IMAX1", "Intensité maximale appelée 1",
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE),
RegularIntSensor(serial_reader,
"IMAX2", "Intensité maximale appelée 2",
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE),
RegularIntSensor(serial_reader,
"IMAX3", "Intensité maximale appelée 3",
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE),
RegularIntSensor(serial_reader,
"PAPP", "Puissance apparente",
device_class=SensorDeviceClass.APPARENT_POWER,
native_unit_of_measurement=POWER_VOLT_AMPERE,
state_class=SensorStateClass.MEASUREMENT),
RegularStrSensor(serial_reader,
"HHPHC", "Horaire Heures Pleines Heures Creuses", "mdi:clock-outline",
enabled_by_default=False),
RegularStrSensor(serial_reader,
"MOTDETAT", "Mot d'état du compteur", "mdi:file-word-box-outline",
category=EntityCategory.DIAGNOSTIC,
enabled_by_default=False),
RegularIntSensor(serial_reader,
"ADIR1", "Intensité de dépassement phase 1",
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE),
RegularIntSensor(serial_reader,
"ADIR2", "Intensité de dépassement phase 2",
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE),
RegularIntSensor(serial_reader,
"ADIR3", "Intensité de dépassement phase 3",
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE),
]
_LOGGER.info(
"adding %d sensors for the three phase historic mode", len(sensors))
else:
# single phase
sensors = [
Expand Down Expand Up @@ -113,6 +204,11 @@ async def async_setup_platform(
"IMAX", "Intensité maximale appelée",
device_class=SensorDeviceClass.CURRENT,
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE),
RegularIntSensor(serial_reader,
"PMAX", "Puissance maximale",
device_class=SensorDeviceClass.APPARENT_POWER,
native_unit_of_measurement=POWER_WATT,
state_class=SensorStateClass.MEASUREMENT),
RegularIntSensor(serial_reader,
"PAPP", "Puissance apparente",
device_class=SensorDeviceClass.APPARENT_POWER,
Expand Down

0 comments on commit e9961f7

Please sign in to comment.