Skip to content

Commit

Permalink
Fix broken request to zeroconf/getState #1442
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed Sep 7, 2024
1 parent a34a5a2 commit 76ad969
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions custom_components/sonoff/core/ewelink/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from Crypto.Cipher import AES
from Crypto.Hash import MD5
from Crypto.Random import get_random_bytes
from aiohttp.hdrs import CONTENT_TYPE
from zeroconf import Zeroconf, ServiceStateChange
from zeroconf.asyncio import AsyncServiceBrowser, AsyncServiceInfo

Expand Down Expand Up @@ -202,6 +203,11 @@ async def send(
)

try:
# some devices don't support getState command
# https://github.com/AlexxIT/SonoffLAN/issues/1442
if command == "getState" and r.headers.get(CONTENT_TYPE) == "text/html":
return "online"

resp: dict = await r.json()
if resp["error"] == 0:
_LOGGER.debug(f"{log} <= {resp}")
Expand Down

0 comments on commit 76ad969

Please sign in to comment.