Polling TCP Sensor with adjustable interval

Hi everyone,
I’m currently reading some value with the TCP Sensor platform and it works nice, but it’s possible to adjust the polling interval?
I’ve made some basic math and discovered that it polls it by default every 30 seconds.
Screenshot_39
For some internet polling this is more than enough, but for local polling it would be nice to set this (much) lower.

It would be awesome if someone could add a custom key to set the interval freely.

Maybe it’s possible and the platform documentation doesn’t mentions it, if so, can somebody tell me it that’s already possible?

A valid reason for that would be a TCP sensor integrated into a more sensible environiment, such as a cooking stove or something like that, where 30 seconds could be too a too large interval.

Thanks in advance.

Yes. Just add scan_interval to the platform configuration. It’s a time period parameter, so, for example, you could do:

sensor:
  - template: tcp
    ...
    scan_interval:
      seconds: 5

Thank you so much.

I guess it’s missing in the platform documentation then.

I’ll edit the documentation later for future readers…

Yeah, not sure how I found this out. It might be somewhere in the docs (they’re hard to search), or I might have found it while I was writing some custom components.

I’ve proposed a file change and included a example too.
https://github.com/home-assistant/home-assistant.io/commit/1536d4a5d5239b4d741326bc7f4af52acbdee4bb

It is/was already documented

But it should also be documented in the platform documentation itself.

A lot of readers will think that it doesn’t support the scan_interval paramenter, because it’s not there, including me.

Agreed. I actually answered this same question twice in the last couple of days. I knew I had read about scan_interval somewhere, but I came up empty even when I searched for it. Now that @metbril points out the page, I’m not sure how I missed it. But, still, I think it would make it easier for users if platform documentation made note of it, and defined what its default scan interval is (because platform code can override the component’s default.)

1 Like