desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Return the content ID of current playing media.'
| @property
def media_content_id(self):
| return 'bounzz-1'
|
'Return the content type of current playing media.'
| @property
def media_content_type(self):
| return MEDIA_TYPE_MUSIC
|
'Return the duration of current playing media in seconds.'
| @property
def media_duration(self):
| return 213
|
'Return the image url of current playing media.'
| @property
def media_image_url(self):
| return 'https://graph.facebook.com/v2.5/107771475912710/picture?type=large'
|
'Return the title of current playing media.'
| @property
def media_title(self):
| return (self.tracks[self._cur_track][1] if self.tracks else '')
|
'Return the artist of current playing media (Music track only).'
| @property
def media_artist(self):
| return (self.tracks[self._cur_track][0] if self.tracks else '')
|
'Return the album of current playing media (Music track only).'
| @property
def media_album_name(self):
| return 'Bounzz'
|
'Return the track number of current media (Music track only).'
| @property
def media_track(self):
| return (self._cur_track + 1)
|
'Flag media player features that are supported.'
| @property
def supported_features(self):
| support = MUSIC_PLAYER_SUPPORT
if (self._cur_track > 0):
support |= SUPPORT_PREVIOUS_TRACK
if (self._cur_track < (len(self.tracks) - 1)):
support |= SUPPORT_NEXT_TRACK
return support
|
'Send previous track command.'
| def media_previous_track(self):
| if (self._cur_track > 0):
self._cur_track -= 1
self.schedule_update_ha_state()
|
'Send next track command.'
| def media_next_track(self):
| if (self._cur_track < (len(self.tracks) - 1)):
self._cur_track += 1
self.schedule_update_ha_state()
|
'Clear players playlist.'
| def clear_playlist(self):
| self.tracks = []
self._cur_track = 0
self._player_state = STATE_OFF
self.schedule_update_ha_state()
|
'Initialize the demo device.'
| def __init__(self):
| super().__init__('Lounge room')
self._cur_episode = 1
self._episode_count = 13
self._source = 'dvd'
|
'Return the content ID of current playing media.'
| @property
def media_content_id(self):
| return 'house-of-cards-1'
|
'Return the content type of current playing media.'
| @property
def media_content_type(self):
| return MEDIA_TYPE_TVSHOW
|
'Return the duration of current playing media in seconds.'
| @property
def media_duration(self):
| return 3600
|
'Return the image url of current playing media.'
| @property
def media_image_url(self):
| return 'https://graph.facebook.com/v2.5/HouseofCards/picture?width=400'
|
'Return the title of current playing media.'
| @property
def media_title(self):
| return 'Chapter {}'.format(self._cur_episode)
|
'Return the series title of current playing media (TV Show only).'
| @property
def media_series_title(self):
| return 'House of Cards'
|
'Return the season of current playing media (TV Show only).'
| @property
def media_season(self):
| return 1
|
'Return the episode of current playing media (TV Show only).'
| @property
def media_episode(self):
| return self._cur_episode
|
'Return the current running application.'
| @property
def app_name(self):
| return 'Netflix'
|
'Return the current input source.'
| @property
def source(self):
| return self._source
|
'Flag media player features that are supported.'
| @property
def supported_features(self):
| support = NETFLIX_PLAYER_SUPPORT
if (self._cur_episode > 1):
support |= SUPPORT_PREVIOUS_TRACK
if (self._cur_episode < self._episode_count):
support |= SUPPORT_NEXT_TRACK
return support
|
'Send previous track command.'
| def media_previous_track(self):
| if (self._cur_episode > 1):
self._cur_episode -= 1
self.schedule_update_ha_state()
|
'Send next track command.'
| def media_next_track(self):
| if (self._cur_episode < self._episode_count):
self._cur_episode += 1
self.schedule_update_ha_state()
|
'Set the input source.'
| def select_source(self, source):
| self._source = source
self.schedule_update_ha_state()
|
'Create Soundtouch Entity.'
| def __init__(self, name, config):
| from libsoundtouch import soundtouch_device
self._device = soundtouch_device(config['host'], config['port'])
if (name is None):
self._name = self._device.config.name
else:
self._name = name
self._status = self._device.status()
self._volume = self._device.volume()
self._config... |
'Return specific soundtouch configuration.'
| @property
def config(self):
| return self._config
|
'Return Soundtouch device.'
| @property
def device(self):
| return self._device
|
'Retrieve the latest data.'
| def update(self):
| self._status = self._device.status()
self._volume = self._device.volume()
|
'Volume level of the media player (0..1).'
| @property
def volume_level(self):
| return (self._volume.actual / 100)
|
'Return the name of the device.'
| @property
def name(self):
| return self._name
|
'Return the state of the device.'
| @property
def state(self):
| if (self._status.source == 'STANDBY'):
return STATE_OFF
return MAP_STATUS.get(self._status.play_status, STATE_UNAVAILABLE)
|
'Boolean if volume is currently muted.'
| @property
def is_volume_muted(self):
| return self._volume.muted
|
'Flag media player features that are supported.'
| @property
def supported_features(self):
| return SUPPORT_SOUNDTOUCH
|
'Turn off media player.'
| def turn_off(self):
| self._device.power_off()
self._status = self._device.status()
|
'Turn on media player.'
| def turn_on(self):
| self._device.power_on()
self._status = self._device.status()
|
'Volume up the media player.'
| def volume_up(self):
| self._device.volume_up()
self._volume = self._device.volume()
|
'Volume down media player.'
| def volume_down(self):
| self._device.volume_down()
self._volume = self._device.volume()
|
'Set volume level, range 0..1.'
| def set_volume_level(self, volume):
| self._device.set_volume(int((volume * 100)))
self._volume = self._device.volume()
|
'Send mute command.'
| def mute_volume(self, mute):
| self._device.mute()
self._volume = self._device.volume()
|
'Simulate play pause media player.'
| def media_play_pause(self):
| self._device.play_pause()
self._status = self._device.status()
|
'Send play command.'
| def media_play(self):
| self._device.play()
self._status = self._device.status()
|
'Send media pause command to media player.'
| def media_pause(self):
| self._device.pause()
self._status = self._device.status()
|
'Send next track command.'
| def media_next_track(self):
| self._device.next_track()
self._status = self._device.status()
|
'Send the previous track command.'
| def media_previous_track(self):
| self._device.previous_track()
self._status = self._device.status()
|
'Image url of current playing media.'
| @property
def media_image_url(self):
| return self._status.image
|
'Title of current playing media.'
| @property
def media_title(self):
| if (self._status.station_name is not None):
return self._status.station_name
elif (self._status.artist is not None):
return ((self._status.artist + ' - ') + self._status.track)
return None
|
'Duration of current playing media in seconds.'
| @property
def media_duration(self):
| return self._status.duration
|
'Artist of current playing media.'
| @property
def media_artist(self):
| return self._status.artist
|
'Artist of current playing media.'
| @property
def media_track(self):
| return self._status.track
|
'Album name of current playing media.'
| @property
def media_album_name(self):
| return self._status.album
|
'Play a piece of media.'
| def play_media(self, media_type, media_id, **kwargs):
| _LOGGER.debug(('Starting media with media_id: ' + str(media_id)))
if re.match('http://', str(media_id)):
_LOGGER.debug('Playing URL %s', str(media_id))
self._device.play_url(str(media_id))
else:
presets = self._device.presets()
preset = next([preset for pres... |
'Create a zone (multi-room) and play on selected devices.
:param slaves: slaves on which to play'
| def create_zone(self, slaves):
| if (not slaves):
_LOGGER.warning('Unable to create zone without slaves')
else:
_LOGGER.info(('Creating zone with master ' + str(self.device.config.name)))
self.device.create_zone([slave.device for slave in slaves])
|
'Remove slave(s) from and existing zone (multi-room).
Zone must already exist and slaves array can not be empty.
Note: If removing last slave, the zone will be deleted and you\'ll have
to create a new one. You will not be able to add a new slave anymore
:param slaves: slaves to remove from the zone'
| def remove_zone_slave(self, slaves):
| if (not slaves):
_LOGGER.warning('Unable to find slaves to remove')
else:
_LOGGER.info(('Removing slaves from zone with master ' + str(self.device.config.name)))
self.device.remove_zone_slave([slave.device for slave in slaves])
|
'Add slave(s) to and existing zone (multi-room).
Zone must already exist and slaves array can not be empty.
:param slaves:slaves to add'
| def add_zone_slave(self, slaves):
| if (not slaves):
_LOGGER.warning('Unable to find slaves to add')
else:
_LOGGER.info(('Adding slaves to zone with master ' + str(self.device.config.name)))
self.device.add_zone_slave([slave.device for slave in slaves])
|
'Initialize the Gstreamer device.'
| def __init__(self, player, name):
| self._player = player
self._name = (name or DOMAIN)
self._state = STATE_IDLE
self._volume = None
self._duration = None
self._uri = None
self._title = None
self._artist = None
self._album = None
|
'Update properties.'
| def update(self):
| self._state = self._player.state
self._volume = self._player.volume
self._duration = self._player.duration
self._uri = self._player.uri
self._title = self._player.title
self._album = self._player.album
self._artist = self._player.artist
|
'Set the volume level.'
| def set_volume_level(self, volume):
| self._player.volume = volume
|
'Play media.'
| def play_media(self, media_type, media_id, **kwargs):
| if (media_type != MEDIA_TYPE_MUSIC):
_LOGGER.error('invalid media type')
return
self._player.queue(media_id)
|
'Play.'
| def media_play(self):
| self._player.play()
|
'Pause.'
| def media_pause(self):
| self._player.pause()
|
'Next track.'
| def media_next_track(self):
| self._player.next()
|
'Content ID of currently playing media.'
| @property
def media_content_id(self):
| return self._uri
|
'Content type of currently playing media.'
| @property
def content_type(self):
| return MEDIA_TYPE_MUSIC
|
'Return the name of the device.'
| @property
def name(self):
| return self._name
|
'Return the volume level.'
| @property
def volume_level(self):
| return self._volume
|
'Flag media player features that are supported.'
| @property
def supported_features(self):
| return SUPPORT_GSTREAMER
|
'Return the state of the player.'
| @property
def state(self):
| return self._state
|
'Duration of current playing media in seconds.'
| @property
def media_duration(self):
| return self._duration
|
'Media title.'
| @property
def media_title(self):
| return self._title
|
'Media artist.'
| @property
def media_artist(self):
| return self._artist
|
'Media album.'
| @property
def media_album_name(self):
| return self._album
|
'Initialize the base Z-Wave class.'
| def __init__(self):
| self._update_scheduled = False
self.old_entity_id = None
self.new_entity_id = None
|
'Maybe schedule state update.
If value changed after device was created but before setup_platform
was called - skip updating state.'
| def maybe_schedule_update(self):
| if (self.hass and (not self._update_scheduled)):
self.hass.add_job(self._schedule_update)
|
'Schedule delayed update.'
| @callback
def _schedule_update(self):
| if self._update_scheduled:
return
@callback
def do_update():
'Really update.'
self.hass.async_add_job(self.async_update_ha_state)
self._update_scheduled = False
self._update_scheduled = True
self.hass.loop.call_later(0.1, do_update)
|
'Initialize node.'
| def __init__(self, node, network, new_entity_ids):
| super().__init__()
from openzwave.network import ZWaveNetwork
from pydispatch import dispatcher
self._network = network
self.node = node
self.node_id = self.node.node_id
self._name = node_name(self.node)
self._product_name = node.product_name
self._manufacturer_name = node.manufactur... |
'Handle a changed node on the network.'
| def network_node_changed(self, node=None, args=None):
| if (node and (node.node_id != self.node_id)):
return
if ((args is not None) and ('nodeId' in args) and (args['nodeId'] != self.node_id)):
return
self.node_changed()
|
'Retrieve statistics from the node.'
| def get_node_statistics(self):
| return self._network.manager.getNodeStatistics(self._network.home_id, self.node_id)
|
'Update node properties.'
| def node_changed(self):
| attributes = {}
stats = self.get_node_statistics()
for attr in ATTRIBUTES:
value = getattr(self.node, attr)
if ((attr in _REQUIRED_ATTRIBUTES) or value):
attributes[attr] = value
for attr in _COMM_ATTRIBUTES:
attributes[attr] = stats[attr]
if self.node.can_wake_up... |
'Handle a node activated event on the network.'
| def network_node_event(self, node, value):
| if (node.node_id == self.node.node_id):
self.node_event(value)
|
'Handle a node activated event for this node.'
| def node_event(self, value):
| if (self.hass is None):
return
self.hass.bus.fire(EVENT_NODE_EVENT, {ATTR_ENTITY_ID: self.entity_id, ATTR_NODE_ID: self.node.node_id, ATTR_BASIC_LEVEL: value})
|
'Handle a scene activated event on the network.'
| def network_scene_activated(self, node, scene_id):
| if (node.node_id == self.node.node_id):
self.scene_activated(scene_id)
|
'Handle an activated scene for this node.'
| def scene_activated(self, scene_id):
| if (self.hass is None):
return
self.hass.bus.fire(EVENT_SCENE_ACTIVATED, {ATTR_ENTITY_ID: self.entity_id, ATTR_NODE_ID: self.node.node_id, ATTR_SCENE_ID: scene_id})
|
'Return the state.'
| @property
def state(self):
| if (ATTR_READY not in self._attributes):
return None
stage = ''
if (not self._attributes[ATTR_READY]):
stage = self._attributes[ATTR_QUERY_STAGE]
if self._attributes[ATTR_FAILED]:
return sub_status('Dead', stage)
if (not self._attributes[ATTR_AWAKE]):
return sub_statu... |
'No polling needed.'
| @property
def should_poll(self):
| return False
|
'Return the name of the device.'
| @property
def name(self):
| return self._name
|
'Return the device specific state attributes.'
| @property
def device_state_attributes(self):
| attrs = {ATTR_NODE_ID: self.node_id, ATTR_NODE_NAME: self._name, ATTR_MANUFACTURER_NAME: self._manufacturer_name, ATTR_PRODUCT_NAME: self._product_name, 'old_entity_id': self.old_entity_id, 'new_entity_id': self.new_entity_id}
attrs.update(self._attributes)
if (self.battery_level is not None):
attrs... |
'Initialize the device.'
| def __init__(self, area_name, lutron_device, controller):
| self._lutron_device = lutron_device
self._controller = controller
self._area_name = area_name
|
'Register callbacks.'
| @asyncio.coroutine
def async_added_to_hass(self):
| self.hass.async_add_job(self._controller.subscribe, self._lutron_device, self._update_callback)
|
'Run when invoked by pylutron when the device state changes.'
| def _update_callback(self, _device):
| self.schedule_update_ha_state()
|
'Return the name of the device.'
| @property
def name(self):
| return '{} {}'.format(self._area_name, self._lutron_device.name)
|
'No polling needed.'
| @property
def should_poll(self):
| return False
|
'Initialize a Nest Camera.'
| def __init__(self, structure, device):
| super(NestCamera, self).__init__()
self.structure = structure
self.device = device
self._location = None
self._name = None
self._online = None
self._is_streaming = None
self._is_video_history_enabled = False
self._time_between_snapshots = timedelta(seconds=30)
self._last_image = ... |
'Return the name of the nest, if any.'
| @property
def name(self):
| return self._name
|
'Nest camera should poll periodically.'
| @property
def should_poll(self):
| return True
|
'Return true if the device is recording.'
| @property
def is_recording(self):
| return self._is_streaming
|
'Return the brand of the camera.'
| @property
def brand(self):
| return NEST_BRAND
|
'Cache value from Python-nest.'
| def update(self):
| self._location = self.device.where
self._name = self.device.name
self._online = self.device.online
self._is_streaming = self.device.is_streaming
self._is_video_history_enabled = self.device.is_video_history_enabled
if self._is_video_history_enabled:
self._time_between_snapshots = timedel... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.