1 """Support for Pocket Casts."""
3 from __future__
import annotations
5 from datetime
import timedelta
8 from pycketcasts
import pocketcasts
9 import voluptuous
as vol
12 PLATFORM_SCHEMA
as SENSOR_PLATFORM_SCHEMA,
21 _LOGGER = logging.getLogger(__name__)
24 SENSOR_NAME =
"Pocketcasts unlistened episodes"
28 PLATFORM_SCHEMA = SENSOR_PLATFORM_SCHEMA.extend(
29 {vol.Required(CONF_PASSWORD): cv.string, vol.Required(CONF_USERNAME): cv.string}
36 add_entities: AddEntitiesCallback,
37 discovery_info: DiscoveryInfoType |
None =
None,
39 """Set up the pocketcasts platform for sensors."""
40 username = config.get(CONF_USERNAME)
41 password = config.get(CONF_PASSWORD)
44 api = pocketcasts.PocketCast(email=username, password=password)
45 _LOGGER.debug(
"Found %d podcasts", len(api.subscriptions))
47 except OSError
as err:
48 _LOGGER.error(
"Connection to server failed: %s", err)
52 """Representation of a pocket casts sensor."""
54 _attr_icon =
"mdi:rss"
57 """Initialize the sensor."""
63 """Return the name of the sensor."""
68 """Return the sensor state."""
72 """Update sensor values."""
74 self.
_state_state = len(self.
_api_api.new_releases)
75 _LOGGER.debug(
"Found %d new episodes", self.
_state_state)
76 except OSError
as err:
77 _LOGGER.warning(
"Failed to contact server: %s", err)
def add_entities(account, async_add_entities, tracked)
None setup_platform(HomeAssistant hass, ConfigType config, AddEntitiesCallback add_entities, DiscoveryInfoType|None discovery_info=None)