Merge of nested IF-IF cases - E-G (#48367)

This commit is contained in:
Franck Nijhof 2021-03-27 12:39:37 +01:00 committed by GitHub
parent 786023fce4
commit 0d595a2845
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 257 additions and 246 deletions

View File

@ -115,8 +115,7 @@ class EbusdData:
try: try:
_LOGGER.debug("Opening socket to ebusd %s", name) _LOGGER.debug("Opening socket to ebusd %s", name)
command_result = ebusdpy.write(self._address, self._circuit, name, value) command_result = ebusdpy.write(self._address, self._circuit, name, value)
if command_result is not None: if command_result is not None and "done" not in command_result:
if "done" not in command_result: _LOGGER.warning("Write command failed: %s", name)
_LOGGER.warning("Write command failed: %s", name)
except RuntimeError as err: except RuntimeError as err:
_LOGGER.error(err) _LOGGER.error(err)

View File

@ -170,10 +170,13 @@ class Monitor:
) )
for dev in self.devices: for dev in self.devices:
if dev.namespace == namespace and dev.instance == instance: if (
if dev.temperature != temperature: dev.namespace == namespace
dev.temperature = temperature and dev.instance == instance
dev.schedule_update_ha_state() and dev.temperature != temperature
):
dev.temperature = temperature
dev.schedule_update_ha_state()
def stop(self): def stop(self):
"""Signal runner to stop and join thread.""" """Signal runner to stop and join thread."""

View File

@ -96,12 +96,13 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
active_emby_devices[dev_id] = new active_emby_devices[dev_id] = new
new_devices.append(new) new_devices.append(new)
elif dev_id in inactive_emby_devices: elif (
if emby.devices[dev_id].state != "Off": dev_id in inactive_emby_devices and emby.devices[dev_id].state != "Off"
add = inactive_emby_devices.pop(dev_id) ):
active_emby_devices[dev_id] = add add = inactive_emby_devices.pop(dev_id)
_LOGGER.debug("Showing %s, item: %s", dev_id, add) active_emby_devices[dev_id] = add
add.set_available(True) _LOGGER.debug("Showing %s, item: %s", dev_id, add)
add.set_available(True)
if new_devices: if new_devices:
_LOGGER.debug("Adding new devices: %s", new_devices) _LOGGER.debug("Adding new devices: %s", new_devices)

View File

@ -92,13 +92,11 @@ def setup_platform(hass, config, add_entities, discovery_info=None):
for elem in data.data: for elem in data.data:
if exclude_feeds is not None: if exclude_feeds is not None and int(elem["id"]) in exclude_feeds:
if int(elem["id"]) in exclude_feeds: continue
continue
if include_only_feeds is not None: if include_only_feeds is not None and int(elem["id"]) not in include_only_feeds:
if int(elem["id"]) not in include_only_feeds: continue
continue
name = None name = None
if sensor_names is not None: if sensor_names is not None:

View File

