TCP test to work offline

This commit is contained in:
Paulus Schoutsen committed 2016-03-05 09:27:22 -08:00
1 parent d30fb7f04a
commit 41214fd082
3 files changed
+24 -18

No files matched your search

+1
View File
@@ -90,6 +90,7 @@ class Sensor(Entity):
def update(self):
"""Get the latest value for this sensor."""
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
sock.settimeout(self._config[CONF_TIMEOUT])
try:
sock.connect(
(self._config[CONF_HOST], self._config[CONF_PORT]))