DomiStyle / esphome-panasonic-ac

Open source alternative for Panasonic air condition wifi adapters that works locally without the Comfort Cloud
MIT License
226 stars 58 forks source link

Mild Dry Switch keeps getting off #89

Open michas79de opened 1 year ago

michas79de commented 1 year ago

Hello! great job @DomiStyle so far! I really appreciate being freed from the cloud! 👍

While my remote control has a MILD DRY button, the same button in the Home Assistant cannot be switched on permanently, but is immediately switched off again every time I try.

When using the remote control, the log shows that the 14th RX byte switches 2D (off) <-> 2B (on), I think:

[22:32:31][V][panasonic_ac.cz_tacg1:248]: Polling AC [22:32:31][V][panasonic_ac:245]: TX: 70.0A.00.00.00.00.00.00.00.00.00.00.86 (13) [22:32:31][V][panasonic_ac:247]: RX: 70.20.34.2B.80.A0.5A.00.00.00.00.00.30.2B.00.00.20.97.80.80.FF.12.06.FF.80.80.FF.80.18.00.01.00.00.00.D7 (35) [22:32:31][D][climate:392]: 'Panasonic AC' - Sending state: [22:32:31][D][climate:395]: Mode: COOL [22:32:31][D][climate:403]: Custom Fan Mode: Automatic [22:32:31][D][climate:409]: Custom Preset: Normal [22:32:31][D][climate:412]: Swing Mode: OFF [22:32:31][D][climate:415]: Current Temperature: 18.00°C [22:32:31][D][climate:421]: Target Temperature: 21.50°C [22:32:31][V][component:204]: Component panasonic_ac.climate took a long time for an operation (0.05 s). [22:32:31][V][component:205]: Components should block for at most 20-30ms. [22:32:36][V][panasonic_ac.cz_tacg1:248]: Polling AC [22:32:36][V][panasonic_ac:245]: TX: 70.0A.00.00.00.00.00.00.00.00.00.00.86 (13) [22:32:36][V][panasonic_ac:247]: RX: 70.20.34.2B.80.A0.5A.00.00.00.00.00.30.2D.00.00.20.97.80.80.FF.12.06.FF.80.80.FF.80.18.00.01.00.00.00.D5 (35) [22:32:36][D][climate:392]: 'Panasonic AC' - Sending state: [22:32:36][D][climate:395]: Mode: COOL [22:32:36][D][climate:403]: Custom Fan Mode: Automatic [22:32:36][D][climate:409]: Custom Preset: Normal [22:32:36][D][climate:412]: Swing Mode: OFF [22:32:36][D][climate:415]: Current Temperature: 18.00°C [22:32:36][D][climate:421]: Target Temperature: 21.50°C [22:32:36][V][component:204]: Component panasonic_ac.climate took a long time for an operation (0.05 s). [22:32:36][V][component:205]: Components should block for at most 20-30ms. [22:32:41][V][panasonic_ac.cz_tacg1:248]: Polling AC [22:32:41][V][panasonic_ac:245]: TX: 70.0A.00.00.00.00.00.00.00.00.00.00.86 (13) [22:32:41][V][panasonic_ac:247]: RX: 70.20.34.2B.80.A0.5A.00.00.00.00.00.30.2B.00.00.20.97.80.80.FF.12.06.FF.80.80.FF.80.18.00.01.00.00.00.D7 (35) [22:32:41][D][climate:392]: 'Panasonic AC' - Sending state: [22:32:41][D][climate:395]: Mode: COOL [22:32:41][D][climate:403]: Custom Fan Mode: Automatic [22:32:41][D][climate:409]: Custom Preset: Normal [22:32:41][D][climate:412]: Swing Mode: OFF [22:32:41][D][climate:415]: Current Temperature: 18.00°C [22:32:41][D][climate:421]: Target Temperature: 21.50°C [22:32:41][V][component:204]: Component panasonic_ac.climate took a long time for an operation (0.05 s). [22:32:41][V][component:205]: Components should block for at most 20-30ms. [22:32:46][V][panasonic_ac.cz_tacg1:248]: Polling AC [22:32:46][V][panasonic_ac:245]: TX: 70.0A.00.00.00.00.00.00.00.00.00.00.86 (13) [22:32:46][V][panasonic_ac:247]: RX: 70.20.34.2B.80.A0.5A.00.00.00.00.00.30.2D.00.00.20.97.80.80.FF.12.06.FF.80.80.FF.80.18.00.01.00.00.00.D5 (35) [22:32:46][D][climate:392]: 'Panasonic AC' - Sending state: [22:32:46][D][climate:395]: Mode: COOL [22:32:46][D][climate:403]: Custom Fan Mode: Automatic [22:32:46][D][climate:409]: Custom Preset: Normal [22:32:46][D][climate:412]: Swing Mode: OFF [22:32:46][D][climate:415]: Current Temperature: 18.00°C [22:32:46][D][climate:421]: Target Temperature: 21.50°C [22:32:51][V][panasonic_ac.cz_tacg1:248]: Polling AC [22:32:51][V][panasonic_ac:245]: TX: 70.0A.00.00.00.00.00.00.00.00.00.00.86 (13) [22:32:51][V][panasonic_ac:247]: RX: 70.20.34.2B.80.A0.5A.00.00.00.00.00.30.2B.00.00.20.97.80.80.FF.12.06.FF.80.80.FF.80.18.00.01.00.00.00.D7 (35) [22:32:51][D][climate:392]: 'Panasonic AC' - Sending state: [22:32:51][D][climate:395]: Mode: COOL [22:32:51][D][climate:403]: Custom Fan Mode: Automatic [22:32:51][D][climate:409]: Custom Preset: Normal [22:32:51][D][climate:412]: Swing Mode: OFF [22:32:51][D][climate:415]: Current Temperature: 18.00°C [22:32:51][D][climate:421]: Target Temperature: 21.50°C [22:32:51][V][component:204]: Component panasonic_ac.climate took a long time for an operation (0.05 s). [22:32:51][V][component:205]: Components should block for at most 20-30ms. [22:32:56][V][panasonic_ac.cz_tacg1:248]: Polling AC [22:32:56][V][panasonic_ac:245]: TX: 70.0A.00.00.00.00.00.00.00.00.00.00.86 (13) [22:32:56][V][panasonic_ac:247]: RX: 70.20.34.2B.80.A0.5A.00.00.00.00.00.30.2D.00.00.20.97.80.80.FF.12.06.FF.80.80.FF.80.18.00.01.00.00.00.D5 (35) [22:32:56][D][climate:392]: 'Panasonic AC' - Sending state: [22:32:56][D][climate:395]: Mode: COOL [22:32:56][D][climate:403]: Custom Fan Mode: Automatic [22:32:56][D][climate:409]: Custom Preset: Normal [22:32:56][D][climate:412]: Swing Mode: OFF [22:32:56][D][climate:415]: Current Temperature: 18.00°C [22:32:56][D][climate:421]: Target Temperature: 21.50°C [22:32:56][V][component:204]: Component panasonic_ac.climate took a long time for an operation (0.05 s). [22:32:56][V][component:205]: Components should block for at most 20-30ms.

