Peloton support

Hi All -

I’d like to include the workout image in a Lovelace card. it is show as an attribute item… just can’t figure out how to display it - any ideas?
Thanks!

Use this: https://github.com/edwork/homeassistant-peloton-sensor/tree/master/examples

Also, wanted to report back. Tread+ workouts sync with this component no issue. Love this implementation.

@insertion - thanks!

Is there anything beyond copying & pasting (and change to my sensor name…) in a markdown Lovelace card?

My card shows up blank and am scratching my head…

I had the same issue. Deleting the line including Leaderboard Rank worked for me. If you are still having issues, start by adding a few lines at a time. Once it breaks, you know which line is causing the issue.

success- thanks! awesome Lovelace card

Hi Tom, Like you, I cannot install pylotoncycle from pip. I did what you did, but it is not working. And I cannot figure out what’s not working. Could you guide me through your install?

I did download pylotoncycle-0.5.0.tar.gz, unzipped the files into the pylotoncycle folder within Peloton folder - see image

I modified Line 6. And modified the YAML file, but HA does not recognize “- platform: peloton”, i.e., it won’t let me restart HASS. What am I doing wrong. Can you contact me privately?

UPDATE: I WORKED IT OUT. The issue is resolved and I can see the data in Home Assistant

Awesome! Have fun with it!

What did you do to get it worked out? I tried making my directory identical to yours.
Did you modify line 6 of the sensor.py from “import pylotoncycle” to what Tom had?
I’m not getting any error message and I’m not seeing peloton as a sensor.
Edit:
I finally figured out what I was doing wrong. I’m a newbie to Home Assistant and this was my second sensor in my configuration.yaml file. I thought each sensor needed to be
sensor:
-item
sensor:
-item.
I just listed them all under one sensor heading and it worked.

Fantastic integration. Our Peloton was delivered today and now I can automatically turn out workout fan and set some lighting. I love Home Assistant!

1 Like

got the integration working earlier today but now its throwing up a bunch of errors after some restarts

Logger: homeassistant.components.sensor
Source: custom_components/peloton/sensor.py:81
Integration: Sensor (documentation, issues)
First occurred: 7:16:22 PM (2 occurrences)
Last logged: 7:16:24 PM

peloton: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 432, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 601, in async_device_update
    await task
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/peloton/sensor.py", line 81, in update
    workouts = conn.GetRecentWorkouts(1)
  File "/usr/local/lib/python3.9/site-packages/pylotoncycle/pylotoncycle.py", line 111, in GetRecentWorkouts
    resp_summary = self.GetWorkoutSummaryById(workout_id)
  File "/usr/local/lib/python3.9/site-packages/pylotoncycle/pylotoncycle.py", line 132, in GetWorkoutSummaryById
    resp = self.GetUrl(url)
  File "/usr/local/lib/python3.9/site-packages/pylotoncycle/pylotoncycle.py", line 62, in GetUrl
    resp = self.s.get(url, timeout=10).json()
  File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/local/lib/python3.9/site-packages/simplejson/__init__.py", line 525, in loads
    return _default_decoder.decode(s)
  File "/usr/local/lib/python3.9/site-packages/simplejson/decoder.py", line 370, in decode
    obj, end = self.raw_decode(s)
  File "/usr/local/lib/python3.9/site-packages/simplejson/decoder.py", line 400, in raw_decode
    return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 2 column 5 (char 5)

Any idea? I even reverted to a snapshot 5 hours ago when it was working and same issue

Same problem here. There is an issue if you’d like to follow that. The developer is usually pretty responsive.

1 Like

hmmm - my workout image disappeared - any suggestions?

yaml:

 {% if (state_attr('sensor.peloton_myusername', 'Workout Image')|string != 'None') %}
   <img src="{{ state_attr('sensor.peloton_myusername', "Workout Image") }}">
 {% endif %}

image

Question…is there a way to determine the “workout type” for multiple users versus just one as per the example below. I would like to be able to determine, for example, that User1 is “cycling” while User2 is “walking” (on the tread) and so one…

sensor:

  • platform: template
    sensors:
    power_output:
    friendly_name: “Power Output”
    value_template: >
    {{ state_attr(‘sensor.peloton_username’, “Workout Type” ) }}

I’m only seeing a handful of the attributes listed above.
image

Am I missing something? I’m an app user - I do not have the bike, perhaps that’s it?

I’ve been reviewing the API documentation and cannot find the call to retrieve a users Friends who are actively riding (like you can see on the bike). I would love to have a sensor that would show number of friends riding and then I could look at that and see who and what rides. Might motivate me to join them quickly to get another workout in.

1 Like

I have gone back to the basic instructions -

Manual Copy Peloton folder into the custom components and
updated the yaml with my details,
it’s not working, and I get the following log errors? any help would be appreciated thanks in advance-

2022-01-05 09:15:38 WARNING (SyncWorker_7) [custom_components.peloton.sensor] Error on parsing State Attributes, something in the API may have changed
2022-01-05 09:15:38 ERROR (MainThread) [homeassistant.components.sensor] peloton: Error on device update!

File “/config/custom_components/peloton/sensor.py”, line 150, in update
if self.hr_monitor == True:
AttributeError: ‘PelotonSensor’ object has no attribute ‘hr_monitor’

I have fixed it, installed HACS, all good, hope this helps others?

image

Hopefully, this is useful feedback?

I am lucky to have the Bike and Tread, the State attributes are quite different, eg there are no ‘Heat Rate’ values on the tread (labeled AKA device type ‘Prism’), also the ‘output Kj’ did not update every 30 secs or so only on completion and no Calories?

Got this up and working. I would love to keep historical stats. Will keep on playing with it.

I haven’t touched this part of my UI in months, but I can’t seem to get a markdown card to work anymore, even though the states/attributes show up fine in dev tools. I know there were changes to the API and the app - were they breaking? Can someone share a current markdown card they are using?

This attr card is working swimmingly, so I’m probably just bad at templating :frowning:

type: custom:entity-attributes-card
title: Latest Ride Stats
heading_name: Metric
heading_state: Value
filter:
  include:
    - sensor.peloton_user.Ride Title
    - sensor.peloton_user.Description
    - sensor.peloton_user.Instructor
    - sensor.peloton_user.Duration Min
    - sensor.peloton_user.Leaderboard Rank
    - sensor.peloton_user.Distance Mi
    - sensor.peloton_user.Calories KCal
    - sensor.peloton_user.Speed Average Mph
    - sensor.peloton_user.Power Average W
  exclude:
    - sensor.peloton_user.icon
    - sensor.peloton_user.friendly_name