core icon indicating copy to clipboard operation
core copied to clipboard

Big Ass Fans not in sync if using auto features

Open compuboy04 opened this issue 2 years ago • 13 comments

The problem

I am running Haiku and ES6 fans. If I enable the auto features for the light or fan, either in the app or within home assistant, the dashboard loses sync with what the fan is actually doing. For example, If I set the light to go to 75% when motion is detected, or if I set the fan to turn on when the room is above 74F my dashboard will show the fan and light both off. I have also seen cases where it says the fan or light is on when its not. The fix is to toggle the light or fan on and off.

It seems when the fan's built in auto features are in use, the status of the fan and light are not being refreshed unless a change is made within home assistant.

What version of Home Assistant Core has the issue?

2022.7.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

baf Big Ass Fans

Link to integration documentation on our website

https://www.home-assistant.io/integrations/baf

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

compuboy04 avatar Jul 12 '22 20:07 compuboy04

baf documentation baf source (message by IssueLinks)

Hey there @bdraco, @jfroy, mind taking a look at this issue as it has been labeled with an integration (baf) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

I have 2 Haiku fans on auto. I just did a quick check and the fan speed is in sync with the actual state of the fans. If I change the target temperature to cause the fans to spin up or down, the state updates in HASS (but that could be due to the target temperature update -- some state updates are bundled together by the firmware). I'll do more testing to see if motion activation can reproduce the issue.

I suspect HASS may be displaying the "manually set speed" of a fan as opposed to its actual speed. So things should be in sync in manual mode, but may get out of sync in auto mode. It's not clear if the "actual speed" and "last manually set speed" states are distinct what HASS should do -- have 2 different entities (one read-only)?

A few more things:

  • Can you enable the Target RPM and Current RPM diagnostic entities and check if those stay in sync with the fan? They are not enabled by default because they are transient sensors that would fill up your database.
  • What firmware version are you using on your devices? BAF released a new firmware recently (3.1.0). I have upgraded to that firmware and I'm not sure if the behavior is different from the prior firmware.

jfroy avatar Jul 25 '22 16:07 jfroy

Thanks for the reply. I just did some testing now with my bedroom Haiku. I will try to give as much detail as possible to help you out. This is a great integration and want to see it perfect!

If AUTO for light is turned on, Home Assistant reads the fan light as off no matter what its actual state is. Auto as you know needs to be on to use the Haiku's motion sensor. Lets say I use home assistant dashboard to turn the light to about 70%. Everything is in sync and reflected perfectly. (BAF app and HA show the light as on) If I then turn Light Auto on in BAF app, or if the light returns to auto mode, HA will reflect the fan's light as off but the BAF app still shows it correctly as on. I can consistently reproduce the issue every time doing this. The key to it all is auto mode. Turning it on in the BAF app, or allowing to to turn on either with a schedule or by return to auto actually sends a "turned off" event to home assistant.

If I have auto on as shown in the screenshot from the app, changing the light brightness in the BAF app or with the remote does nothing to the state in HA and it remains "off" I even restarted home assistant.

I suspect a similar issue with fan auto, but was not able to quickly reproduce it tonight. Will wait to see what you say about the light first. I suspect fan auto needs to be turned on and then respond to a temperature change for the glitch to occur.

I am on the new 3.1 firmware. I also have an ES6 fan and same issue there.

as seen in the screenshot, HA reflects hitting the auto button in the app, or "Return to auto" as "off" baf

compuboy04 avatar Jul 26 '22 00:07 compuboy04

