mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 08:07:45 +00:00
PS4 handle no connection/ fix spamming of logs when device is off (#25091)
* Bump 0.8.7 * Bump 0.8.7 * 0.8.7 * Handle exception. Handle device unavailable. * Typo * Blank line
This commit is contained in:
parent
c6b63b15b8
commit
68edf10270
@ -4,7 +4,7 @@
|
|||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/components/ps4",
|
"documentation": "https://www.home-assistant.io/components/ps4",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"pyps4-homeassistant==0.8.5"
|
"pyps4-homeassistant==0.8.7"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"codeowners": [
|
"codeowners": [
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
import logging
|
import logging
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
import pyps4_homeassistant.ps4 as pyps4
|
||||||
|
from pyps4_homeassistant.errors import NotReady
|
||||||
|
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
from homeassistant.components.media_player import (
|
from homeassistant.components.media_player import (
|
||||||
ENTITY_IMAGE_URL, MediaPlayerDevice)
|
ENTITY_IMAGE_URL, MediaPlayerDevice)
|
||||||
@ -27,6 +30,8 @@ ICON = 'mdi:playstation'
|
|||||||
GAMES_FILE = '.ps4-games.json'
|
GAMES_FILE = '.ps4-games.json'
|
||||||
MEDIA_IMAGE_DEFAULT = None
|
MEDIA_IMAGE_DEFAULT = None
|
||||||
|
|
||||||
|
DEFAULT_RETRIES = 2
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||||
"""Set up PS4 from a config entry."""
|
"""Set up PS4 from a config entry."""
|
||||||
@ -38,7 +43,6 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
async def async_setup_platform(
|
async def async_setup_platform(
|
||||||
hass, config, async_add_entities, discovery_info=None):
|
hass, config, async_add_entities, discovery_info=None):
|
||||||
"""Set up PS4 Platform."""
|
"""Set up PS4 Platform."""
|
||||||
import pyps4_homeassistant.ps4 as pyps4
|
|
||||||
games_file = hass.config.path(GAMES_FILE)
|
games_file = hass.config.path(GAMES_FILE)
|
||||||
creds = config.data[CONF_TOKEN]
|
creds = config.data[CONF_TOKEN]
|
||||||
device_list = []
|
device_list = []
|
||||||
@ -118,8 +122,15 @@ class PS4Device(MediaPlayerDevice):
|
|||||||
if self._ps4.ddp_protocol is not None:
|
if self._ps4.ddp_protocol is not None:
|
||||||
# Request Status with asyncio transport.
|
# Request Status with asyncio transport.
|
||||||
self._ps4.get_status()
|
self._ps4.get_status()
|
||||||
if not self._ps4.connected and not self._ps4.is_standby:
|
|
||||||
await self._ps4.async_connect()
|
# Don't attempt to connect if entity is connected or if,
|
||||||
|
# PS4 is in standby or disconnected from LAN or powered off.
|
||||||
|
if not self._ps4.connected and not self._ps4.is_standby and\
|
||||||
|
self._ps4.is_available:
|
||||||
|
try:
|
||||||
|
await self._ps4.async_connect()
|
||||||
|
except NotReady:
|
||||||
|
pass
|
||||||
|
|
||||||
# Try to ensure correct status is set on startup for device info.
|
# Try to ensure correct status is set on startup for device info.
|
||||||
if self._ps4.ddp_protocol is None:
|
if self._ps4.ddp_protocol is None:
|
||||||
@ -162,7 +173,7 @@ class PS4Device(MediaPlayerDevice):
|
|||||||
if self._state != STATE_OFF:
|
if self._state != STATE_OFF:
|
||||||
self.state_off()
|
self.state_off()
|
||||||
|
|
||||||
elif self._retry > 5:
|
elif self._retry > DEFAULT_RETRIES:
|
||||||
self.state_unknown()
|
self.state_unknown()
|
||||||
else:
|
else:
|
||||||
self._retry += 1
|
self._retry += 1
|
||||||
|
@ -1324,7 +1324,7 @@ pypjlink2==1.2.0
|
|||||||
pypoint==1.1.1
|
pypoint==1.1.1
|
||||||
|
|
||||||
# homeassistant.components.ps4
|
# homeassistant.components.ps4
|
||||||
pyps4-homeassistant==0.8.5
|
pyps4-homeassistant==0.8.7
|
||||||
|
|
||||||
# homeassistant.components.qwikswitch
|
# homeassistant.components.qwikswitch
|
||||||
pyqwikswitch==0.93
|
pyqwikswitch==0.93
|
||||||
|
@ -286,7 +286,7 @@ pyopenuv==1.0.9
|
|||||||
pyotp==2.2.7
|
pyotp==2.2.7
|
||||||
|
|
||||||
# homeassistant.components.ps4
|
# homeassistant.components.ps4
|
||||||
pyps4-homeassistant==0.8.5
|
pyps4-homeassistant==0.8.7
|
||||||
|
|
||||||
# homeassistant.components.qwikswitch
|
# homeassistant.components.qwikswitch
|
||||||
pyqwikswitch==0.93
|
pyqwikswitch==0.93
|
||||||
|
Loading…
x
Reference in New Issue
Block a user