Skip to content

Commit

Permalink
Update vedo sensor support to match web panel logic
Browse files Browse the repository at this point in the history
  • Loading branch information
pbartolome authored and gicamm committed Nov 14, 2024
1 parent b039860 commit b44b3d7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions custom_components/comelit/vedo.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ def build_http(self, headers, uid, path):

# Do the GET from the vedo IP
@timeout(DEFAULT_TIMEOUT, use_signals=True)
def get(self, uid, path, is_response):
def get(self, uid, path, is_response):
_LOGGER.info(f"Running GET with uid {uid}, path {path}")
url, headers = self.build_http(None, uid, path)
_LOGGER.info(f"GET: url {url}, headers {headers}")
response = requests.get(url, headers=headers, timeout=DEFAULT_TIMEOUT)
response.raise_for_status()
text = response.text
text = response.content.decode('iso-8859-1').encode('utf-8')
if is_response:
payload = json.loads(text)
return payload
Expand Down Expand Up @@ -156,7 +156,8 @@ def update_sensor(self, s):
try:
id = s["id"]
name = s["name"]
if s["status"] == "0011":
zone_status = int(s["status"], 16)
if (zone_status & 1) != 0:
state = STATE_ON
else:
state = STATE_OFF
Expand Down Expand Up @@ -248,7 +249,7 @@ def run(self):
if value == 'Not logged':
raise CookieException("cookie expired")

if value > 1:
if value != 0:
sensor_dict = {"index": i, "id": i, "name": description[i], "status": zone_statuses[i]}
_LOGGER.debug(f"Updating the zone {sensor_dict}")
sensors.append(sensor_dict)
Expand Down

0 comments on commit b44b3d7

Please sign in to comment.