Skip to content

Commit

Permalink
set timeout on socket connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh committed Oct 24, 2024
1 parent e1a7e4d commit 096f74f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion custom_components/omnik/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
_LOGGER = logging.getLogger(__name__)

DEFAULT_PORT_INVERTER = 8899
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=1)
MIN_TIME_BETWEEN_UPDATES = timedelta(seconds=5)

CONF_INVERTER_HOST = 'inverter_host'
CONF_INVERTER_PORT = 'inverter_port'
Expand Down Expand Up @@ -324,6 +324,7 @@ def get_statistics(self):
""" Create a socket (SOCK_STREAM means a TCP socket). """
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(3)
except:
sock = None

Expand Down

0 comments on commit 096f74f

Please sign in to comment.