@ -439,11 +439,13 @@ class HueOneLightChangeView(HomeAssistantView):
# saturation and color temp # saturation and color temp
if entity.domain == light.DOMAIN: if entity.domain == light.DOMAIN:
if parsed[STATE_ON]: if parsed[STATE_ON]:
if entity_features & SUPPORT_BRIGHTNESS: if (
if parsed[STATE_BRIGHTNESS] is not None: entity_features & SUPPORT_BRIGHTNESS
data[ATTR_BRIGHTNESS] = hue_brightness_to_hass( and parsed[STATE_BRIGHTNESS] is not None
parsed[STATE_BRIGHTNESS] ):
) data[ATTR_BRIGHTNESS] = hue_brightness_to_hass(
parsed[STATE_BRIGHTNESS]
)
if entity_features & SUPPORT_COLOR: if entity_features & SUPPORT_COLOR:
if any((parsed[STATE_HUE], parsed[STATE_SATURATION])): if any((parsed[STATE_HUE], parsed[STATE_SATURATION])):
@ -466,13 +468,17 @@ class HueOneLightChangeView(HomeAssistantView):
if parsed[STATE_XY] is not None: if parsed[STATE_XY] is not None:
data[ATTR_XY_COLOR] = parsed[STATE_XY] data[ATTR_XY_COLOR] = parsed[STATE_XY]
if entity_features & SUPPORT_COLOR_TEMP: if (
if parsed[STATE_COLOR_TEMP] is not None: entity_features & SUPPORT_COLOR_TEMP
data[ATTR_COLOR_TEMP] = parsed[STATE_COLOR_TEMP] and parsed[STATE_COLOR_TEMP] is not None
):
data[ATTR_COLOR_TEMP] = parsed[STATE_COLOR_TEMP]
if entity_features & SUPPORT_TRANSITION: if (
if parsed[STATE_TRANSITON] is not None: entity_features & SUPPORT_TRANSITION
data[ATTR_TRANSITION] = parsed[STATE_TRANSITON] / 10 and parsed[STATE_TRANSITON] is not None
):
data[ATTR_TRANSITION] = parsed[STATE_TRANSITON] / 10
# If the requested entity is a script, add some variables # If the requested entity is a script, add some variables
elif entity.domain == script.DOMAIN: elif entity.domain == script.DOMAIN:
@ -489,11 +495,13 @@ class HueOneLightChangeView(HomeAssistantView):
# only setting the temperature # only setting the temperature
service = None service = None
if entity_features & SUPPORT_TARGET_TEMPERATURE: if (
if parsed[STATE_BRIGHTNESS] is not None: entity_features & SUPPORT_TARGET_TEMPERATURE
domain = entity.domain and parsed[STATE_BRIGHTNESS] is not None
service = SERVICE_SET_TEMPERATURE ):
data[ATTR_TEMPERATURE] = parsed[STATE_BRIGHTNESS] domain = entity.domain
service = SERVICE_SET_TEMPERATURE
data[ATTR_TEMPERATURE] = parsed[STATE_BRIGHTNESS]
# If the requested entity is a humidifier, set the humidity # If the requested entity is a humidifier, set the humidity
elif entity.domain == humidifier.DOMAIN: elif entity.domain == humidifier.DOMAIN:
@ -505,43 +513,48 @@ class HueOneLightChangeView(HomeAssistantView):
# If the requested entity is a media player, convert to volume # If the requested entity is a media player, convert to volume
elif entity.domain == media_player.DOMAIN: elif entity.domain == media_player.DOMAIN:
if entity_features & SUPPORT_VOLUME_SET: if (
if parsed[STATE_BRIGHTNESS] is not None: entity_features & SUPPORT_VOLUME_SET
turn_on_needed = True and parsed[STATE_BRIGHTNESS] is not None
domain = entity.domain ):
service = SERVICE_VOLUME_SET turn_on_needed = True
# Convert 0-100 to 0.0-1.0 domain = entity.domain
data[ATTR_MEDIA_VOLUME_LEVEL] = parsed[STATE_BRIGHTNESS] / 100.0 service = SERVICE_VOLUME_SET
# Convert 0-100 to 0.0-1.0
data[ATTR_MEDIA_VOLUME_LEVEL] = parsed[STATE_BRIGHTNESS] / 100.0
# If the requested entity is a cover, convert to open_cover/close_cover # If the requested entity is a cover, convert to open_cover/close_cover
elif entity.domain == cover.DOMAIN: elif entity.domain == cover.DOMAIN:
domain = entity.domain domain = entity.domain
service = SERVICE_CLOSE_COVER
if service == SERVICE_TURN_ON: if service == SERVICE_TURN_ON:
service = SERVICE_OPEN_COVER service = SERVICE_OPEN_COVER
else:
service = SERVICE_CLOSE_COVER
if entity_features & SUPPORT_SET_POSITION: if (
if parsed[STATE_BRIGHTNESS] is not None: entity_features & SUPPORT_SET_POSITION
domain = entity.domain and parsed[STATE_BRIGHTNESS] is not None
service = SERVICE_SET_COVER_POSITION ):
data[ATTR_POSITION] = parsed[STATE_BRIGHTNESS] domain = entity.domain
service = SERVICE_SET_COVER_POSITION
data[ATTR_POSITION] = parsed[STATE_BRIGHTNESS]
# If the requested entity is a fan, convert to speed # If the requested entity is a fan, convert to speed
elif entity.domain == fan.DOMAIN: elif (
if entity_features & SUPPORT_SET_SPEED: entity.domain == fan.DOMAIN
if parsed[STATE_BRIGHTNESS] is not None: and entity_features & SUPPORT_SET_SPEED
domain = entity.domain and parsed[STATE_BRIGHTNESS] is not None
# Convert 0-100 to a fan speed ):
brightness = parsed[STATE_BRIGHTNESS] domain = entity.domain
if brightness == 0: # Convert 0-100 to a fan speed
data[ATTR_SPEED] = SPEED_OFF brightness = parsed[STATE_BRIGHTNESS]
elif 0 < brightness <= 33.3: if brightness == 0:
data[ATTR_SPEED] = SPEED_LOW data[ATTR_SPEED] = SPEED_OFF
elif 33.3 < brightness <= 66.6: elif 0 < brightness <= 33.3:
data[ATTR_SPEED] = SPEED_MEDIUM data[ATTR_SPEED] = SPEED_LOW
elif 66.6 < brightness <= 100: elif 33.3 < brightness <= 66.6:
data[ATTR_SPEED] = SPEED_HIGH data[ATTR_SPEED] = SPEED_MEDIUM
elif 66.6 < brightness <= 100:
data[ATTR_SPEED] = SPEED_HIGH
# Map the off command to on # Map the off command to on
if entity.domain in config.off_maps_to_on_domains: if entity.domain in config.off_maps_to_on_domains:

View File

@ -90,9 +90,11 @@ class BanSensor(SensorEntity):
if len(self.ban_dict[STATE_ALL_BANS]) > 10: if len(self.ban_dict[STATE_ALL_BANS]) > 10:
self.ban_dict[STATE_ALL_BANS].pop(0) self.ban_dict[STATE_ALL_BANS].pop(0)
elif entry[0] == "Unban": elif (
if current_ip in self.ban_dict[STATE_CURRENT_BANS]: entry[0] == "Unban"
self.ban_dict[STATE_CURRENT_BANS].remove(current_ip) and current_ip in self.ban_dict[STATE_CURRENT_BANS]
):
self.ban_dict[STATE_CURRENT_BANS].remove(current_ip)
if self.ban_dict[STATE_CURRENT_BANS]: if self.ban_dict[STATE_CURRENT_BANS]:
self.last_ban = self.ban_dict[STATE_CURRENT_BANS][-1] self.last_ban = self.ban_dict[STATE_CURRENT_BANS][-1]

View File

@ -459,9 +459,8 @@ class FanEntity(ToggleEntity):
@property @property
def percentage(self) -> int | None: def percentage(self) -> int | None:
"""Return the current speed as a percentage.""" """Return the current speed as a percentage."""
if not self._implemented_preset_mode: if not self._implemented_preset_mode and self.speed in self.preset_modes:
if self.speed in self.preset_modes: return None
return None
if not self._implemented_percentage: if not self._implemented_percentage:
return self.speed_to_percentage(self.speed) return self.speed_to_percentage(self.speed)
return 0 return 0

View File

@ -120,9 +120,8 @@ class GaradgetCover(CoverEntity):
def __del__(self): def __del__(self):
"""Try to remove token.""" """Try to remove token."""
if self._obtained_token is True: if self._obtained_token is True and self.access_token is not None:
if self.access_token is not None: self.remove_token()
self.remove_token()
@property @property
def name(self): def name(self):
@ -239,10 +238,12 @@ class GaradgetCover(CoverEntity):
) )
self._state = STATE_OFFLINE self._state = STATE_OFFLINE
if self._state not in [STATE_CLOSING, STATE_OPENING]: if (
if self._unsub_listener_cover is not None: self._state not in [STATE_CLOSING, STATE_OPENING]
self._unsub_listener_cover() and self._unsub_listener_cover is not None
self._unsub_listener_cover = None ):
self._unsub_listener_cover()
self._unsub_listener_cover = None
def _get_variable(self, var): def _get_variable(self, var):
"""Get latest status.""" """Get latest status."""

