Would love to see Peloton support.
Perhaps you should give us a couple of sentences on that peloton is? Because neither of your links give me any damn idea!
Itās a really expensive exercise bicycle.
LOL no wonder I didnāt know!!
/me looks around for wine glass and runny cheese.
Good News!
Using the linked API above I was able to scrap something together. The API being used is official but undocumented aside from @geudrikās documentation (someone please correct me).
My plan is to refactor the code from the peloton-api project directly into the HASS Component, as peloton-api is not published to PyPi, and is already MIT licenced.
For anyone curious about use cases, I am interested in using this to trigger:
- Lights off
- Accent lights to blue
- HVAC to stop cooling and ventilate
- directed cooling fan on
And reverse when the ride is over.
Quick Edit: I realize the peloton-api project is not just a simple script, and I may look at working with the dev to get it published into PyPi.
@edwork well done, would be very interested in collaborating or helping test, is there somewhere to follow along on your progress?
Congrats @edwork, this is super exciting! Iāve been looking for the same thing, did you manage to get this working? Let me know if I can help!
Thanks @edwork - this is fantastic! Iām confused on how to install the sensor, though?
Iām running in a docker container, and have
- Placed the contents from your git into HomeAssistant/config/custom_components/peloton
- Created the HomeAssistant/config/peloton configuration file with credentials.
- Added - platform: peloton to my configuration file
However, nothing is loaded into the entities? What steps should we be following to get this going?
Thanks!
Matt
@edwork do you have something working even if rough? Iād love to help with this so I can stop getting yelled at when the basement lights turn off when my wife is on the Bike.
Hello All,
Itās been a while since I started this, and I could use some help making it more streamlined. First, there are some requirements that we need to work out.
-
I am using geudrik/peloton-api. An unofficial (but working) API. Itās not in PyPi so I have resorted to cloning the project and refactoring certain things such as the credentials in order to get it working.
-
Credentials currently have to be hard coded. This is a VERY solvable issue, I am just not the best at refactoring whatās already built in the API functions. I believe I hard coded my credz in
custom_components/homeassistant-peloton-sensor/sensor.py
(line 33,34) but if that doesnāt work check incustom_components/homeassistant-peloton-sensor/peloton/peloton.py
and look into hard coding them there.
To be clear, most of the terrible workarounds are just to get it to work for proof of concept. Since thereās been much more interest lately (and I need to get back on the bikeā¦) Iām going to try to polish this up a good bit within the next few days.
Checkout https://github.com/edwork/homeassistant-peloton-sensor/ for more details in the Readme (including new setup instructions).
Cheers,
Ed
Thanks @edwork! Appreciate the progress on this, even if itās just MVPā¦ very cool! Iāve been refreshing this page for the last 8 days waiting for this .
I updated the credentials in 33,34 but was still unsuccessful. I ended up hard coding them into line 268, 269 which worked! Iām not a developer and know just enough about Python to be dangerousā¦ will play around with the code later this week to see if I can help figure out why the variables arenāt passed into the payload on 268,269.
Happy to hear itās working somewhat. I havenāt poked at this for a while, so couldnāt remember exactly what I had done! Pull requests are welcome, suggestions and critiques are also very welcome!
@edwork Nice Job in this, I was able to get it working as well and would be happy to help test.
One thing I noticed, it never reports anything other than complete as the status, however the attributes do seem to update after a workout is completed. Is that consistent with everyone elseās experience?
Hey - Just wanted to thank you for working on this- canāt wait to try it out. Hopefully it could be included in as a standard HA integration (or installable via HACS) some day.
For anyone interested, I wanted something offline to solve the issue of knowing if someone was using the bike.
I sideloaded the following app onto the Peloton: https://llamalab.com/automate/
The app allows you to make HTTP/S calls during screen on/off events. I use these events to fire a āpelotonā event into the HASS event bus with event metadata indicating if the screen is on/off.
I listen to these events in automation to turn fans/lights on and off.
Unfortunately this isnt as elegant as a HASS plugin, but I like the fact that I am getting feedback directly from the bike!
That is interestingā¦how did you install onto the Peloton?
Sideload using ADB and plugging my computer directly into the Peloton
Can you tell me how you hardcoded it so I can copy paste with my user information please?
I know itās not āelegantā either, but FWIW I use Google Wifi Mesh setup at my house. I created an āIFTTT Eventā when Google Wifi detects my Peloton on the network, it calls a script (which sets a variable / timestamp in HA denoting the Peloton is ON). Another IFTTT Trigger fires when Google Wifi detects the Peloton leaving the network to fire a peloton off script.
scripts:
peloton_on:
sequence:
- service: variable.set_variable
data:
variable: peloton
value: 'on'
- service: variable.set_variable
data:
variable: peloton_on
value_template: "{{ now().timestamp() }}"
peloton_off:
sequence:
- service: variable.set_variable
data:
variable: peloton
value: 'off'
binary_sensor:
peloton:
friendly_name: Peloton
value_template: "{{ is_state('variable.peloton','on') }}"
sensors:
peloton_last_on:
value_template: >
{% set elapsed = (as_timestamp(states('sensor.date_time').replace(',','')) - states('variable.peloton_on') | int ) %}
{% set days = (elapsed / 86400) | int %}
{% set hours= ((elapsed % 86400) / 3600) | int %}
{% set mins = ((elapsed % 3600) / 60) | int %}
{% set secs = elapsed | int % 60 %}
{% if days > 0 %} {{days}}d {%if hours < 10 %}0{%endif%}{{hours}}:{%if mins< 10 %}0{%endif%}{{mins}}
{% elif hours > 0 %} {% if hours < 10 %}0{%endif%}{{hours}}:{%if mins< 10 %}0{%endif%}{{mins}}
{% elif mins > 0 %} {{mins}}m
{% else %} {{secs}}s {% endif %}
Iām sure there are more elegant ways to do this, but, hey, does at least what I need it to doā¦
Also, FWIW, I use the exact same methodology for our Xbox, Nanny sensor, etc. Anything that comes onto / off of the network I can track like this to see if itās on or not and how long itās been on.
Ends up looking like this on frontend:
Variable
I use is custom component and found here: https://github.com/rogro82/hass-variables (Iām also aware input_* can be used, but I started w/ variables and they work, so sticking with my theme of āif it aināt broke, donāt fix itā - I kept using themā¦
Unfortunately I have UniFi and same thing wonāt work. Right now the status on this does not change from complete to in progress.