revk / ESP32-Faikin

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

Temperature of external sensor not shown/used #111

Closed andreas-bulling closed 11 months ago

andreas-bulling commented 1 year ago

I've flashed one of the "Mi Temperature and Humidity Monitors" and it is found by Faikin and showing the measured temperature. However, this temperature is not forwarded to HomeAssistant it seems and, consequently, also not shown nor can it be used as a reference when setting temperatures.

Would be great if that worked :)

revk commented 1 year ago

There is a setting to use it as reference, which you also have to pick (asks for tolerance) and what target you want. It then tells the Daikin high or low to get the target temp, so what goes to HA may be rather confusing.

There is probably scope for improving the links to HA. At present HA just sees what the Daikin sees, which is its view of temp and target, not the external temp or logical target.

It may make more sense when in this mode for HA to see, and be able to set, the "logical" target we are using, and see the external reference.

Maybe when I am over this bout of covid.

andreas-bulling commented 1 year ago

you mean "Remote BLE temperature sensor"? This I have set.

Get well soon!

revk commented 1 year ago

I mean "Track" and when it appears the temperature target slider.

andreas-bulling commented 1 year ago

Is there a documentation somewhere what "Track" does?

revk commented 1 year ago

I thought so, but I will look.

It is the "Faikin auto mode" in effect. It controls the Daikin setting hot/cold and a high/low target to aim for a specific temperature. It can use a BLE sensor as the target for that or the built in temp sensor if no BLE sensor set.

andreas-bulling commented 1 year ago

Oh, that is the auto feature?! Good to know but curious that it's disabled by default (if I am not mistaken). Isn't that the most important feature/what users want - set a target temperature and the AC maintains that temperature?

FYI: When using the thermostat card/entity/whatever in HA and set a target temperature there it's not this one. It's the temperature in the top part of the Faiking configuration screen. Or do I misunderstand?

revk commented 1 year ago

Your aircon has an auto setting, and it uses its idea of room temperature and probably has a very wide margin on that.

The "track" is a feature in my code that allows controlling the aircon much more tightly and even using an external (BLE) reference.

The HA side only knows of the aircon itself, so will see the target go up and down a lot when using the track feature, and won't see the BLE temp. This is perhaps what would be better switched over to the settings used by the track feature instead. A useful change I may do.

But sounds like it needs more documentation at least.

andreas-bulling commented 1 year ago

There is lots of potential in a tighter integration with HA (and potentially others) I think - the tracking in combination with an external BLE sensor is a really cool feature that few others (maybe even none?!) have. Ideally one could control/enable/disable most/all of this through HA.

Unfortunately I cannot help directly with coding - but I am happy to continue giving feedback/ideas based on the six Faikin modules I have bought/will have in use eventually, and testing HA stuff out.

revk commented 1 year ago

Still feel like shit, but yes, sounds like a good idea.

revk commented 1 year ago

OK I am back on dry land, still not well, but I agree this would be a good change, so looking in to it. It would help if you are around to test some changes at some point this week.

revk commented 1 year ago

I have issued new code.

The HA reporting of temp and target will now be the Faikin ones if the Faikin-auto mode is engaged. It will report as auto mode.

The control from HA to set temp should set the target we are using in Faikin-auto.

Do test and let me know any issues.

andreas-bulling commented 1 year ago

Thanks a lot but just a quick question:

"The HA reporting of temp and target will not be the Faikin ones if the Faikin-auto mode is engaged. It will report as auto mode."

Did you mean to say "will noW be the Faikin ones.." ?

andreas-bulling commented 1 year ago

Flashed the newest firmware but I unfortunately can't test the new functionality out - the external sensor is not read out anymore since I had to switch to the BTHome advertisement format (see the other issue I just created).

andreas-bulling commented 1 year ago

OK, so in Faikin-auto mode the temperature from the external BLE sensor gets transmitted to HA fine. The operation mode of the AC cannot be changed in HA anymore - it seems to be fixed to "auto" (intended?)

However, in this mode, one also cannot turn off the indoor units with the remote control anymore - only through HA. I assume this is not intended?!

revk commented 1 year ago

The mode being auto is deliberate, as the actual mode is hot/cold as needed. If you want hot/cold then change to normal working. I mean I could make it setting other modes turns off the faikin-auto. It may be I can create a new mode that is 'failing-auto' or something... Possible improvement.

As for remote - not even tried that before, it may be something I can change to work out you must have done it via the remote.

andreas-bulling commented 1 year ago

