home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.82k stars 30.51k forks source link

Binary Sensor updates delayed by up to 15-60 seconds with Total Connect Alarm #37307

Closed trevorcortez closed 4 years ago

trevorcortez commented 4 years ago

The problem

The binary sensors created for each zone are updating, but can take up to 60 seconds from the time an action is taken (and the log entry shows up on the TC2 website) and when the event is picked up by HA.

For example, I opened a window: TC2 timestamp is 4:47:19 PM HA timestamp is 4:47:58 PM

I closed that window: TC2: 4:48:15 PM HA: 4:49:00 PM

Is the total-connect-client notification driven, or does it use polling?

Environment

k v
arch x86_64
dev false
docker false
hassio false
installation_type Home Assistant Core
os_name Darwin
os_version 10.14.6
python_version 3.7.7
timezone America/Los_Angeles
version 0.111.4
virtualenv true

Problem-relevant configuration.yaml

totalconnect:
    username: <xxx>
    password: <xxx>

Traceback/Error logs

N/A

Additional information

probot-home-assistant[bot] commented 4 years ago

Hey there @austinmroczek, mind taking a look at this issue as its been labeled with an integration (totalconnect) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

austinmroczek commented 4 years ago

Hope to look at this tomorrow. It is a polling system so will not be the most timely, but 60 seconds is higher than average.

On Jul 1, 2020, at 5:58 PM, probot-home-assistant[bot] notifications@github.com wrote:

 Hey there @austinmroczek, mind taking a look at this issue as its been labeled with an integration (totalconnect) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

austinmroczek commented 4 years ago

@trevorcortez a few questions for you:

a) Have you been using Home Assistant with TotalConnect for a while and this delay has always been generally the same, or have you seen an increase since upgrading to 0.111.4 ?

b) How many sensors/zones do you have? Folks with larger systems tend to take longer to update.

c) Are the delays basically the same again today? The TotalConnect service sometimes has "bad days" and is slow for everyone. I'll check my own logs and see if yesterday appears to be such a day.

trevorcortez commented 4 years ago

Thanks a lot for taking a look!

a) I've been using Home Assistant a few years, but only just setup TotalConnect Alarm to it. My experience with other online connected plugins (Rachio, iAqualink) has been shorter delays, so I figured I'd ask in case I've misconfigured something.

b) I have 31 zones

c) Looks the same this morning, and it also looks like many events are dropped, presumably because the state toggled to something and back in-between polls? Maybe the motions sensors are too noisy? It does look excessive…

Here's a dump of events from TC Screen Shot 2020-07-03 at 9 59 55 AM

(note the events are duplicated to a similarly named sensor because I'm using template sensors to bridge nicer to HomeKit)

…and the same from the logbook in HA:

https://pastebin.com/TFmHb91Y

austinmroczek commented 4 years ago

The integration is requesting an update for the state of your alarm panel and zones at the standard scan interval for Home Assistant, which I believe is 30 seconds. So on average you're looking at a 15 second delay there.

Add on to that the time it takes to communicate with the TotalConnect server and process the info. TotalConnect doesn't have great documentation, including any estimates of timeliness. For my system it seems to be 5-10 seconds most of the time, but sometimes more like 20 or 30.

We recently added the ability to record that time in the underlying TotalConnectClient, but it's not tied into Home Assistant right now. If you want to check out your system times, follow the Troubleshooting instructions at https://github.com/craigjmidwinter/total-connect-client

So a total time between actual change at the sensor, and it showing up in Home Assistant would be an average of 22.5 seconds (using my average time for TotalConnect) with a range of 5 to 60.

As you discussed, you'll miss any changes that happen between updates.

Decreasing the scan interval is a possible solution, however I believe it is not recommended (can't find the link to discussion at the moment) by Home Assistant. We'd also have to test TotalConnect to see if their server can handle it, because there is no documentation or even a good point of contact for developers.

To resolve this issue I'm suggesting that I update the documentation at https://www.home-assistant.io/integrations/totalconnect to discuss the timeline issue so user better know what to expect.

trevorcortez commented 4 years ago

Thanks for the details. Was skimming the docs here: https://rs.alarmnet.com/TC21api/tc2.asmx

Maybe an alternative implementation could:

or

GetAllLiveEvents Returns a set of device event records. A maximum of 250 records can be returned per call. The parameter LastEventIdReceived is used to retreive newer records than the ones previously obtained. Entering the most recent event id into this field will return all records that are newer than that record

…which seems to be more efficient than retrieving status for all zones at all times. Depending on how expensive that method is, it might return faster and be able to handle more Then you'd just need to update the zones. I'll post an issue over in the total-connect-client repo to request something like that.

stale[bot] commented 4 years ago

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 now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.