revk / ESP32-Faikin

ESP32 based module to control Daikin aircon units
GNU General Public License v3.0
448 stars 66 forks source link

[BUG] - Home Assistant native Daikin integration - Fan Mode and Preset errors #348

Closed Nick-Sills closed 5 months ago

Nick-Sills commented 5 months ago

Faikin hardware Amazon purchased, 04/24. Faikin-S3-MINI-N4-R2: b1a9db5 2024-06-03T08:35:42

Daikin hardware Daikin FTXM42R Daikin FTXM20R

Connect to Faikin using EKRS21 Wiring Harness + Dupont cables

Describe the bug

@revk Sorry for being such a PITA with so many problems in succession. I was trying the native Daikin integration while debugging the MQTT routing. The native integration is very good, and manages to update the entity icon colours correctly to reflect the HVAC state. I'd like to use both MQTT and Native for a while.

Changing the target temperature causes a 'Fan Mode' error.

https://github.com/revk/ESP32-Faikin/assets/162114112/4565a8d0-8c9e-4ba8-bea6-592711755fcd

Changing the Preset doesn't reflect in the UI after the change, and doesn't reliably change the Daikin AC preset.

https://github.com/revk/ESP32-Faikin/assets/162114112/ec09edd2-08f4-410c-883a-50d9bce14f6c

BTW: The MQTT climate entity has a preset of 'Home', but that doesn't exists for FTXM* units

To Reproduce See above

Thanks for reading!

revk commented 5 months ago

The legacy mode should work in the same way to be honest, but it was a bit of a bodge.

Not entirely clears which mode you are using to make the changes.

Can you get a dump of the MQTT or URL/GET it is doing for these?

Nick-Sills commented 5 months ago

MQTT is working fine for the fan and preset, the only glitch is that there's no 'Home' preset for FTXM* units. I.e, The climate entity has 'Home', but there's no such preset for the AC unit.

Those videos are of the 'Legacy' Daikin integration which has the bugs.

I'll try and get the URL's.

Nick-Sills commented 5 months ago

I'm not sure if this helps, but here's a .pcap of comms between 192.168.100.11 (the pi hosting HA), 192.168.100.165 (the Faikin board). It should cover the events in the first video, Fan.Mode.mp4.

Filter by: ip.addr == 192.168.100.165

I've renamed Faikin,pcap to Faikin.txt because I couldn't upload .pcap. Just rename it back.

Faikin.txt

Let me know if you need anything else.

revk commented 5 months ago

FYI the pcap shows getting info, then

GET /aircon/set_control_info?pow=0&mode=7&stemp=16&shum=0&f_rate=0&f_dir=0 HTTP/1.1

With response

ret=PARAM NG,adv=Invalid f_rate value

My notes suggest an f_rate of 3 to 7 or A or B are valid, not 0

Do you know what 0 is meant to mean?

Nick-Sills commented 5 months ago

That's odd, I don't think 0 is a real fan rate. The "Fan mode" selection works perfectly, it's only when the set temperature changes that it causes an error. That smells like an uninitialized variable in the Daikin integration being sent rather than the current fan rate. I also have another Daikin unit with a BRP069B4 local API module, and that's working fine.

revk commented 5 months ago

We ignore the 0 (apart from reporting an error) so it should be working anyway, and not even change fan rate.

Nick-Sills commented 5 months ago

It reports the error, then the fan mode changes to an unset state in the UI. I don't know what would happen if no error was sent.

revk commented 5 months ago

We don't change fan if the error is reported though?!? Maybe it thinks it is an unknown state, what fan state is reported on the web interface.

Nick-Sills commented 5 months ago

It changes to unset:

From:

image

To:

image
revk commented 5 months ago

I meant the web interface on the Faikin!

Nick-Sills commented 5 months ago

That's unchanged and shows 'Auto'. Perhaps 0 means don't change, and it's the error returned that's causing a problem in the HA UI?

revk commented 5 months ago

I can try that (i.e. not sending error) - use next beta. But a better "don't change" would be not to send f_rate at all!

Nick-Sills commented 5 months ago

I'll do some more tests but I think that's fixed both problems! 👍

Faikin-S3-MINI-N4-R2: 32727c3 2024-06-04T10:39:47 S21

Nick-Sills commented 5 months ago

Sorry, I spoke too soon. There's still the same error being returned.

revk commented 5 months ago

The latest beta should ignore a 0. I'll double check. Can you do another pcap?

Nick-Sills commented 5 months ago

Sure, it'll be in an hour or so.

Nick-Sills commented 5 months ago

First pass, and the response from Faikin seems to be good, it's also immediately responding to get_control_info request with the correct f_rate. I can't see where f_rate=0 is coming from, or why it's causing an error, given that it's got the correct f_rate from get_control_info.

