Add transmission info about torrents that is accessible with templating (#27111)

* Add information about current downloads.

* Cleanup: add "Torrent Info" state attribute

* Add username to codeowners

* Rename state_attributes - device_state_attributes.

* Fix snakecase keys, use f-strings, remove redundant method.

* Access started_torrent_dict directly

* Add return None condition

* Remove redundancy.

* Add missing comma in codeowners list.

* Add missing @ to username.

* Update CODEOWNERS with script.hassfest.

* Remove transmission_downloading, give started_torrents the info.

* Confirm changes.

* Actually approve changes.

* Resolve conflicts.

* Remove leftovers from old torrent_info sensor.

* Remove get_started_torrent_info method.

Old method to display boolean for the removed torrent_info sensor.
This commit is contained in:
J.P. Hutchins authored and Martin Hjelmare committed 2019-10-28 10:20:59 +01:00
1 parent edcf476408
commit 54342d2a4e
5 files changed
+41 -4

No files matched your search

@@ -6,7 +6,8 @@ from homeassistant.core import callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import Entity
from .const import DOMAIN, SENSOR_TYPES
from .const import DOMAIN, SENSOR_TYPES, STATE_ATTR_TORRENT_INFO
_LOGGER = logging.getLogger(__name__)
@@ -82,6 +83,13 @@ class TransmissionSensor(Entity):
"""Could the device be accessed during the last update call."""
return self._tm_client.api.available
@property
def device_state_attributes(self):
"""Return the state attributes, if any."""
if self._tm_client.api.started_torrent_dict and self.type == "started_torrents":
return {STATE_ATTR_TORRENT_INFO: self._tm_client.api.started_torrent_dict}
return None
async def async_added_to_hass(self):
"""Handle entity which will be added."""
async_dispatcher_connect(