So, as an intensive HA user - here's what would be ideal IMHO. The wishlist that is ;) Maybe it helps/gives some ideas for further improvements if you have time.

The switch to enable/disable Farkin-auto mode is exposed to HA and can be operated there without having to go to the Faikin web UI. Same goes for the target temperature, allowed temperature deviation, eco mode etc.

The Faikin-auto mode would just be another operating mode. Turning it on disables any other mode and it equally gets disabled once the user selects heat/cool explicitly. Also by the "normal" auto mode.

ALTERNATIVE: The Faikin auto mode replaces the "normal" auto mode. It's better after all it seems. If a BLE sensor is connected that one is being used. Otherwise the internal sensor, turning it into the "normal" auto mode again.

andreas-bulling commented 1 year ago

As for remote - not even tried that before, it may be something I can change to work out you must have done it view remote.

Sorry, don't get what you mean with "you must have done it view remote"?

revk commented 1 year ago

Thanks for feedback. I'll have to see what I can work out.

revk commented 1 year ago

I'll re-open so I don't forget.

JeanOlivier commented 11 months ago

I just installed a BLE sensor for both of my units and it seems to have worked alright.

The faikin auto mode is very interesting, but it seems to take over the whole unit. Ideally I'd like to be able to say "cool only" or "heat only", and turn it on/off with the timer.

However, what would be even better IMO, it to use the BLE sensor instead of the internal Daikin one, as transparently as possible.

What I mean by that is a mode where you automatically set the internat Daikin target to the desired value +ΔT between the BLE sensor and the Daikin one, and keep track of this +ΔT over time and adjust the Daikin internal target accordingly.

I thought about implementing this in HA automations but I'm not familiar enough with it yet, and there's the issue of keeping track of the actual target set by the user vs the internal target within the Daikin. I feel like that would be easier done inside the dongle itself.

I think simply intercepting the "set temperature" command (from remote/HA/webpage) and then passing the adjusted value (+ΔT from the BLE) periodically would work. But you'd need to keep the "last user-set target" in memory.

I can open a separate issue describing this if you prefer.

revk commented 11 months ago

I think configuring the over and under temp setting controls to zero may do that. Someone else posted that worked well for their Daikin.

JeanOlivier commented 11 months ago

You mean essentially setting the PID (or PID-like) adjustment for temperature to follow the BLE directly?

It think this might essentially be what I'm asking for, but I'd like it to be a feature enabled no matter the mode. Let's says I'm turning on heat I don't want it to ever cool, and turning the unit on/off is only done manually or through the webpage Schedule.

Can one create virtual devices in HA with internal states that can control other devices? I could maybe do a prototype this way.

JeanOlivier commented 11 months ago

Update:

I found this: https://www.home-assistant.io/integrations/template#state-based-template-sensors

Which seems like it'd be sufficient for my goal as long as I can read the BLE sensors through HA. Could the faikin forward that information? Otherwise I'll just buy a Bluetooth adapter for the HA server.

If I can find the time to implement this, and if it works well, I'll share it wherever appropriate.

revk commented 11 months ago

Not sure on HA side. Obviously new ways of working could be added if people really want them.

revk commented 11 months ago

The BLE is reported when in the auto mode. I don't recall for other reports. That is probably easy to add. But afaik HA can read these BLE as well.

JeanOlivier commented 11 months ago

The BLE is reported when in the auto mode. I don't recall for other reports. That is probably easy to add. But afaik HA can read these BLE as well.

HA can read it but I don't have Bluetooth support on my server. That's on me though, not you, a passthrough would just be convenient.

I'll try to implement my idea in HA. It's easier for me to script "over" your firmware than to modify it. If that's a feature you find interesting, or if there is a demand from someone else than me about it, then feel free to implement it.

andreas-bulling commented 11 months ago

No need for a BT module. If you got an ESP32 flashed with ESPHome close-by you can activate a Bluetooth proxy on the device to read out all values of the sensor in HA.

When you flash your temperature sensor I recommend you select the BTHome protocol - the others didn't not work reliably for me. BTHome devices get detected within a few seconds and report all sensor readings nicely (temperature, humidity, battery voltage and percentage).

I should add that I haven't quite understood @JeanOlivier what you want to achieve that's not already there/possible. I have two indoor units so far that I run with the Faikin auto mode. I set the temperature to 23 degrees, 1 degree deviation allowed, and the room temperature is held nicely at 22.1 degrees all the time. This works so well one completely forgets about the units. I never saw a need to interfere. Isn't that exactly what one wants - the technology fading into the background and just doing what it's supposed to do?!