Changing Set Temp - Error - Fan mode is invalid http://192.168.100.165/aircon/set_control_info?pow=1&mode=7&stemp=18&shum=0&f_rate=0&f_dir=0 ret=OK,adv= http://192.168.100.165/aircon/get_control_info ret=OK,pow=1,mode=7,adv=,stemp=18.0,shum=0,dt1=18.0,dt2=18.0,dt3=18.0,dt4=18.0,dt5=18.0,dt7=18.0,dh1=0,dh2=0,dh3=0,dh4=0,dh5=0,dh7=0,dhh=0,b_mode=7,b_stemp=18.0,b_shum=0,alert=255,f_rate=B,f_dir=0,b_f_rate=B,b_f_dir=0,dfr1=0,dfr2=0,dfr3=0,dfr4=0,dfr5=0,dfr7=0,dfrh=0,dfd1=0,dfd2=0,dfd3=0,dfd4=0,dfd5=0,dfd7=0,dfdh=0,dmnd_run=0,en_demand=0

Changing the fan speed - OK http://192.168.100.165/aircon/set_control_info?pow=1&mode=7&stemp=18.0&shum=0&f_rate=B&f_dir=0 ret=OK,adv= http://192.168.100.165/aircon/get_control_info ret=OK,pow=1,mode=7,adv=,stemp=18.0,shum=0,dt1=18.0,dt2=18.0,dt3=18.0,dt4=18.0,dt5=18.0,dt7=18.0,dh1=0,dh2=0,dh3=0,dh4=0,dh5=0,dh7=0,dhh=0,b_mode=7,b_stemp=18.0,b_shum=0,alert=255,f_rate=B,f_dir=0,b_f_rate=B,b_f_dir=0,dfr1=0,dfr2=0,dfr3=0,dfr4=0,dfr5=0,dfr7=0,dfrh=0,dfd1=0,dfd2=0,dfd3=0,dfd4=0,dfd5=0,dfd7=0,dfdh=0,dmnd_run=0,en_demand=0

faikin.txt

Not sure what adv= is

Nick-Sills commented 5 months ago

Perhaps return from aircon/set_control_info?pow=1&mode=7&stemp=18&shum=0&f_rate=0&f_dir=0

with ret=OK,f_rate=B ( or whatever the current fan rate is )

revk commented 5 months ago

I thought all the set commands just return ret=OK. Not sure about changing that incase it upsets something else. All seems very odd.

Nick-Sills commented 5 months ago

Agree, it's very odd.

It's currently retuning ret=OK,adv=, so it isn't just OK at the moment.

revk commented 5 months ago

OK I am not keen on tinkering with what is returned on a set command.

Nick-Sills commented 5 months ago

I can fire the same url at an actual Daikin WiFi board to see what happens. Give me a miute...

revk commented 5 months ago

OK, that is a sensible.

Nick-Sills commented 5 months ago

http://192.168.100.171/aircon/set_control_info?pow=1&mode=7&stemp=18&shum=0&f_rate=0&f_dir=0 it returned: ret=PARAM NG

for

http://192.168.100.171/aircon/set_control_info?pow=1&mode=7&stemp=18&shum=0&f_rate=B&f_dir=0 it reurned:
ret=OK,adv=

revk commented 5 months ago

Which fits with f_rate=0 not being valid, and what we were sending (along with adv= and error).

revk commented 5 months ago

I can't imagine the adv= being an issue with the PARAM NG.

But it suggests the issue is not in the Faikin.

Nick-Sills commented 5 months ago

I'll grab a .pcap of the same Fan speed change, followed by a set target temp change on the real Daikin wifi unit. This works OK in HA, so it'll be interesting to see if anything is different....

revk commented 5 months ago

Ok thanks, that should give us some way to get a comparison of the way it works.

Nick-Sills commented 5 months ago

Not checked it yet.... daikin.txt

revk commented 5 months ago

That looks like it sends f_rate=A or f_rate=B

Can you see any other differences?

Nick-Sills commented 5 months ago

The fan speed selections were different for the Daikin unit. With Faikin it reset to nothing on error, so I put it back to Auto.

I can't see any smoking gun. get_control_info is returning an extra two parameters on the Daikin unit, but that doesn't seem relevant. ,dfr6=5,dfd6=0

Still looking...

revk commented 5 months ago

Yeh, for some reason we exclude 6 on that, not sure why, but will be based on previous message dumps like this.

Nick-Sills commented 5 months ago

I think it has to be something with get_control_info as that's the only data that is effectively 'configuring' the climate entity states in HA. Unless I've missed something.

However, the unit with the Daikin WiFi board is a different model, so it's not a direct comparison.

revk commented 5 months ago