View File

@ -442,28 +442,27 @@ class GenericThermostat(ClimateEntity, RestoreEntity):
if not self._active or self._hvac_mode == HVAC_MODE_OFF: if not self._active or self._hvac_mode == HVAC_MODE_OFF:
return return
if not force and time is None: # If the `force` argument is True, we
# If the `force` argument is True, we # ignore `min_cycle_duration`.
# ignore `min_cycle_duration`. # If the `time` argument is not none, we were invoked for
# If the `time` argument is not none, we were invoked for # keep-alive purposes, and `min_cycle_duration` is irrelevant.
# keep-alive purposes, and `min_cycle_duration` is irrelevant. if not force and time is None and self.min_cycle_duration:
if self.min_cycle_duration: if self._is_device_active:
if self._is_device_active: current_state = STATE_ON
current_state = STATE_ON else:
else: current_state = HVAC_MODE_OFF
current_state = HVAC_MODE_OFF try:
try: long_enough = condition.state(
long_enough = condition.state( self.hass,
self.hass, self.heater_entity_id,
self.heater_entity_id, current_state,
current_state, self.min_cycle_duration,
self.min_cycle_duration, )
) except ConditionError:
except ConditionError: long_enough = False
long_enough = False
if not long_enough: if not long_enough:
return return
too_cold = self._target_temp >= self._cur_temp + self._cold_tolerance too_cold = self._target_temp >= self._cur_temp + self._cold_tolerance
too_hot = self._cur_temp >= self._target_temp + self._hot_tolerance too_hot = self._cur_temp >= self._target_temp + self._hot_tolerance