DomiStyle commented 1 year ago

That's strange, byte 14 is actually used for eco mode on my unit and byte 5 is used for mild dry. Not sure how to combine those 2 different behaviors.

You can check out the current protocol documentation here: https://github.com/DomiStyle/esphome-panasonic-ac/tree/master/protocol/cztacg1

michas79de commented 1 year ago

Here it seems to be free and shows 2D, which seems to be 'Mild Dry off' for me: grafik I would suggest switching both bytes, but I don't know what byte 5 will trigger at my A/C and 14 at other A/Cs. (Switching on the Mild Dry Button in Home Assistant won't do anything for me, it seems. The switch switches immediately back to off and the log always show "80".) I don't have any further suggestion or proposal at the moment.

michas79de commented 1 year ago

@DomiStyle I want to try this other byte for Mild Dry myself. So I made a fork (https://github.com/michas79de/esphome-panasonic-ac). I am not a programmer. So I am not sure what I am doing. But I hope I'm doing it right.

I think I found the values in esppac_cnt.cpp and changed them. But I can't find where to change the byte. Can you please guide me?

DomiStyle commented 1 year ago

You can manipulate any value in the packet being sent by accessing this->cmd[X] where X is the index you want to access excluding the header and packet length. Any data that was received is inside of this->data instead.

For example, mild dry (ID 4 in the table above) would be this->cmd[2]. If you want to change field 13 you can access it with this->cmd[11].

As for reading, the values get passed to their own determine_xyz(uint8_t value) functions that evaluates the values.

For example:

bool PanasonicACCNT::determine_alternative_mild_dry(uint8_t value) {
  if (value == 0x2B)
    return true;
  else if (value == 0x2D)
    return false;
  else {
    ESP_LOGW(TAG, "Received unknown alternative mild dry value");
    return false;
  }
}

You will then want to call that function in set_data:

bool alternativeMildDry = determine_alternative_mild_dry(this->data[11]);
michas79de commented 1 year ago

Thank you! I duplicated each snippet with "mild dry" to "alternative mild dry" and changed the bytes. However, I noticed that the byte that changes between two values every time I use the remote control seems to be overlaid with additional data. This is because it alternates between 2B and 2D, 32 and 30, 30 and 2E and maybe more. Could be some work...

Anyway: When I try to use 0x32 and 0x30, I get a warning that the value is 86 instead of 30:

[18:29:39][V][panasonic_ac.cz_tacg1:254]: Polling AC [18:29:39][V][panasonic_ac:259]: TX: 70.0A.00.00.00.00.00.00.00.00.00.00.86 (13) [18:29:39][V][panasonic_ac:261]: RX: 70.20.34.30.80.A0.16.00.00.00.00.00.30.30.00.00.20.97.80.80.FF.17.1E.FF.80.80.FF.80.38.00.02.00.00.00.D3 (35) [18:29:39][W][panasonic_ac.cz_tacg1:488]: Received unknown alternative mild dry value: 86

while using this code: bool alternativeMildDry = determine_alternative_mild_dry(this->data[11]); and bool PanasonicACCNT::determine_alternative_mild_dry(uint8_t value) { if (value == 0x30) return true; else if (value == 0x32) return false; else { ESP_LOGW(TAG, "Received unknown alternative mild dry value: %d", value);

You might want to check my changes at https://github.com/DomiStyle/esphome-panasonic-ac/compare/master...michas79de:esphome-panasonic-ac:master. So that I use a correct code, when I continue with it.