Can you see any other difference? I mean, I can add the dfr6/dfd6 maybe?

Nick-Sills commented 5 months ago

All other parameters match. If we try dfr6/dfd6 and it doesn't work then it could be reverted,

revk commented 5 months ago

OK, try that beta

Nick-Sills commented 5 months ago

No change I'm afraid...

Faikin-S3-MINI-N4-R2: cc5100f 2024-06-04T13:20:35 S21

revk commented 5 months ago

No change, as it not sending those extra values? or still not working? Might be a typo on my part, I'll try again.

We should be doing test builds not beta for this, but hopefully this is the last one.

Nick-Sills commented 5 months ago

I meant it didn't fix the problem. I haven't check for the parameters, give me a minute

revk commented 5 months ago

A couple more '6' entries I can send as well. I'll update again.

Nick-Sills commented 5 months ago

The extra parameters are there, so it's back to square one. I'll spend some time later studying the .pcap dumps to see if there's anything else

Nick-Sills commented 5 months ago

You could try dfr6=5 rather than dfr6=0. That's what the Daikin board returned.

revk commented 5 months ago

OK set otahost to test.revk.uk and turn off otabeta and upgrade.

Nick-Sills commented 5 months ago

done

revk commented 5 months ago

Ok that will send =5

Nick-Sills commented 5 months ago

My pi seems to have crashed/hung. Apologies, I'm going to have to go offline for a bit to fix this and attend to something else....

Nick-Sills commented 5 months ago

I'm afraid it didn't work. I think we may be barking up the wrong tree here, so I'll give it some thought and get back if I have any other ideas, Perhaps study the HA Daikin integration in more detail.

revk commented 5 months ago

Thanks.

Nick-Sills commented 5 months ago

I'm posting this here before properly looking at the data, so apologies if this isn't helpful.

It seems that the control communication between HA and Faikin is faultless when compared with a Daikin WiFi board. The problem might be due to the configuration of the Climate entity in HA, and that only happens on discovery when the device is added. So, I removed the Daikin native AC unit, and one of the Faikin units, then added them back and captured the discovery of both units. I've not had a chance to digest what's going on, but I thought it'd be useful info regardless.

Daikin Discovery

http://192.168.100.171/common/basic_info
ret=OK,type=aircon,reg=eu,dst=1,ver=1_14_88,rev=8A618141,pow=1,err=0,location=0,name=%20%46%72%6f%6e%74%20%42%65%64%72%6f%6f%6d,icon=22,method=polling,port=30050,id=a9706479-4a61-4a57-aa06-66c09f145a9d,pw=,lpw_flag=0,adp_kind=3,pv=3.20,cpv=3,cpv_minor=20,led=1,en_setzone=1,mac=346F240A90C8,adp_mode=run,en_hol=0,ssid1=Silvia42,radio1=-69,ssid=DaikinAP75416,grp_name=,en_grp=0

http://192.168.100.171/common/get_datetime?cur=
ret=OK,sta=2,cur=2024/6/4 21:22:25,reg=eu,dst=1,zone=211

http://192.168.100.171/common/get_remote_method
ret=OK,method=polling,notice_ip_int=3600,notice_sync_int=10

http://192.168.100.171/aircon/get_sensor_info
ret=OK,htemp=21.0,hhum=-,otemp=21.0,err=0,cmpfreq=16,mompow=2

http://192.168.100.171/aircon/get_model_info
ret=OK,model=135E,type=N,pv=3.20,cpv=3,cpv_minor=20,mid=NA,humd=0,s_humd=0,acled=0,land=0,elec=1,temp=1,temp_rng=0,m_dtct=0,ac_dst=--,disp_dry=0,dmnd=1,en_scdltmr=1,en_frate=1,en_fdir=1,s_fdir=1,en_rtemp_a=0,en_spmode=3,en_ipw_sep=1,en_mompow=1,en_onofftmr=1,hmlmt_l=10.0

http://192.168.100.171/aircon/get_control_info
ret=OK,pow=1,mode=0,adv=,stemp=20.0,shum=0,dt1=20.0,dt2=M,dt3=18.0,dt4=19.0,dt5=19.0,dt7=20.0,dh1=0,dh2=50,dh3=0,dh4=0,dh5=0,dh7=0,dhh=50,b_mode=0,b_stemp=20.0,b_shum=0,alert=255,f_rate=B,f_dir=0,b_f_rate=B,b_f_dir=0,dfr1=B,dfr2=5,dfr3=5,dfr4=5,dfr5=5,dfr6=5,dfr7=B,dfrh=5,dfd1=0,dfd2=0,dfd3=0,dfd4=0,dfd5=0,dfd6=0,dfd7=0,dfdh=0,dmnd_run=0,en_demand=0

http://192.168.100.171/aircon/get_target
ret=OK,target=0

