petretiandrea / home-assistant-tapo-p100

A custom integration to control Tapo devices from home assistant.
MIT License
818 stars 102 forks source link

changing the polling frequency for the h100 hub doesn't have any effect on paired T110 contact sensors #665

Open ChakraFusion opened 10 months ago

ChakraFusion commented 10 months ago

If I open a window in my room (with T110 contact sensor) or my door (also T110 contact sensor) I want all the lights in my room to turn off. So far the automation is working very good. The only problem is the delay of the sensors connected to the H100 Hub. The delay is mostly 20 to 30 seconds. Changing the polling time of the H100 Hub in the Tapo integration configuration from 30 to 3s also results in no changes in the reaction time for the T110 sensors. The Report interval of both contact sensors stays steadily at 16s (displayed in HA). And the real reaction time stays at 30s. I need a low reaction time of under 2 seconds for the contact sensor on my door because otherwise HA doesn't even register any change of state if I leave my room.

Is there any setting which directly modifies the polling time for the T110 sensors?

For others reading this and having the same problem: My workaround so far is to have the official Tapo App change one led in my room to a specific color as soon as the T110 registers a change and then use the rgb color change of this lamp (with reduced polling time to 3s in the HA Tapo Integration) as a trigger for my automation. The polling time change works for the L530 leds in my case.

I don't know if you need any logs for this, because there shouldn't be much to see other than the polling time of the contact sensors not changing. If you're reading this, thank you for your time and support.

Ian-Harriy commented 10 months ago

I'm not sure this is the right place to comment ,I am experiencing the exact same issue, I'm using the T110 sensor to activate a seen when my door opens and I also need a 2 second reaction time. Thank you for the effort you put into this product.

matheuscanela commented 10 months ago

Same here - any workaround?

MrG30rge commented 10 months ago

Same here.

I also receive a lot of "became unavailable" status for all T110 and T100. When I check the HA logs I find this API error:

This error originated from a custom integration.

Logger: custom_components.tapo.coordinators Source: helpers/update_coordinator.py:332 Integration: TP-Link Tapo (documentation, issues) First occurred: 9:26:17 AM (30 occurrences) Last logged: 10:06:39 AM

Error fetching tapo data: Error communication with API: [Errno 104] Connection reset by peer Error fetching tapo data: Unexpected exception: Error fetching tapo data: Error communication with API: Cannot connect to host 192.168.13.191:80 ssl:default [Connect call failed ('192.168.13.191', 80)]

ChakraFusion commented 10 months ago

Same here - any workaround?

I described my workaround (using a Tapo Lamp colour change) in my original post. You can use that if you can.

matheuscanela commented 10 months ago