I'm not done investigating, but the short story is that Home Assistant models a light's on/off state as a binary value (ON or OFF). It's awkward to model BAF's AUTO state with just that. The current integration maps AUTO to OFF (which matches the behavior you're observing for the toggle). We could instead track the real hardware state in the HASS model, but it's not clear (to me) if that would create a feedback loop, e.g. the firmware turns off the light, thus causing the HASS state to go from ON to OFF, thus causing the device firmware mode to go from AUTO to OFF. If not, that's probably a better behavior than what is currently implemented.

Furthermore, there is no affordance to set the light to AUTO mode (based on your screenshots).

The fan entity does not suffer from these problems for 2 reasons. First, the fan entity has a preset mode state which lets us model AUTO.

Screenshot 2022-07-26 at 14 19 55

And second, although we map the AUTO hardware mode to OFF for the on/off toggle, the fan entity has special code to consider the fan ON despite the on/off state if the fan's preset mode is set or if the fan speed is not 0:

    @property
    def is_on(self) -> bool | None:
        """Return true if the entity is on."""
        return (
            self.percentage is not None and self.percentage > 0
        ) or self.preset_mode is not None

jfroy avatar Jul 26 '22 21:07 jfroy

It's not clear to me why the light brightness is not tracking, but I've been focusing on the on/off state.

jfroy avatar Jul 26 '22 21:07 jfroy

Sounds good. Your last part about the fan state may explain what I saw using fan auto mode before. As I recall the fan was off (not moving) but HA was showing it as "on". I havent been able to reproduce this since the firmware update, but havent been home enough.

I think I understand what you are saying. Lets say the light is on auto and things are properly tracking. When the fans firmware shuts the light off, it may then trigger an "off" event and disable auto on the fan. Am I following you correctly? If so, makes sense.

Personally, the most important thing to me is accurate state reporting of the fan and light. I really dont care if I can control auto mode for the light/fan in HA, as I would generally use a schedule in the BAF app to set the fan to go into auto mode at 5pm every day. This way when I turn it off before bed its off for good until tomorrow.

Further, with your integration as is, I can use a different motion sensor, and the in-built temperature sensor to let HA control the light/fan and just keep auto mode off. I'd like to use the in-built motion hardware though if possible as the placement in the center of the room is perfect!

If you need anything else from me, or would like me to try anything, let me know. I am definitely more of a hardware and networking guy than a programmer though... just a heads up! Also, unrelated from this, the ES6 fan and the new revision of the Haiku come with both an up and down light as well as RGP functions. My ES6 has all of this so if you would like to use my hardware to add support for those features, just let me know.

compuboy04 avatar Jul 26 '22 22:07 compuboy04

Spent some time tonight testing out fan auto. Seems to be solid. Not sure what I was seeing before. Will let you know if I notice anything. The speed in HA matches what the fan is doing, including if its off.

compuboy04 avatar Jul 26 '22 22:07 compuboy04

Spent some time tonight testing out fan auto. Seems to be solid. Not sure what I was seeing before. Will let you know if I notice anything. The speed in HA matches what the fan is doing, including if its off.

I would expect you'll see the fan state as ON but the speed slider at 0 if the fan is in AUTO mode and the firmware decides to not spin the fan (because the target temperature is above the current temperature, for example).

I don't have an ES6 or a Haiku with fancy lights, so it's very hard for me to add new hardware functionality in isolation. If you want to help, you can do so in a few ways.

  • Take screenshots for all setting screens in the BAF app for the devices.
  • Run an internal tool to dump firmware messages.
  • Run the BAF app on an Apple Silicon Mac and capture packets with Wireshark.

For the tool, you can run it to get an initial dump of all firmware state and any further state pushes from the device. So you could run it with a long query interval (say 10 or 30 minutes), making a note of the initial state of the device, then take various actions in the BAF app, like editing a single setting, going through a bunch of possible configuration of the device, keeping a log of each action you're taking, and attach all the resulting dump files and your notes.

python3 -m venv hass75087
source ./hass75087/bin/activate
pip3 install aiobafi6
aiobafi6 --discover
# ^C when you have your fan's IP
aiobafi6 --direct --dump --ip <IP>

If you have an Apple Silicon Mac you can run the BAF app on your Mac with Wireshark to capture all the network traffic between the app and the fan device. Go through more or less the same process as above, but attach the pcap file instead. You can also do this I suppose with any smart phone and an appropriate packet capture setup (which I assume is possible to do with Android as well). Or maybe just run an Android emulator.

jfroy avatar Jul 26 '22 23:07 jfroy

I should be able to provide everything you requested at some point. I dont have a Mac but am very familiar with wireshark and can easily isolate all traffic to the fan and get you captures.

As far as the light issue, do you have any thoughts on a fix? About to pull the trigger on an alternative motion sensor and just setting up an automation in HA :)

compuboy04 avatar Aug 01 '22 23:08 compuboy04

I should be able to provide everything you requested at some point. I dont have a Mac but am very familiar with wireshark and can easily isolate all traffic to the fan and get you captures.

Great. I'm particularly interested in seeing the data for the up and down lights, how they are controlled, and how the color is controlled for the uplight. I haven't seen data from that hardware yet.

As far as the light issue, do you have any thoughts on a fix? About to pull the trigger on an alternative motion sensor and just setting up an automation in HA :)

I need to discuss with @bdraco but my current idea is to throw in a additional switch or select entity to represent the tristate of a BAF light (OFF, ON, AUTO), which will track the hardware state, override BAF light's is_on property to return True either when the mode is ON or AUTO, or if the brightness is > 0, and override the light entity's turn_on, async_turn_on, turn_off, and async_ turn_off to do something more useful. Probably set the light mode to OFF if the light entity is actuated by the user to its off state, and set the light mode to ON or to its last known "on" state (ON or AUTO). The new switch or select entity would also actuate the hardware's mode and thus indirectly update the light entity's state when the hardware sends update messages as a result of changing the mode.

jfroy avatar Aug 02 '22 00:08 jfroy

@compuboy04 Oh and by the way, I just added occupancy support to the integration. Requires firmware 3.1. It should work on your fan models. I don't know when that will be released.

jfroy avatar Aug 02 '22 00:08 jfroy

Oh and by the way, I just added occupancy support to the integration. Requires firmware 3.1. It should work on your fan models. I don't know when that will be released.

Oh that's really awesome thanks!! I was wondering if this might happen :)

petervk2 avatar Aug 09 '22 11:08 petervk2

@jfroy I do see the Occupancy sensor for my bedroom Haiku and Living Room. The living room seems pretty accurate and will mess with it. My Haiku however just shows "on" 24/7. I do have light-auto on still. Not sure if thats why and its messing it up. Will turn it off and see if it helps.

How quick does the change react? Can I use occupancy like a regular motion sensor entity? That would be AMAZING!

I'm eager to help get you the data for the ES6 and will try to by the weekend. I will get sceenshots and wireshark captures of all the functions. Whats the best way to get it all to you, a google drive link?

Thanks for all your effort. Fun fact, your integration is what caused me to pull the trigger and start using Home Assistant. The convo with my partner went like this "So it can control the fans... You ok if the switches (zwave) are all down a few days while I figure this all out? GREAT!"

compuboy04 avatar Aug 23 '22 19:08 compuboy04

@jfroy I do see the Occupancy sensor for my bedroom Haiku and Living Room. The living room seems pretty accurate and will mess with it. My Haiku however just shows "on" 24/7. I do have light-auto on still. Not sure if thats why and it's messing it up. Will turn it off and see if it helps.

Yeah I only tested using my no-light Haikus, so it's possible it's bugged on with-light Haikus, or interacts with auto modes in some manner.

How quick does the change react? Can I use occupancy like a regular motion sensor entity? That would be AMAZING!

I don't know the exact technology they use, but it feels as responsive as a PIR sensor. They do hold the state to "occupied" for 5 minutes (on one of the firmware flags for occupancy -- they have another flag that sticks for 10 minutes).

I'm eager to help get you the data for the ES6 and will try to by the weekend. I will get sceenshots and wireshark captures of all the functions. Whats the best way to get it all to you, a google drive link?

Attach everything to this GitHub issue if you can (as individual files or an archive). If that fails (too big?), then Google Drive or similar. Make sure to scrub any personal information (there shouldn't be any in the binary data and screenshots -- everybody has a Living Room I hope :p).

Thanks for all your effort. Fun fact, your integration is what caused me to pull the trigger and start using Home Assistant. The convo with my partner went like this "So it can control the fans... You ok if the switches (zwave) are all down a few days while I figure this all out? GREAT!"

Happy to help :)

jfroy avatar Aug 23 '22 21:08 jfroy

@jfroy Sounds good. Put together a quick automation for light on/off based on sunset and occupancy sensor. In the app I then disabled light auto completely and rebooted the fan (power switch on the wall). As I suspected, light auto does cause occupancy to always stay on.

Response is near identical to most PIR's like you said. I get about 3 steps into the room before it fades in. It seems to hold the occupied state for about 10 minutes for me. I did just now try playing with the "light auto motion timeout" setting in the app thinking that may adjust it. Doesn't seem to be the case. In its current state, its honestly ideal and solves my original complaint about not having things in sync. If HA can replace the functionality of light auto using the same sensor in the fan, thats good enough for me. Plus I can adjust it to the position of the sun, which the fan cannot do. Not saying dont improve things so it can work with light auto, but saying this is a fantastic solution to my original problem in initial testing. :)

Considering the state seems to change about 10-12 minutes after motion stops, I just have it turn the light off immediately when not occupied. (trigger on not occupied)

compuboy04 avatar Aug 23 '22 22:08 compuboy04

@jfroy See screenshots and PCAP. Will be honest, not sure how much this will help. I didnt really see much human readable data here, at least not much I can make sense of. I connected the fan to an access point by itself and then mirrored the switchport and captured the traffic with wireshark. The fan is 10.0.2.104 and my phone is 10.0.2.129

