kiwi-cam / homebridge-broadlink-rm

[This fork supports TV accessories] Broadlink RM Mini and Pro plugin for homebridge: https://github.com/nfarina/homebridge
Apache License 2.0
303 stars 96 forks source link

Temperature Trigger Automation broken with 4.18 and 4.5.0 Beta 0 #733

Open JasonGoldenDDT opened 1 week ago

JasonGoldenDDT commented 1 week ago

Describe the bug Temperature trigger based HomeKit automations fail unless iPhone is awake when using 4.18 and 4.5.0 beta 0. I have two home automation routines that control the climate in my bedroom. One turns off the AC when the broadlink RM Mini 4 temperature sensor registered below 73 degrees. When the temperature rises above 74 degrees it turns on the AC.

It looks like this when it works.
Screenshot 2024-09-24 at 8 38 45 AM

Yesterday I upgraded to 4.18 to see if the issue has been resolved by recent iOS, macOS, Homebridge, Node, etc. updates.

Last night again I found under 4.18 the temperature automation did not fire unless my iPhone was awake. I only use this automation at night, so I tried 4.5.0 beta 0 to see if the issue was resolved in newer versions of the software. You can see this in the chart from last night with the large spike in temp. I rolled back to 4.17 and automation returned to normal.

Since iOS 17.6 I've noticed some devices don't update reliably unless observed in the home app, and their status can fall out of sync between devices.

I have an headless Apple TV 4K wired, a turned wifi network with an 88% - 100% experience metric (Alien router x 2 wired backbone).

This issue pre-dates public beta software. Actually installed the beta to see if it would resolve these issues.

To Reproduce Steps to reproduce the behavior:

  1. Create temperature trigger automation that turns a device on when a temp a broadlink RM Mini 4 temp sensor reads temp below X.
  2. Lock iPhone and monitor.

Expected behavior Temp Automation responds in near real-time to temperature trigger events, without the iPhone awake.

Screenshots Screenshot 2024-09-24 at 8 44 04 AM Screenshot 2024-09-24 at 8 44 14 AM

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context LMK what additional information I can provide.

JasonGoldenDDT commented 6 days ago

Spent an hour with screen recordings of 4.4.18, 4.4.17 and 4.5.0. beta 2.

I ran through multiple test routines with temperature trigger automations and recorded the screens of Home, Homebridge logs, and LG AC App for reference.

It appears that the only thing that forces the automation to run is either manually testing the automation via the home app, or reloading the home app on the iPhone or other device.

I'm sharing this finding with Homebridge as well. I have trace debugging enabled.

The zip file is 4.16 gb in size with 3 screen recordings for each version of the plug in and the related logs exported. It would be too time consuming to strip these files of identifying information, but I'm willing to share them privately with the developer directly to support resolution of this issue.

Screenshot 2024-09-24 at 10 10 10 AM
JasonGoldenDDT commented 6 days ago

Okay, weird. Not sure what he issue is, but it appears HomeKit or Homebridge may have an update frequency I'm not able to see in the Homebridge Logs.

With all Home Apps closed, and just the web UI for Homebridge open I watched with version 4.5.0 beta 2 installed with both HAP and CIAO, the automation IS triggered but it overshoots by a degree on average... the above 85 gets triggered when HB reflects 86... the below 84 gets triggered when HB sees 83 or even 82...

I've adjusted the refresh rate for the temperature sensor to 100 ms and debug trace logging is enabled.

This may be an issue with HomeKit's refresh rate on the temperature data. I also noticed that automation data was out of sync, after restarting the hub (headless appletv wired) the automation was pointed to the wrong sensor. Ugh.

This may not be an issue after all, just a limitation with HomeKit.

JasonGoldenDDT commented 6 days ago

I received some feedback from the homebridge GitHub that clarified how HomeKit handles temperature values and updates.

https://github.com/homebridge/homebridge/issues/3700#issuecomment-2372582579

They suggest adjusting how this plugin handles updates. Currently the automation works but it over/under shoots the set temperature by a few degrees, likely due to conversions in F to C, but also in the method used to update HomeKit.

kiwi-cam commented 6 days ago

Thanks for doing all the research for me @JasonGoldenDDT. The latest beta will hopefully help with this. Let me know how it goes.

JasonGoldenDDT commented 6 days ago

Happy to do what I can to progress this work forward. It saves us money every month.

Screenshot 2024-09-25 at 7 56 39 AM

Last night was perfect using 4.5.0 Beta.2 with a 100ms on the temp sensor. LMK what other context I can provide. I did update my AppleTVs to 18.1 public beta (22J5552d). I've been providing apple with feedback on automation performance as well. HomePod sensors are useless for automation triggers in my case.

Screenshot 2024-09-25 at 8 03 22 AM Screenshot 2024-09-25 at 8 03 59 AM Screenshot 2024-09-25 at 8 04 07 AM

{ "name": "Broadlink Temperature", "type": "temperatureSensor", "disabled": false, "host": "xxx", "temperatureUpdateFrequency": 100, "logLevel": "warning" }, { "name": "Air Con RM", "type": "air-conditioner", "disabled": false, "host": "xxx", "units": "F", "temperatureUpdateFrequency": 60000, "ignoreTemperatureWhenOff": true, "defaultCoolTemperature": 15.5556, "sendTemperatureOnlyWhenOff": true, "minTemperature": 15.5556, "maxTemperature": 30, "replaceAutoMode": "cool", "minimumAutoOnOffDuration": 300, "turnOnWhenOff": true, "preventResendHex": true, "coolOnly": true, "noHumidity": true, "noHistory": true, "logLevel": "warning", "data": { "off": "26004800000121931336131213121212131213111312133613121336133613121312133613361312133613121212131213121311131213361312133613361337123713361336131213000d050000000000000000000000000000", "on": [ { "data": "26004800000121931336131213121212131213111312133613121336133613121312133613361312133613121212131213121311131213361312133613361337123713361336131213000d050000000000000000000000000000", "pause": 0.5 }, { "data": "2600480000011f951237121312121114111411131114113812131138123810141213123711391113113811391113113911381114101411391113111411381114111410391138121311000d050000000000000000000000000000" } ], "cool15.5556": { "pseudo-mode": "cool", "data": "260058000001209411371313111411141014121311141138121211391237111411131238113812131014113911131138111411141114113811381213113811141039113812371114110005700001244d12000c4a0001264b11000d050000000000000000000000000000", "sendCount": 2, "interval": 0.5 } } },

I did see this error messages soon after my shortcut ran. The shortcut turns on the AC and turns on and adjust fan speeds for two Dyson fans. The RM Mini 4, shown as a 'Pro' controls the AC, sending the "ON" message. Each Dyson Fan has its own RM Mini 3 attached to it.

[homebridge-broadlink-rm-pro] This plugin generated a warning from the characteristic 'On': Characteristic not in required or optional characteristic section for service Fanv2. Adding anyway.. See https://homebridge.io/w/JtMGR for more info. [9/24/2024, 8:00:06 PM] [homebridge-broadlink-rm-pro] This plugin generated a warning from the characteristic 'On': Characteristic not in required or optional characteristic section for service Fanv2. Adding anyway.. See https://homebridge.io/w/JtMGR for more info. [9/24/2024, 8:00:06 PM] [Broadlink RM] Daryl's Fan setSwitchState: already 1 (no data sent - B) [9/24/2024, 8:00:06 PM] [homebridge-broadlink-rm-pro] This plugin generated a warning from the characteristic 'On': Characteristic not in required or optional characteristic section for service Fanv2. Adding anyway.. See https://homebridge.io/w/JtMGR for more info. [9/24/2024, 8:00:06 PM] [homebridge-broadlink-rm-pro] This plugin generated a warning from the characteristic 'On': Characteristic not in required or optional characteristic section for service Fanv2. Adding anyway.. See https://homebridge.io/w/JtMGR for more info.

Here is a sample of the Dyson fan programming:

{ "name": "Daryl's Fan", "type": "fan", "host": "XXX", "logLevel": "warning", "defaultNowTemperature": 20, "alwaysResetToDefaults": false, "persistState": true, "resendHexAfterReload": false, "hideRotationDirection": false, "stepCycle": true, "allowResend": false, "data": { "on": "26004800421919181719172f192d191717191719171a19181818191818181817192d192c19000caf46171a171918192d172e181819171917191819181917191818181917182d182d18000d050000000000000000000000000000", "off": "26004800441818191818182e182e1818181818181819181918181818181918181718181818000cd8481918181819182e182e1818181718181819181918191818181818181818181718000d050000000000000000000000000000", "swingToggle": "26004800421918191719182e162f181818181817181a1719182e182e18181818182d182d18000d03471917191818182e172f17191817181818191819172e182e17191818182d172f17000d050000000000000000000000000000", "clockwise": "26004800411a171a1719172f172e1719171917181730171a1630162f1719172f172e172e17000cda481817191917192d192d181816191917182f1818192d192d1917192c192d182d19000d050000000000000000000000000000", "counterClockwise": "26002400441719181917192d192c1917191719161919192d19171917192d19161917192c19000d050000", "fanSpeed10": [ { "data": "26004800441819171918192c192d191719161917192e192d192d192d192d192c192c192d19000ca8461719171a17192c1a2c191719161a16192e192d192d192d192c1a2c192c192c1a000d050000000000000000000000000000", "sendCount": 10, "interval": 0.3 } ], "fanSpeed20": [ { "data": "26004800431819171918192c1a2c191719161a16192e192d192d192d192c1a2c1917191619000cd2481719171a17192c1a2c191719161a16192e192d192d192d192d192c1917191619000d050000000000000000000000000000", "sendCount": 10, "interval": 0.3, "pause": 0.2 }, { "data": "26004800421918191818182e182e181817181818171a182e1818182e1818182e172e182d18000cea49171a171917192d192d19161a1619171918192d19171a2c1917192d192c192c19000d050000000000000000000000000000" } ],

JasonGoldenDDT commented 4 days ago

Still monitoring this... last night experienced a glitch in temperature trigger...

Screenshot 2024-09-26 at 1 37 01 PM

Working through this issue in this thread:

https://github.com/homebridge/homebridge/issues/3700#issuecomment-2378080983

Because I'm noticing multiple plugins where home falls out of sync with the device. I'm running a detailed log. When testing it works as expected, but over night it has a tendency to fail. Planning to capture detailed trace and HAP logging tonight.

Also, noticed this error on version 4.5.0 beta.2: [9/26/2024, 1:00:33 PM] [homebridge-broadlink-rm-pro] This plugin generated a warning from the characteristic 'On': Characteristic not in required or optional characteristic section for service Fanv2. Adding anyway.. See https://homebridge.io/w/JtMGR for more info.

Not sure if this a configuration change I need to make or not.