-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
Add torrent id to Transmission events #44187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add torrent id to Transmission events #44187
Conversation
@JPHutchins nice! Sure here's the docs PR: home-assistant/home-assistant.io#15905 The docs assume this will work: service: transmission.remove_torrent
data:
name: "Transmission"
id: "{{trigger.event.data.id}}" Instead of something like this: service: transmission.remove_torrent
data:
name: "Transmission"
id: "{{trigger.event.data.id | int}}" |
@AlecRust Awesome, thanks! As far as I can tell the data should an int at each step of the way so the docs you provided are correct. I think what's going on is that the raw torrent object has ints and strings whereas when you use the workaround accessing attributes of the HA sensor everything is strings necessitating the I will ask on the community threads about other potentially useful attributes as outlined in the spec: https://github.com/transmission/transmission/blob/master/extras/rpc-spec.txt Technically we could provide an event that is simply {
"activityDate": 1607716468,
"addedDate": 1607713708,
"announceResponse": 0,
"announceURL": 0,
"bandwidthPriority": 0,
"comment": "Garuda",
"corruptEver": 0,
"creator": "mktorrent 1.1",
"dateCreated": 1607201653,
"desiredAvailable": 5183946752,
"doneDate": 0,
"downloadDir": "/downloads/complete",
"downloadLimit": 100,
"downloadLimited": false,
"downloadedEver": 27879026,
"downloaders": 0,
"editDate": 0,
"error": 0,
"errorString": "",
"eta": 316403,
"etaIdle": -1,
"fileStats": [
{
"bytesCompleted": 24107008,
"priority": 0,
"wanted": true
}
],
"files": [
{
"bytesCompleted": 24107008,
"length": 5208053760,
"name": "garuda-kde-ultimate-linux-tkg-bmq-201205.iso"
}
],
"hashString": "1d981fa2cb881c3ff3f5f3d98c3ccc5253b4b943",
"haveUnchecked": 6504448,
"haveValid": 17602560,
"honorSessionLimits": 0,
"id": 1,
"isFinished": false,
"isPrivate": true,
"isStalled": false,
"labels": [],
"lastAnnounceTime": 0,
"lastScrapeTime": 0,
"leechers": 0,
"leftUntilDone": 5183946752,
"magnetLink": "magnet:?xt=urn:btih:1d981fa2cb881c3ff3f5f3d98c3ccc5253b4b943&dn=garuda-kde-ultimate-linux-tkg-bmq-201205.iso&tr=udp%3A%2F%2Flonewolf-builder.duckdns.org%3A23069&tr=http%3A%2F%2Ftorrent.resonatingmedia.com%3A6969%2Fannounce&ws=https%3A%2F%2Fbuilds.garudalinux.org%2Fiso%2Fgaruda%2Fkde%2F201205%2Fgaruda-kde-ultimate-linux-tkg-bmq-201205.iso&ws=https%3A%2F%2Fosdn.net%2Fprojects%2Fgaruda-linux%2Fstorage%2Fkde%2F201205%2Fgaruda-kde-ultimate-linux-tkg-bmq-201205.iso&ws=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fgaruda-linux%2Ffiles%2Fkde%2F201205%2Fgaruda-kde-ultimate-linux-tkg-bmq-201205.iso",
"manualAnnounceTime": -1,
"maxConnectedPeers": 50,
"metadataPercentComplete": 1,
"name": "garuda-kde-ultimate-linux-tkg-bmq-201205.iso",
"nextAnnounceTime": 0,
"nextScrapeTime": 0,
"peer-limits": 0,
"peersConnected": 1,
"peersFrom": {
"fromCache": 1,
"fromDht": 0,
"fromIncoming": 0,
"fromLpd": 0,
"fromLtep": 0,
"fromPex": 0,
"fromTracker": 0
},
"peersGettingFromUs": 0,
"peersKnown": 0,
"peersSendingToUs": 1,
"percentDone": 0.0046,
"pieceCount": 2484,
"pieceSize": 2097152,
"pieces": "gAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAQAAAAAAAIAAAAAAAAAgAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAABA=",
"priorities": [
0
],
"queuePosition": 0,
"rateDownload": 16000,
"rateUpload": 0,
"recheckProgress": 0,
"scrapeResponse": 0,
"scrapeURL": 0,
"secondsDownloading": 2144,
"secondsSeeding": 0,
"seedIdleLimit": 30,
"seedIdleMode": 0,
"seedRatioLimit": 2,
"seedRatioMode": 0,
"seeders": 0,
"sizeWhenDone": 5208053760,
"startDate": 1607714631,
"status": 4,
"status": 4,
"swarmSpeed": 0,
"timesCompleted": 0,
"torrentFile": "/config/torrents/1d981fa2cb881c3ff3f5f3d98c3ccc5253b4b943.torrent",
"totalSize": 5208053760,
"trackerStats": [
{
"announce": "udp://lonewolf-builder.duckdns.org:23069",
"announceState": 1,
"downloadCount": -1,
"hasAnnounced": true,
"hasScraped": true,
"host": "udp://lonewolf-builder.duckdns.org:23069",
"id": 0,
"isBackup": false,
"lastAnnouncePeerCount": 0,
"lastAnnounceResult": "Connection failed",
"lastAnnounceStartTime": 0,
"lastAnnounceSucceeded": false,
"lastAnnounceTime": 1607714781,
"lastAnnounceTimedOut": false,
"lastScrapeResult": "Connection failed",
"lastScrapeStartTime": 0,
"lastScrapeSucceeded": false,
"lastScrapeTime": 1607715691,
"lastScrapeTimedOut": false,
"leecherCount": -1,
"nextAnnounceTime": 1607716590,
"nextScrapeTime": 1607719320,
"scrape": "udp://lonewolf-builder.duckdns.org:23069",
"scrapeState": 1,
"seederCount": -1,
"tier": 0
},
{
"announce": "http://torrent.resonatingmedia.com:6969/announce",
"announceState": 1,
"downloadCount": 4,
"hasAnnounced": true,
"hasScraped": true,
"host": "http://torrent.resonatingmedia.com:6969",
"id": 1,
"isBackup": false,
"lastAnnouncePeerCount": 6,
"lastAnnounceResult": "Success",
"lastAnnounceStartTime": 1607716300,
"lastAnnounceSucceeded": true,
"lastAnnounceTime": 1607716300,
"lastAnnounceTimedOut": false,
"lastScrapeResult": "",
"lastScrapeStartTime": 0,
"lastScrapeSucceeded": true,
"lastScrapeTime": 1607716300,
"lastScrapeTimedOut": false,
"leecherCount": 2,
"nextAnnounceTime": 1607717941,
"nextScrapeTime": 1607718100,
"scrape": "http://torrent.resonatingmedia.com:6969/scrape",
"scrapeState": 1,
"seederCount": 4,
"tier": 1
}
],
"trackers": [
{
"announce": "udp://lonewolf-builder.duckdns.org:23069",
"id": 0,
"scrape": "udp://lonewolf-builder.duckdns.org:23069",
"tier": 0
},
{
"announce": "http://torrent.resonatingmedia.com:6969/announce",
"id": 1,
"scrape": "http://torrent.resonatingmedia.com:6969/scrape",
"tier": 1
}
],
"uploadLimit": 100,
"uploadLimitMode": 0,
"uploadLimited": false,
"uploadRatio": 0.04,
"wanted": [
1
],
"webseeds": [
"https://builds.garudalinux.org/iso/garuda/kde/201205/garuda-kde-ultimate-linux-tkg-bmq-201205.iso",
"https://osdn.net/projects/garuda-linux/storage/kde/201205/garuda-kde-ultimate-linux-tkg-bmq-201205.iso",
"https://sourceforge.net/projects/garuda-linux/files/kde/201205/garuda-kde-ultimate-linux-tkg-bmq-201205.iso"
],
"webseedsSendingToUs": 3
}, |
@JPHutchins agree that whole object is probably not necessary. I think just the items that make combining the different events and services possible are important. Saying that attributes such as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
We should have used actual type hinting. There is no need to use comments for type hints. Please address that in a new PR @JPHutchins |
Sounds good!
…On Fri, Jan 8, 2021, 9:27 AM Franck Nijhof ***@***.***> wrote:
We should have used actual type hinting. There is no need to use comments
for type hints.
Please address that in a new PR @JPHutchins
<https://github.com/JPHutchins>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#44187 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AIESQLTW3EELZJVJ3XCZ5TLSY456XANCNFSM4UZYTDCQ>
.
|
* 'dev' of https://github.com/home-assistant/core: (98 commits) Bump pymyq to 2.0.13 (home-assistant#44961) Add zwave to ozw migration (home-assistant#39081) Add pressure forecast to HA weather entity model (home-assistant#44965) Deduplicate MQTT entity discovery code (home-assistant#44970) Fix parameters when toggling light (home-assistant#44950) Move MQTT entity helpers to separate file (home-assistant#44838) Helpers type hint improvements (home-assistant#44964) Remove script/test (home-assistant#44967) Add MQTT Number (non optimistic) (home-assistant#44883) Fix Netatmo climate boost for valves (home-assistant#44957) Disambiguate Supervisor HTTPUnauthorized on user/password validation (home-assistant#44940) Add torrent id to Transmission events (home-assistant#44187) Prefix versions in system health (home-assistant#44921) Fix media renderers without volume control (home-assistant#44874) Fix wait_template incorrectly matching falsey values (home-assistant#44938) Upgrade youtube_dl to 2021.01.03 (home-assistant#44942) Upgrade discord.py to 1.6.0 (home-assistant#44941) Fix KNX cover state return open when unknown (home-assistant#44926) Use parent_id to find cause of logbook events with new contexts (home-assistant#44416) Implement support for additional ecobee hold modes (home-assistant#40520) ...
Proposed change
Make torrent "id" attribute available in fired events as requested here: https://community.home-assistant.io/t/transmission-add-torrent-id-to-event-data/254822
Eliminate unnecessary cast to lists, iterate sets directly.
Update objects before firing event that says they were updated!
Clarify existing code with better variable names and make consistent across the three methods that check for changes and fire events.
TODO:
update docs - @AlecRust can you look at this? I don't use events so I am not sure how to explain it!Type of change
Example entry for
configuration.yaml
:# Example configuration.yaml
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: