Add transmission info about torrents that is accessible with templating#27111
Conversation
|
Thank you for your contribution thus far! 🎖 Since this is a significant contribution, we would appreciate you'd added yourself to the list of code owners for this integration. ❤️ Please, add your GitHub username to the For more information about "code owners", see: Architecture Decision Record 0008: Code owners. |
|
Documentation has been updated, not sure how to remove the docs-missing tag. Thanks! |
|
Thanks! @engrbm87 ok? |
|
I suggest that we use the already existing |
|
Generally we prefer individual sensors over many sensor attributes. I don't known what's best in this case. |
|
Ultimately I intended to use the date_added attribute to truncate the dictionary of started torrents to the five (or some number) most recent. The most important thing is that the user sees quick feedback when they call the add_torrent service - new torrent appears at the top of the list with ETA - and I love the idea of seeing a few of the most recent completions as well. OK to change to started_torrents attr. @engrbm87 You have also added a config flow that eliminates the need for the monitored_conditions: entry in the configuration.yaml? I would love to learn how to dynamically create an entity for each torrent. Ultimately that would make it easier for the end user to make a GUI. We would definitely want to carefully truncate the number of torrents that could be registered in this way. Thanks for your help! |
|
@JPHutchins It will be nice to see the torrent details in the GUI especially for torrents being downloaded. I don't think it is a good idea to create a new entity for each torrent. We should be in control of which entities are added to HA. |
|
@engrbm87 I have made a small update and added photos. Obviously this needs further thought. Sorry if I missed any leftovers in the code, I will continue tomorrow. For some reason my development hass kept loading an old IP and Port for transmission (I wanted to setup a phony transmission for testing) even though hass was otherwise parsing the configuration.yaml. It did not even respect a complete removal of the transmission component from the yaml. Does this have to do with the new config flow? |
|
The trouble I was having did have to do with the new config flow. An edit of the transmission entry in the configuration.yaml would not have any effect on the integration - it was necessary to delete transmission from the integrations frontend and then re-add. Registering was smooth, good work on that config flow! |
|
@engrbm87 please approve when this is ready and I'll merge. |
|
Hi @MartinHjelmare, |
|
I don't think there should be any need to make changes since PR #28136. I'd like to get it out in this form, displaying a dictionary of the downloading torrents as a state_attr of the started_torrents sensor, so that hopefully a front end person will be inspired. |
|
Hello @JPHutchins , |
|
@engrbm87 Thank you for your patience and help, I am learning so much! |
There was a problem hiding this comment.
Can you please explain the need for this? in the SENSOR_TYPES you specified all as None.
There was a problem hiding this comment.
This is removed as it was leftover from the original torrent_info sensor.
There was a problem hiding this comment.
You can directly use self._transmission_api.started_torrent_dict without the need to store it in self._torrent_info
There was a problem hiding this comment.
I have removed this - now when the sensor started_torrents is updated it checks for torrent info:
@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 NoneThere was a problem hiding this comment.
You are only using the downloading status. I recommend removing _TRPC and use downloading directly.
There was a problem hiding this comment.
I have removed these - if transmissionrpc ever changed their codes they can be found here: https://bitbucket.org/blueluna/transmissionrpc/src/default/transmissionrpc/torrent.py
There was a problem hiding this comment.
I recommend removing this as it would increase the list of torrents in the attribute if the user has many pending torrents. We should only focus on torrents being downloaded.
| """Get the number of completed torrents.""" | ||
| return len(self.completed_torrents) | ||
|
|
||
| def get_started_torrent_info(self): |
There was a problem hiding this comment.
Unused method. Either remove it or use it in the sensor attributes check.
Old method to display boolean for the removed torrent_info sensor.
|
Great @JPHutchins |
Description:
Added is a new sensor that contains a dictionary of "started torrents" in its state attribute.The inspiration comes from the add_torrent service implemented with an input_text entity. Ultimately I believe Home Assistant can act as a simple interface for adding, sorting, and observing torrent progress, very useful to friends and family that have a hard time managing their Linux ISOs in the regular interface.This example is just to see if there is interest. I am trying to learn HA architecture while improving my programming ability. To this end I would like to know if a better implementation would be for torrents to be registered as entities (like how discovery or device tracker does)?
Example state attribute:
Here is what you can expect in Developer Tools->States->sensor.transmission_started_torrents->Attributes.
Example templating:
Add a Markdown card like this one. This took me forever Jinja and I do not understand one another.
Clicking on the started_torrents sensor for "more info" yields inadequate results - can this be templated?

Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
Documentation added: Add info about torrents that is accessible with templating home-assistant.io#10574
Cheers,
J.P.