View File

@ -17,45 +17,44 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for sensor_type, sensor_details in SENSOR_TYPES.items(): for sensor_type, sensor_details in SENSOR_TYPES.items():
if sensor_details[0] not in client.api.data: if sensor_details[0] not in client.api.data:
continue continue
if sensor_details[0] in client.api.data: if sensor_details[0] == "fs":
if sensor_details[0] == "fs": # fs will provide a list of disks attached
# fs will provide a list of disks attached for disk in client.api.data[sensor_details[0]]:
for disk in client.api.data[sensor_details[0]]:
dev.append(
GlancesSensor(
client,
name,
disk["mnt_point"],
SENSOR_TYPES[sensor_type][1],
sensor_type,
SENSOR_TYPES[sensor_type],
)
)
elif sensor_details[0] == "sensors":
# sensors will provide temp for different devices
for sensor in client.api.data[sensor_details[0]]:
if sensor["type"] == sensor_type:
dev.append(
GlancesSensor(
client,
name,
sensor["label"],
SENSOR_TYPES[sensor_type][1],
sensor_type,
SENSOR_TYPES[sensor_type],
)
)
elif client.api.data[sensor_details[0]]:
dev.append( dev.append(
GlancesSensor( GlancesSensor(
client, client,
name, name,
"", disk["mnt_point"],
SENSOR_TYPES[sensor_type][1], SENSOR_TYPES[sensor_type][1],
sensor_type, sensor_type,
SENSOR_TYPES[sensor_type], SENSOR_TYPES[sensor_type],
) )
) )
elif sensor_details[0] == "sensors":
# sensors will provide temp for different devices
for sensor in client.api.data[sensor_details[0]]:
if sensor["type"] == sensor_type:
dev.append(
GlancesSensor(
client,
name,
sensor["label"],
SENSOR_TYPES[sensor_type][1],
sensor_type,
SENSOR_TYPES[sensor_type],
)
)
elif client.api.data[sensor_details[0]]:
dev.append(
GlancesSensor(
client,
name,
"",
SENSOR_TYPES[sensor_type][1],
sensor_type,
SENSOR_TYPES[sensor_type],
)
)
async_add_entities(dev, True) async_add_entities(dev, True)
@ -139,107 +138,103 @@ class GlancesSensor(SensorEntity):
if value is None: if value is None:
return return
if value is not None: if self.sensor_details[0] == "fs":
if self.sensor_details[0] == "fs": for var in value["fs"]:
for var in value["fs"]: if var["mnt_point"] == self._sensor_name_prefix:
if var["mnt_point"] == self._sensor_name_prefix: disk = var
disk = var break
break if self.type == "disk_free":
if self.type == "disk_use_percent":
self._state = disk["percent"]
elif self.type == "disk_use":
self._state = round(disk["used"] / 1024 ** 3, 1)
elif self.type == "disk_free":
try:
self._state = round(disk["free"] / 1024 ** 3, 1)
except KeyError:
self._state = round(
(disk["size"] - disk["used"]) / 1024 ** 3,
1,
)
elif self.type == "battery":
for sensor in value["sensors"]:
if sensor["type"] == "battery":
if sensor["label"] == self._sensor_name_prefix:
self._state = sensor["value"]
elif self.type == "fan_speed":
for sensor in value["sensors"]:
if sensor["type"] == "fan_speed":
if sensor["label"] == self._sensor_name_prefix:
self._state = sensor["value"]
elif self.type == "temperature_core":
for sensor in value["sensors"]:
if sensor["type"] == "temperature_core":
if sensor["label"] == self._sensor_name_prefix:
self._state = sensor["value"]
elif self.type == "temperature_hdd":
for sensor in value["sensors"]:
if (
sensor["type"] == "temperature_hdd"
and sensor["label"] == self._sensor_name_prefix
):
self._state = sensor["value"]
elif self.type == "memory_use_percent":
self._state = value["mem"]["percent"]
elif self.type == "memory_use":
self._state = round(value["mem"]["used"] / 1024 ** 2, 1)
elif self.type == "memory_free":
self._state = round(value["mem"]["free"] / 1024 ** 2, 1)
elif self.type == "swap_use_percent":
self._state = value["memswap"]["percent"]
elif self.type == "swap_use":
self._state = round(value["memswap"]["used"] / 1024 ** 3, 1)
elif self.type == "swap_free":
self._state = round(value["memswap"]["free"] / 1024 ** 3, 1)
elif self.type == "processor_load":
# Windows systems don't provide load details
try: try:
self._state = value["load"]["min15"] self._state = round(disk["free"] / 1024 ** 3, 1)
except KeyError: except KeyError:
self._state = value["cpu"]["total"] self._state = round(
elif self.type == "process_running": (disk["size"] - disk["used"]) / 1024 ** 3,
self._state = value["processcount"]["running"] 1,
elif self.type == "process_total": )
self._state = value["processcount"]["total"] elif self.type == "disk_use":
elif self.type == "process_thread": self._state = round(disk["used"] / 1024 ** 3, 1)
self._state = value["processcount"]["thread"] elif self.type == "disk_use_percent":
elif self.type == "process_sleeping": self._state = disk["percent"]
self._state = value["processcount"]["sleeping"] elif self.type == "battery":
elif self.type == "cpu_use_percent": for sensor in value["sensors"]:
self._state = value["quicklook"]["cpu"] if (
elif self.type == "docker_active": sensor["type"] == "battery"
count = 0 and sensor["label"] == self._sensor_name_prefix
try: ):
for container in value["docker"]["containers"]: self._state = sensor["value"]
if ( elif self.type == "fan_speed":
container["Status"] == "running" for sensor in value["sensors"]:
or "Up" in container["Status"] if (
): sensor["type"] == "fan_speed"
count += 1 and sensor["label"] == self._sensor_name_prefix
self._state = count ):
except KeyError: self._state = sensor["value"]
self._state = count elif self.type == "temperature_core":
elif self.type == "docker_cpu_use": for sensor in value["sensors"]:
cpu_use = 0.0 if (
try: sensor["type"] == "temperature_core"
for container in value["docker"]["containers"]: and sensor["label"] == self._sensor_name_prefix
if ( ):
container["Status"] == "running" self._state = sensor["value"]
or "Up" in container["Status"] elif self.type == "temperature_hdd":
): for sensor in value["sensors"]:
cpu_use += container["cpu"]["total"] if (
self._state = round(cpu_use, 1) sensor["type"] == "temperature_hdd"
except KeyError: and sensor["label"] == self._sensor_name_prefix
self._state = STATE_UNAVAILABLE ):
elif self.type == "docker_memory_use": self._state = sensor["value"]
mem_use = 0.0 elif self.type == "memory_use_percent":
try: self._state = value["mem"]["percent"]
for container in value["docker"]["containers"]: elif self.type == "memory_use":
if ( self._state = round(value["mem"]["used"] / 1024 ** 2, 1)
container["Status"] == "running" elif self.type == "memory_free":
or "Up" in container["Status"] self._state = round(value["mem"]["free"] / 1024 ** 2, 1)
): elif self.type == "swap_use_percent":
mem_use += container["memory"]["usage"] self._state = value["memswap"]["percent"]
self._state = round(mem_use / 1024 ** 2, 1) elif self.type == "swap_use":
except KeyError: self._state = round(value["memswap"]["used"] / 1024 ** 3, 1)
self._state = STATE_UNAVAILABLE elif self.type == "swap_free":
self._state = round(value["memswap"]["free"] / 1024 ** 3, 1)
elif self.type == "processor_load":
# Windows systems don't provide load details
try:
self._state = value["load"]["min15"]
except KeyError:
self._state = value["cpu"]["total"]
elif self.type == "process_running":
self._state = value["processcount"]["running"]
elif self.type == "process_total":
self._state = value["processcount"]["total"]
elif self.type == "process_thread":
self._state = value["processcount"]["thread"]
elif self.type == "process_sleeping":
self._state = value["processcount"]["sleeping"]
elif self.type == "cpu_use_percent":
self._state = value["quicklook"]["cpu"]
elif self.type == "docker_active":
count = 0
try:
for container in value["docker"]["containers"]:
if container["Status"] == "running" or "Up" in container["Status"]:
count += 1
self._state = count
except KeyError:
self._state = count
elif self.type == "docker_cpu_use":
cpu_use = 0.0
try:
for container in value["docker"]["containers"]:
if container["Status"] == "running" or "Up" in container["Status"]:
cpu_use += container["cpu"]["total"]
self._state = round(cpu_use, 1)
except KeyError:
self._state = STATE_UNAVAILABLE
elif self.type == "docker_memory_use":
mem_use = 0.0
try:
for container in value["docker"]["containers"]:
if container["Status"] == "running" or "Up" in container["Status"]:
mem_use += container["memory"]["usage"]
self._state = round(mem_use / 1024 ** 2, 1)
except KeyError:
self._state = STATE_UNAVAILABLE