My problem is that I am using the Tapo sensor to activate a light from another system :(

matheuscanela commented 10 months ago

@petretiandrea any idea where it would be in the code? I can try to fix.

ChakraFusion commented 10 months ago

My problem is that I am using the Tapo sensor to activate a light from another system :(

I understand. Sorry for assuming your light manufacturer. 😂 That is unfortunate then. I just wish the Tapo Hub Events would trigger as reliable as with the stock Tapo App. But I know about the technical issues with this.

petretiandrea commented 10 months ago

The problem is the same of buttons https://github.com/petretiandrea/home-assistant-tapo-p100/issues/556. There is no event stream for sensor, but only polling. Polling too frequently means making DOS to your hub. Actually I don't have an alternative way of polling.

matheuscanela commented 10 months ago

Gotcha

I haven't check the other issue as I am not in front of my computer, but where can we change the default settings? I think it is set to 16s right? I tried to change through console and it didn't work

Happy to test with a sort time as I don't have many devices anyway, so it should not impact the performance or DDoS the device

ninosnicolaou commented 9 months ago

@petretiandrea I get what you are saying! In my case is kind of critical since I am using motion and contact sensors for alarm system. If i set a high refresh interval (say >5 seconds) It could be the case of the door opening and quickly closing before the 5 seconds elapsed and the HA won't know that the door was opened, hence alarm will not be triggered. If i set the refresh interval too low (say <3 seconds) I frequently get sensor states "unavailable" possibly because i am "DoS" the hub. Since there is no solution yet, do you have anything to propose? I found that around 4 seconds is pretty reliable for me, but i still think it's kind of high for alarm purposes.

matheuscanela commented 9 months ago

@ninosnicolaou how did you change the interval?

ninosnicolaou commented 9 months ago

@ninosnicolaou how did you change the interval?

image

matheuscanela commented 9 months ago

oh! I actually was trying to change the sensor settings, which is limited to 16s, let me try, thanks!

ninosnicolaou commented 9 months ago

I "fixed" my issue. So I removed all my sensors from TP-Link Tapo integration and managed to get them into the Matter (beta) integration. Basically in Tapo App (due to a recent update) I am able to add H100 hub in HomeKit (as i bridge i think, natively supported by Tapo). Now in iOS Home app I have the H100 as a bridge.

I then tried Matter (Beta) HASS integration and using the iOS companion app I was able to add the H100 in HASS as well. Now the response is instant (like truly instant) and since I am not using this integration I am not polling the H100 continuously, all the timeouts and sensors being unavailable is no longer a problem.

However, i still use this integration to be able to have the hub.siren entity (and trigger in case of alarm) since it's not supported in Matter (Beta) integration.

image

image

mtp-24 commented 9 months ago

@ninosnicolaou do the smart buttons work in the Matter Beta integration (single tap/double tap/rotate cw/rotate ccw)? And if the do, do they work in HomeKit and HA?

ninosnicolaou commented 9 months ago

@ninosnicolaou do the smart buttons work in the Matter Beta integration (single tap/double tap/rotate cw/rotate ccw)? And if the do, do they work in HomeKit and HA?

Homekit: Doesn't work (not supported by Tapo yet)

Homeassistant: No controls/entities available, so no, they don't work

doenau commented 9 months ago

I then tried Matter (Beta) HASS integration and using the iOS companion app I was able to add the H100 in HASS as well. Now the response is instant (like truly instant) and since I am not using this integration I am not polling the H100 continuously, all the timeouts and sensors being unavailable is no longer a problem.

Agreed - I've now done this as well and the response is instant with a T100 motion sensor changing stated to 'Detected' What's frustrating me though, is that it doesn't seem to Clear the occupancy until 1 minute later. Looking at the Tapo IOS app, it is constantly maintains the 'detected' state as detected every 4 seconds (update interval) but there doesn't appear to be an update anywhere to change it to Clear. Nothing I do reduces this to less than a minute. I tried changing the refresh time in the tapo integraton, but that doesn't change anything either.

So it appears that the Tapo T100 or the Hub only update/report the Clear status 1 minute after the last Detected event. @ninosnicolaou does it update your contact sensors to both Open and Closed instantly? Or do you think my problem just motion sensor specific?

ninosnicolaou commented 9 months ago

Mine as well keeps the same state for 1 minute. But this was the case with Tapo integration as well. I think it's a hassio thing to be honest. Also I think you misunderstood the concept of motion sensors, they are not like contact sensors (no instant on/off state)

Homeassistant has 2 types of "motion sensors" in my understanding.

Take a look at these. I am also new to hassio so take everything with a grain of salt!

doenau commented 9 months ago

Mine as well keeps the same state for 1 minute. But this was the case with Tapo integration as well. I think it's a hassio thing to be honest. Also I think you misunderstood the concept of motion sensors, they are not like contact sensors (no instant on/off state)

Homeassistant has 2 types of "motion sensors" in my understanding.

  • Motion entity
  • Occupancy entity

Take a look at these. I am also new to hassio so take everything with a grain of salt!

No problem. Yes I realise they may not work exactly the same as contact sensors. I would have thought though, seeing as the Tapo app shows a 'Detected' log every 4 seconds, that it also knows when it is not in the 'Detected' state and so that info should be available to users. FYI using the Tapo integration they are seen as a Motion entity (with the battery and report interval entities), but using Matter they are an Occupancy entity only. Aside from that they appear to operate essentially the same, but with Matter I get the 'Detected' state faster.

ninosnicolaou commented 9 months ago

@doenau You can chance occupancy with motion and vice versa