http://192.168.100.171/aircon/get_price
ret=OK,price_int=27,price_dec=0

http://192.168.100.171/common/get_holiday
ret=OK,en_hol=0

http://192.168.100.171/common/get_notify
ret=OK,auto_off_flg=0,auto_off_tm=- -

http://192.168.100.171/aircon/get_day_power_ex
ret=OK,curr_day_heat=0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0,prev_1day_heat=0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0,curr_day_cool=2/2/1/1/2/1/1/2/1/2/1/2/2/3/0/0/0/0/2/2/2/0/0/0,prev_1day_cool=1/2/1/2/1/2/1/2/1/2/2/1/2/0/0/0/0/0/0/0/0/0/0/1

http://192.168.100.171/aircon/get_week_power
ret=OK,today_runtime=1025,datas=0/0/100/0/100/200/200

http://192.168.100.171/aircon/get_year_power
ret=OK,previous_year=0/0/0/0/0/0/2/2/3/1/0/0,this_year=1/1/0/1/1/0

http://192.168.100.171/common/get_datetime
ret=OK,sta=2,cur=2024/6/4 21:30:39,reg=eu,dst=1,zone=211

Faikin Discovery - (I played back the same URLs from the Daikin discovery)

http://192.168.100.165/common/basic_info
ret=OK,type=aircon,reg=eu,dst=1,ver=f690972+,rev=f690972+,pow=1,err=0,location=0,name=Villacana AC Back Bedroom,icon=1,method=none,port=0,id=34B7DA588E44,pw=,lpw_flag=0,adp_kind=0,pv=0,cpv=0,cpv_minor=0,led=0,en_setzone=0,mac=34B7DA588E44,ssid=Silvia42,grp_name=,en_grp=0

http://192.168.100.165/common/get_datetime?cur=
Nothing matches the given URI

http://192.168.100.165/common/get_remote_method
Nothing matches the given URI

http://192.168.100.165/aircon/get_sensor_info
ret=OK,htemp=21.00,hhum=-,otemp=21.50,err=0,cmpfreq=-

http://192.168.100.165/aircon/get_model_info
ret=OK,model=FTXM20R

http://192.168.100.165/aircon/get_control_info
ret=OK,pow=1,mode=7,adv=,stemp=20.0,shum=0,dt1=20.0,dt2=20.0,dt3=20.0,dt4=20.0,dt5=20.0,dt6=20.0,dt7=20.0,dh1=0,dh2=0,dh3=0,dh4=0,dh5=0,dh6=0,dh7=0,dhh=0,b_mode=7,b_stemp=20.0,b_shum=0,alert=255,f_rate=A,f_dir=0,b_f_rate=A,b_f_dir=0,dfr1=0,dfr2=0,dfr3=0,dfr4=0,dfr5=0,dfr6=5,dfr7=0,dfrh=0,dfd1=0,dfd2=0,dfd3=0,dfd4=0,dfd5=0,dfd6=0,dfd7=0,dfdh=0,dmnd_run=0,en_demand=0

http://192.168.100.165/aircon/get_target
Nothing matches the given URI

http://192.168.100.165/aircon/get_price
Nothing matches the given URI

http://192.168.100.165/common/get_holiday
Nothing matches the given URI

http://192.168.100.165/common/get_notify
Nothing matches the given URI

http://192.168.100.165/aircon/get_day_power_ex
Nothing matches the given URI

http://192.168.100.165/aircon/get_model_info
ret=OK,model=FTXM20R

http://192.168.100.165/aircon/get_week_power
Nothing matches the given URI

http://192.168.100.165/aircon/get_year_power
Nothing matches the given URI

daikin_init.txt faikin_init.txt

Nick-Sills commented 5 months ago

Just for giggles I asked ChatGPT. It could be total nonsense of course:

Detailed Fan Rates (dfr1, dfr2, ..., dfr7):

Real Unit: dfr1=B, dfr2=5, dfr3=5, dfr4=5, dfr5=5, dfr6=5, dfr7=B, dfrh=5 Reverse Engineered: dfr1=0, dfr2=0, dfr3=0, dfr4=0, dfr5=0, dfr6=5, dfr7=0, dfrh=0

Issue: The detailed fan rates (dfr1 to dfr7) are mostly zeros in the reverse-engineered output, except for dfr6=5. In contrast, the real unit has specific values for these settings, indicating a more complex configuration that adjusts the fan speed at different stages or modes. The lack of detailed fan rate configuration in the reverse-engineered module could lead to incorrect fan speed settings.

Recommendations: Align Fan Rate Settings: Ensure that the f_rate and b_f_rate parameters in the reverse-engineered module match those of the real unit. This can be set to B or the appropriate setting as per the real unit's configuration.