Peloton support

I installed this and it’s working great with my fan already. Thanks! Does the API return anything other than “In Progress” when a ride is active? Nice to have request from the other Peloton user in my household is to turn the fan off when the ride ride type is cool down ride.

“In Progress” will be updated within a day or so. Great use case for the cool down ride!

I actually had a similar idea, if Output is a sensor or attribute of a sensor… I have a floor fan pointed at the bike, which turns on as part of my “Start Peloton” automation. But it’s always a little cold until I warm up. I was thinking it would be cool (pun intended) if the fan doesn’t turn on until I reach a certain output number. By then I would be warmed up and ready to have the fan cool me down.

Personally I set my fan up with an old christmas light plug w/ remote control. the remote clips on the water bottle holder (hangs on the under-side so can still use the holder). Whenever I want the fan on, I press the button.

I’m guessing it’s going to be near next to impossible to fully automate the exact second you want the fan on without manual intervention.

The first real ‘release’ is out, and it’s installable via HACS if you add the GitHub URL as a custom repo. I’ve installed it and have working on my primary instance now.

Notes:

  • The release is missing some of the assets that make it show up ‘pretty’ in HACS and HomeAssistant
  • Only quick tests were run on active rides, please report bugs
  • Non-bike based workouts have not really been tested
  • The Recorder doesn’t seem to be recording state history, looking into this
  • Additional raw state sensors can be added using Templates - check the README on GitHub
1 Like

Ed,

Great work. I recently installed the release and got everything up and running. I made the following automation based on the heartbeat. The automation changes my gym’s RGB Wi-Fi lights to reflect which heart rate zone I’m in as I work out.

Created a sensor for my current heartbeat.

sensor.yaml:

- platform: template
  sensors:
    peloton_bpm:
      icon_template: mdi:heart-pulse
      friendly_name: "Peloton BPM"
      unit_of_measurement: BPM 
      value_template: >
        {{ state_attr('sensor.peloton_username', "Heart Rate Bpm") }}

Created an automation that calls the color changing script when a workout is Active.

automations.yaml:

- id: '1603764652569'
  alias: Peloton - BPM Loop
  description: ''
  trigger:
  - platform: time_pattern
    minutes: /1
  condition:
  - condition: state
    entity_id: sensor.peloton_arghthor
    state: Active
  action:
  - service: script.turn_on
    data: {}
    entity_id: script.peloton_colors
  mode: restart

Script reads the heartbeat sensor and changes the basement lights to the appropriate color.

peloton_colors:
  alias: Peloton BPM Colors
  sequence:
  - choose:
    - conditions:
      - condition: numeric_state
        entity_id: sensor.peloton_bpm
        above: '160'
      sequence:
      - service: light.turn_on
        data:
          rgb_color:
          - 255
          - 71
          - 89
        entity_id: light.basement_lights
    - conditions:
      - condition: numeric_state
        entity_id: sensor.peloton_bpm
        above: '143'
        below: '159'
      sequence:
      - service: light.turn_on
        data:
          rgb_color:
          - 252
          - 128
          - 15
        entity_id: light.basement_lights
    - conditions:
      - condition: numeric_state
        entity_id: sensor.peloton_bpm
        above: '126'
        below: '142'
      sequence:
      - service: light.turn_on
        data:
          rgb_color:
          - 250
          - 203
          - 62
        entity_id: light.basement_lights
    - conditions:
      - condition: numeric_state
        entity_id: sensor.peloton_bpm
        above: '109'
        below: '125'
      sequence:
      - service: light.turn_on
        data:
          rgb_color:
          - 182
          - 201
          - 92
        entity_id: light.basement_lights
    default:
    - service: light.turn_on
      data:
        rgb_color:
        - 80
        - 196
        - 170
      entity_id: light.basement_lights
  mode: single

Would love to update more often than once a minute, but I understand the hesitancy to poll Peloton more often.

1 Like

@arghthor I also inquired about upping the polling. This is something @edwork said he would look into, but he is using an unofficial API and is unsure if he can increase it.

1 Like

I did see that. Figured a second vote for more frequent updates couldn’t hurt! I’m really pleased with it regardless. I will up my polling, so there is less delay on my end.

1 Like

Happy to hear about everyone’s success with the integration. I’ve been using it myself over the past few weeks and it’s been awesome not yelling at one of my clunky voice assistants and pressing buttons to toggle lights and fans. I’ve also implemented notifications for when my wife or I start/end a ride so we know not to disturb each other.

Regarding the polling interval - I’ve come up with a plan that I think may work. Rather than poll the service at a quicker pace 24/7 I’ll attempt to poll faster when a workout is in progress.

I’ll see if I can get this working over the weekend. Feel free to keep making suggestions, hoping to have this be part of the mainline project someday!

3 Likes

Been following this and just installed via HACS. Looks like its pulling data perfectly - thanks for all the work! Have it working via node-red, so far so good!

Any chance of accessing general user stats ? Total rides, number of each type of ride, maybe profile data etc?

2 Likes

First of all. Thanks for doing this.
I see there is a dependency on pylotoncycle. I am running Home Assistant in docker. There is no pip. How do I install pylotoncycle? Thanks in advance!

1 Like

I figured it out. Since I couldn’t install pylotoncycle from pip:

I installed the pylotoncycle folder under the peloton folder.
I changed line 6 to “from .pylotoncycle import pylotoncycle”

Works great now.

1 Like

I hooked up a Sengled Light strip to HA. If anyone is interested here is my Automation based on Heart Rate.

alias: Office Light Strip on/color based on Peloton Heart Rate
description: ‘’
trigger:

  • platform: time_pattern
    minutes: ‘1’
    condition:
  • condition: state
    entity_id: sensor.peloton_bubbalax
    state: Active
    action:
  • choose:
    • conditions:
      • condition: numeric_state
        entity_id: sensor.peloton_bubbalax
        attribute: Heart Rate Bpm
        below: ‘129’
        above: ‘111’
        sequence:
      • scene: scene.heart_rate_zone_2
    • conditions:
      • condition: numeric_state
        entity_id: sensor.peloton_bubbalax
        attribute: Heart Rate Bpm
        above: ‘128’
        below: ‘147’
        sequence:
      • scene: scene.heart_rate_zone_3
    • conditions:
      • condition: numeric_state
        entity_id: sensor.peloton_bubbalax
        attribute: Heart Rate Bpm
        above: ‘146’
        below: ‘164’
        sequence:
      • scene: scene.heartrate_zone_4
    • conditions:
      • condition: numeric_state
        entity_id: sensor.peloton_bubbalax
        attribute: Heart Rate Bpm
        above: ‘164’
        sequence:
      • scene: scene.heart_rate_zone_5
        default:
    • scene: scene.health_rate_1
      mode: single
5 Likes

I’ll be using a similar implementation. I’ll be testing this out this week. Has anyone tried it with the Tread+ yet?

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