View File

@ -1428,9 +1428,8 @@ class ModesTrait(_Trait):
elif self.state.domain == humidifier.DOMAIN: elif self.state.domain == humidifier.DOMAIN:
if ATTR_MODE in attrs: if ATTR_MODE in attrs:
mode_settings["mode"] = attrs.get(ATTR_MODE) mode_settings["mode"] = attrs.get(ATTR_MODE)
elif self.state.domain == light.DOMAIN: elif self.state.domain == light.DOMAIN and light.ATTR_EFFECT in attrs:
if light.ATTR_EFFECT in attrs: mode_settings["effect"] = attrs.get(light.ATTR_EFFECT)
mode_settings["effect"] = attrs.get(light.ATTR_EFFECT)
if mode_settings: if mode_settings:
response["on"] = self.state.state not in (STATE_OFF, STATE_UNKNOWN) response["on"] = self.state.state not in (STATE_OFF, STATE_UNKNOWN)
@ -1618,15 +1617,17 @@ class OpenCloseTrait(_Trait):
if self.state.domain == binary_sensor.DOMAIN: if self.state.domain == binary_sensor.DOMAIN:
response["queryOnlyOpenClose"] = True response["queryOnlyOpenClose"] = True
response["discreteOnlyOpenClose"] = True response["discreteOnlyOpenClose"] = True
elif self.state.domain == cover.DOMAIN: elif (
if features & cover.SUPPORT_SET_POSITION == 0: self.state.domain == cover.DOMAIN
response["discreteOnlyOpenClose"] = True and features & cover.SUPPORT_SET_POSITION == 0
):
response["discreteOnlyOpenClose"] = True
if ( if (
features & cover.SUPPORT_OPEN == 0 features & cover.SUPPORT_OPEN == 0
and features & cover.SUPPORT_CLOSE == 0 and features & cover.SUPPORT_CLOSE == 0
): ):
response["queryOnlyOpenClose"] = True response["queryOnlyOpenClose"] = True
if self.state.attributes.get(ATTR_ASSUMED_STATE): if self.state.attributes.get(ATTR_ASSUMED_STATE):
response["commandOnlyOpenClose"] = True response["commandOnlyOpenClose"] = True

View File

@ -175,9 +175,10 @@ class GoogleWifiAPI:
sensor_value = "Online" sensor_value = "Online"
else: else:
sensor_value = "Offline" sensor_value = "Offline"
elif attr_key == ATTR_LOCAL_IP: elif (
if not self.raw_data["wan"]["online"]: attr_key == ATTR_LOCAL_IP and not self.raw_data["wan"]["online"]
sensor_value = STATE_UNKNOWN ):
sensor_value = STATE_UNKNOWN
self.data[attr_key] = sensor_value self.data[attr_key] = sensor_value
except KeyError: except KeyError:

View File

@ -227,9 +227,8 @@ class GPMDP(MediaPlayerEntity):
return return
while True: while True:
msg = json.loads(websocket.recv()) msg = json.loads(websocket.recv())
if "requestID" in msg: if "requestID" in msg and msg["requestID"] == self._request_id:
if msg["requestID"] == self._request_id: return msg
return msg
except ( except (
ConnectionRefusedError, ConnectionRefusedError,
ConnectionResetError, ConnectionResetError,