// Byte [00:01] : State of Charge (SOC) (1 %)
// Byte [02:03] : State of Health (SOH) (1 %)
// Byte [04:05] : SOC high resolution (0.01 %)
// Byte [06:07] : Remaining total capacity (1 Ah) (Sofar)
uint8_t can_mesg[8];
uint16_t soc;
uint16_t soh;
// SOC - Sending 100% only at the end of the absorption phase
if (id(state_of_charge).state < 100) soc = id(state_of_charge).state; // SOC < 100% => Sending BMS SOC
else if (id(eoc) == true) soc = 100; // End Of Charge => Sending 100%
else soc = 99; // Otherwise => Sending 99%
// SOH
soh = round(((id(charging_cycles).state/${max_cycles})-1)*-100);
can_mesg[0] = soc & 0xff;
can_mesg[1] = soc >> 8 & 0xff;
can_mesg[2] = soh & 0xff;
can_mesg[3] = soh >> 8 & 0xff;
can_mesg[4] = (soc * 100) & 0xff;
can_mesg[5] = (soc * 100) >> 8 & 0xff;
can_mesg[6] = uint16_t(id(capacity_remaining_ah).state * 10) & 0xff;
can_mesg[7] = uint16_t(id(capacity_remaining_ah).state * 10) >> 8 & 0xff;
ESP_LOGI("main", "send can id: 0x355 hex: %x %x %x %x %x %x %x %x", can_mesg[0], can_mesg[1], can_mesg[2], can_mesg[3], can_mesg[4], can_mesg[5], can_mesg[6], can_mesg[7]);
return {can_mesg[0], can_mesg[1], can_mesg[2], can_mesg[3], can_mesg[4], can_mesg[5], can_mesg[6], can_mesg[7]};