QBittorrent component or sensor

To my surprise, I didn’t find anything on this so I presume there is no QBittorrent component or sensor.
It would be great to have one in HA (if possible)
https://www.qbittorrent.org/

I just start using home assistant, I’m thinking in developing a qBittorrent component, I think the deluge component will make things easy and smooth.

2 Likes

Would love to see some kind of interaction as well. Right now I’m sending finished downloads by email and reading it via IMAP sensor. I’ve been searching around to possibly push the information from qbittorrents “run external program” to HA but haven’t succeded.

I found this python API wrapper https://github.com/v1k45/python-qBittorrent
It’s alredy on PyPi, I did not test it, but if it works on the latest versions of qbittorrent, should be easy create the components.

I’m thinking in something like the transmission sensor/switch. With the adition of a switch to toggle the alternate rate download limits.

Does anyone has any opinion/request ?

Would be great.
If possible also a “pause / resume all” switch maybe…

I got the sensor and switch working, I think it’s almost fine. You can find it in my github: https://github.com/danielbibit/home-assistant/tree/qbittorrent

They are on the qbittorrent branch, on: homeassistant/components/sensor/qbittorrent.py
and homeassistant/components/switch/qbittorrent.py

Put it on your config folder on:
config_folder/custom_components/sensor/qbittorrent.py and config_folder/custom_components/switch/qbittorrent.py respectively.

Here’s a configuration example:

sensor:
  - platform: qbittorrent
    name: qbit
    host: "http://hostname:8080"
    username: "admin"
    password: "adminadmin"
    monitored_variables:
      - 'current_status'
      - 'total_torrents'
      - 'active_torrents'
      - 'inactive_torrents'
      - 'downloading_torrents'
      - 'seeding_torrents'
      - 'resumed_torrents'
      - 'paused_torrents'
      - 'completed_torrents'
      - 'download_speed'
      - 'upload_speed'

and

switch:
  - platform: qbittorrent
    name: qbit turtle
    host: "http://hostname:8080"
    username: "admin"
    password: "adminadmin"

Later this month I’ll look on how to submit to the upstream repository.
Testing and feedback is always appreciated :slight_smile:

3 Likes

This is awesome!
It works for me without issue (tested quickly before going to work)

Question, what does the switch do exactly?

When on, qbittorrent will use the alternate speeds that you set on the configuration.
The rationale behind this is to use a reasonable speed when there’s somebody home, and when there’s nobody home or another condition, the client will download at full speed.

To implement a pause/resume all switch, this should be on the same switch component and use a config to diferentiate what the switch does, right ?

1 Like

Thank you for your work, I’ll wait for the PR on the main repository.
I’ve developed the deluge platform and switched from deluge to qbittorrent a few weeks ago. Will be useful to me.

This works great for me. Thanks for spending the time to create it!

Would it be possible to have a torrent list as a monitored variable? That’d be useful for those who get TV shows via an RSS feed and would like an automation to trigger whenever a new episode of a specific show is done.

1 Like

I’m looking into this. The Radarr component has a list of all my movies, it should be a nice start to implement in the qbittorrent sensor.

For anyone waiting to this get upstream, I’m very busy right now, but as soon as possible I’ll make the pull request.

3 Likes

I updated the code on my github, I now use the sensor attributes to show a list of the torrents that are downloading/uploading/paused etc.

Each sensor show a different attribute value:

  • total_torrents, active_torrents and inactive_torrents shows the ‘state’ value provided by the API.
  • downloading_torrents, resumed_torrents and paused_torrents the torrent progess in %.
  • seeding_torrents gives the torrent ratio.
  • completed_torrents just diplay a fixed 100% (my creativity went away…)

Displaying the full torrent name under the sensor attributes usually ends in a formating disaster, often impossible to distinguish the attribute name from it’s value.
So I limited the torrent name to an arbitrary value of 40 characters, so it looks like this:

ha_downloading

I thought in roughly exstimating the string size (something like this https://stackoverflow.com/questions/16007743/roughly-approximate-the-width-of-a-string-of-text-in-python) to better format the text, but I think it’s overkill.

Grayda, does this approach(having the text trimmed) limits your options to automatation trigger options ? If it does, do you have some ideia of what we can do ?

1 Like

Good job! Have you try to make a PR to merge it in master project?

With the change of custom component, do this still works and how should folders and files be installed?

I just tried it and it didn’t work for me.

Any way to integrate it to HA now that qbittorrent is already a component?

It would be great to see this functionality merged to the current qBittorrent integration, which only shows the down/up speeds.

2 Likes

+1, I would love to be able to lift bandwidth limits when no one’s at home

+1

I would love to be able to show recently completed torrents in the current qBittorent integration.

Any plans for getting this to HACS?