I clicked all the options unique to this fan:

  • light selection (uplight, downlight or both)
  • Color temperature
  • Night light colors
  • Night light brightness
  • Night light enabled/disabled
  • Dim to warm function

If like I suspect, this isnt what you need, let me know what else I can possibly try. I have a layer3 managed switch available to me and Windows and Linux laptops.

image

image

image

image

BAF.zip

compuboy04 avatar Sep 04 '22 03:09 compuboy04

Thanks for the data.

I don't understand how the multiple lights work (the "Dim to warm" screen). Do you have independent control of the lights? I just don't understand the product enough. Can you explain in more details if you can control the lights individually (by selecting the mode), or only configure which lights are enabled (the mode) and only set one intensity for all of them.

Assuming you changed the light mode first, and went left to right, then

root2 {
  commit {
    properties {
      82: 0
    }
  }
}

is setting the light mode. 0 is all, 1 is down, 2 is up.

Assuming you changed the night light settings last, that would be this property:

root2 {
  commit {
    properties {
      83 {
        1: 6
        2: 1
        3: 36
      }
    }
  }
}

Based on the captured data, if you toggled the feature off then back on, then field 2 is bool "on/off". Assuming you toggled the colors from left to right, then field 1 is color {red: 1, orange: 8, yellow: 5, purple: 6, green: 2, cyan: 4, fuchsia/pink: 9}. No value for 3 or 7. Assuming you ended brightness at 13%, the last property commit has field 3 set to 13, so I'm going to guess field 3 is brightness %.

There are a lot of unknown capabilities fields set, I need to cross-reference them, but I'm not sure I'll be able to tease anything apart.

Thanks!

jfroy avatar Sep 04 '22 20:09 jfroy

@jfroy Now that I know this data is potentially useable, let me get things better organized :)

I redid things, and divided the captures just now.

Capture1 On the light screen, at the very top you see three buttons. These are:

  • both lights on
  • downlight only
  • uplight only These are a selector for what the light control does and what light it controls. on the fan. For example, if I select downlight, until I make another selection, all lighting controls for the fan will control only the downlight. In the capture here is what is done and the order:
  • Starting with the light on at 67% brightness and with the light selection initially at uplight, I click the buttons in the following order: both, downlight, uplight
  • I then adjust the brightness to 100%
  • lastly I press the large light button to turn off the light.

Capture2 At the bottom you will see a button with 4 colored circles between orange and white and blue. This is color temperature. I have two settings here, bright white and soft white In the capture the fan's light is already on at 67% soft white, and I do the following:

  • Bright white
  • Soft white
  • bright white
  • soft white

Capture3 We now are leaving the normal lighting controls in the app and going into settings (the gear at the bottom and then the light tab) There is a toggle called dim to warm. What this does is at lower brightnesses the light will use warm color and it will get brighter as you turn it higher. Without this setting, the light either follows the warm white or bright white setting throughout all brightness levels. In this capture I start with dim to warm turned on and do the following:

  • off
  • on
  • off

Capture4 We now get into the color uplight feature. BAF calls it night light because its always on when the fan light is off. For example if I select blue and 20%, any time the fan light is off the color uplight turns on. The second you turn the fan light on, this turns off. This is where things could get really cool because you can make it pretty bright in a dark room and shine color everywhere. Its just buried in menus! In this first capture, I am simply toggling the night light feature off and on. I am starting with it turned on. In the pictures I sent in the last post you will see "Night Light Enabled" or the toggle next to night light on the screen with the colors.. Thats the setting im changing.

  • night light off
  • night light on
  • night light off

Capture5 Now we get into color and brightness. I am on the screen with the color selection and brightness above that. I am starting with the last color magenta selected and brightness on 13% I am doing the following:

  • red
  • orange
  • yellow
  • green
  • blue
  • dark purple
  • magenta
  • Brightness to 100%
  • Brightness to 43%

These are all the new features this fan supports. There is another UV sterilization setting on that model and some other models, however mine is not equipped with that function.

I hope this is useful and more help than the first post BAH captures 2.zip

compuboy04 avatar Sep 04 '22 23:09 compuboy04

@jfroy Just making sure you saw my new captures above. Hope it helps!

compuboy04 avatar Sep 14 '22 02:09 compuboy04

I did and the extra precision I think is going to help, thank you. I've been busy and haven't had a chance to sit down and go through it.

jfroy avatar Sep 14 '22 02:09 jfroy

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Dec 23 '22 15:12 github-actions[bot]

Still a problem.

jfroy avatar Dec 24 '22 03:12 jfroy

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.