Skip to content

Commit

Permalink
update sensor.py
Browse files Browse the repository at this point in the history
- omit update values if getting values from inverter fails
- set timeout on getting values
  • Loading branch information
PierreLevres authored Jul 8, 2021
1 parent 8340be2 commit 4cf5401
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions custom_components/omnik/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import sys

# VERSION
VERSION = '0.0.5'
VERSION = '0.0.6'

BASE_URL = 'http://{0}:{1}{2}'

Expand Down Expand Up @@ -252,7 +252,7 @@ def update(self):
self.get_statistics()

""" Retrieve the data values for the sensors. """
self.update_sensor_values()
if self.interface_inverter.raw_msg is not None: self.update_sensor_values()

class OmnikInverter():
""" Class with function for reading data from the Omnik inverter. """
Expand Down Expand Up @@ -304,6 +304,7 @@ def get_statistics(self):

try:
""" Connect to server and send data. """
sock.settimeout(10)
sock.connect((self._host, self._port))
sock.sendall(OmnikInverter.generate_request(self._serial_number))

Expand Down

0 comments on commit 4cf5401

Please sign in to comment.