JeanOlivier commented 11 months ago

@andreas-bulling

I will want to control when the unit is on/off a different times during the day and ensure it's only heating during winter and warming up during summer. I'm from a very cold-winter place, starting the AC when it's -30C outside because you overshoot doesn't make sense. Ideally I'd also like to turn off the heat pump in favor of regular electric heating when it's under -20C outside, but that's another discussion.

I agree that the best is when technology is doing its job in the background, I just want to tune that job my liking.

Ideally the BLE sensor would just replace the internal thermometer of the unit and I'd be happy. But I understand this requires some more logic.

As for Bluetooth, I don't have any other ESP32 modules and I don't plan on changing from the revk firmware. I had no issue detecting the flashed sensors with my phone and with the faikins using the default settings. I only adjusted the deltas for temperature and humidity.

revk commented 11 months ago

I have a tired on/off and have a setting to turn on/off automatically based on temperature.

I'll have to double check the settings for change from hot/cold when needed. It really should only change if needed, but there are a few settings which can be tweaked which probably stop it ever hitting that.

The advanced section of the manual lists most, but I'm not at my computer right now to check.

JeanOlivier commented 11 months ago

I've been using the scheduled On/Off for a while now, but the "faikin auto" mode seems to take precedence over the schedule.

revk commented 11 months ago

I'll look when get back, but there will be settings (via MQTT) that can be used to change the way it works.

JeanOlivier commented 11 months ago

I received my Bluetooth adapter and it seems to be working fine with the flashed BLE temperature sensors over Home Assistant. It needs the Passive BLE Monitor from HACS to be detected.

I started digging into python scripts for HA automation, see this more flexible schedule implementation in https://github.com/revk/ESP32-Faikin/discussions/132 as an example.

I'll give a shot to an auto-track-ble-temperature-sensor script when I have the time.

XMaarten commented 11 months ago

If possible I would like the Faikin module to forward the raw data from the BLE sensor to MQTT / HomeAssistant, both the temperature and the humidity if available. It saves from having an extra ESPHome module just for that functionality...

revk commented 11 months ago

I'll see what I can do.

revk commented 11 months ago

I have issued new code - it should show BLE temp/hum on web page and on HA. Please do let me know if that works for you as I don't have a HA set up for testing.

XMaarten commented 11 months ago

That is great! Thank you so much! I just tested it and it works without issue in HomeAssistant.

One small thing: you are using mdi:humidity as icon which doesn't exist, I think this should be mdi:water-percent.

revk commented 11 months ago

Ha, that was a guess, changed in next issue (a few minutes). Thanks for testing.

andreas-bulling commented 11 months ago

I can also confirm that it works fine in HA. Minor thing: On the Faikin webpage the BLE temperature is shown twice now - with a slash behind the internal temperature and as "BLE"

revk commented 11 months ago

Ah, if it is used as the reference temperature, that was always shown. So yes, may be a tad confusing. I may have to clean that up a bit.

JeanOlivier commented 11 months ago

I can also confirm it works fine (minus the icon as stated above).

It's even better than using the thermometer via HA bluetooth in my case, since my server is far away from the thermometer/Daikin and the bluetooth signal is very faint, but the Faikin sees both the wifi and thermometer perfectly.

andreas-bulling commented 11 months ago

there is another feature waiting to be implemented then - ESP Bluetooth Proxy (see ESPHome). If Faikin supported that it could also robustly forward the BLE sensor data. And not as a separate Faikin entity but readily using the ESPHome/HA Bluetooth infrastructure.

But I don't think this necessarily has to be high on the priority list. Or, rather, how many people need that I don't know. I have enough other ESP32 modules distributed throughout our home so that BT coverage is pretty good.

XMaarten commented 11 months ago

@andreas-bulling You could already use Faikin as ESPHome module and add the Bluetooth proxy there easily.

revk commented 11 months ago

I have an app for BLE to MQTT. It does not (yet) create HA configs, but probably could.

revk commented 11 months ago

I may look in the morning

andreas-bulling commented 11 months ago

@andreas-bulling You could already use Faikin as ESPHome module and add the Bluetooth proxy there easily.

Thanks a lot - I actually know this repository but I haven't dared trying it out given that it seems to support less features than Faikin (Faikin's BLE feature is particularly nice and, I think, unique but also eco/night mode and presence detection would be nice to have) - and whether it's still actively maintained.

revk commented 11 months ago

Covered by issue #133