Peloton support

I figured this out and have created two sensors now. One for my wife and myself. However the status never changes so it isn’t doing me much good

@edwork any plans to make this a HACS plugin?

Hey All,

Some Updates -

  • Since starting this project, 2 viable Libraries have shown up in Pypi (Pylotoncycle, PyPeloton) - I’ll use these to rebase the project eliminating the need to clone or splice in a github repo. This will allow me to write a proper package and deploy to HACS or even mainline HASS.
  • Features in Progress
    • HACS or Mainline HASS
    • Configurator Flow - required for a proper integration
    • Multiple Config Entry Support

I’m on a 4 week streak right now with the bike, so this is really on my mind at the moment. I hope to have something usable in a week or so.

2 Likes

Good News - I have a working prototype I’ll share very soon. It’s using Pylotoncycle and I have it reporting previous ride stats.

I just need to jump on the bike and do a few cooldown rides with my laptop so I can work out the details of an active session. That’s of course the real motivation behind this - switching lights off, fans on, etc when I hop on the bike.

Here’s the working beta, in a refreshed repo!

3 Likes

I have not installed yet, but it seems like a very cool idea! I didn’t see a list of sensors/data in the read me. Would you mind listing them? Thanks for all of your hard work!!

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?