Zwift Sensor Component - Feedback and Testers Needed

I need some help getting this going. I am running Home Assistant 2021.6.3 on HA OS 5.13. I have the following in my configuration.yaml:

  - platform: zwift
    username: !secret my_zwift_username
    password: !secret my_zwift_password

And, secrets.yaml has the correct information.

On my card I have setup, all of the sensors are stating Entity not available: sensor.zwift_online_123456
I am receiving the following error in the logs:

2021-06-09 15:31:58 ERROR (MainThread) [homeassistant.config] Platform error: media_player
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config.py", line 853, in async_process_component_config
    platform = p_integration.get_platform(domain)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 498, in get_platform
    cache[full_name] = self._import_platform(platform_name)
  File "/usr/src/homeassistant/homeassistant/loader.py", line 503, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'custom_components.zwift.media_player'

I installed the Zwift Sensor Component via HACS. I have tried uninstalling/reinstalling to no avail. Has anyone run across this before? I’ve tried searching, but haven’t found much. Any help would be much appreciated.

try the following for your configuration yaml

# Zwift
sensor zwift:
  - platform: zwift
    username: !secret my_zwift_username
    password: !secret my_zwift_password
2 Likes

Thank you so much @badguy. That did the trick. I’m not sure your name suits you. :grinning:

Hello I am quite new to HASS and all the stuff, but i have bought a Sonoff led band which i was thinking to wrapp arround the TV and than have it linked to Zwift, having the lght changed based on Power effort… do you have the full script you used and do you mind sharing that I can perhap have it on my hass. would be great
thanks

Totally feeling the love for this integration, Anyone know if it is possible or would be possible to pull the elapsed duration of the current ride (not the last ride)? Then I could work out avg. Wkg over the ride so far (useful for leading)

Thanks!

Hello how did you got this nice dashborad i jsut have numbers? sorry i am quiet new, on this…

Top part of the dashboard is mostly from earlier in this thread. The dials I put together like this;

type: grid
cards:
  - type: gauge
    entity: sensor.zwift_current_pc_ftp
    min: 0
    max: 150
    name: '% of FTP'
    needle: true
    severity:
      green: 0
      yellow: 80
      red: 100
  - type: gauge
    entity: sensor.zwift_heart_rate_xxxxxxxx
    min: 0
    max: 200
    name: Heart Rate
    needle: true
    severity:
      green: 0
      yellow: 120
      red: 160
  - type: gauge
    entity: sensor.zwift_current_wkg
    min: 0
    max: 6
    name: Watts per kg
    needle: true
  - type: gauge
    entity: sensor.zwift_speed_xxxxxxxx
    min: 0
    max: 100
    name: Speed
    needle: true
columns: 2
square: false

The %FTP and current WKG are additional sensors I set up.

Too many requests while updating zwift sensor for player?

Has anyone else started getting this error? Online status in Hassio goes from True to False for about 30 seconds, then comes back.

Hi guys!
I am really interested in this dashboard!
I am currently trying to DIY a Kickr Climb to simulate a gradient. As I found out using this kit I can display the current gradient while on a ride. Do you think it is possible to use a motor to adjust the height of the frontwheel according to the value on the dasboard?
I already figured out how to DIY this project mechanically. But I am a noob with software so I am pretty unsure if this is possible. Any advice?

I’m seeing this too - have you had any luck solving it??

Not as yet, haven’t really had time to investigate it as I’ve been too busy Zwifting :stuck_out_tongue:

I was going to disable my automations in case something there was causing this ‘interrupt’, but if it’s not just me…

It’s happens on a very regular pattern if you look at a snapshot from this morning’s session.

Looks similar to my experience (I have the state recording disabled for the zwift entities so can’t see a similar graph). If I find anything out I’ll post back here

for anyone that actually knows what they’re doing, the log entry is:

2021-11-11 13:14:51 ERROR (SyncWorker_3) [custom_components.zwift.sensor] something went wrong in Zwift python library - 429 - Too Many Requests while updating zwift sensor for player 123456
Traceback (most recent call last):
  File "/config/custom_components/zwift/sensor.py", line 361, in update
    player_state = world.player_status(player_id)
  File "/usr/local/lib/python3.9/site-packages/zwift/world.py", line 24, in player_status
    buffer = self.request.protobuf(
  File "/usr/local/lib/python3.9/site-packages/zwift/request.py", line 44, in protobuf
    raise RequestException("{} - {}".format(
zwift.error.RequestException: 429 - Too Many Requests

I’m guessing that Zwift have changed the thresholds for the frequency of connections it will accept. Changing the line in config\custom_components\zwift\sensor.py from

‘self.online_update_interval = timedelta(seconds=1)’

to

‘self.online_update_interval = timedelta(seconds=2)’

seems to have made the problem go away. I’m guessing it’s only noticeable if you have a bunch of automations configured on starting and stopping zwift :slight_smile:

Would be good to get an ‘official’ answer and either get the code change directly or make a change to keep the 1 second resolution. I’m not really a coder so not too confident with using github…

Yes, exactly the same issue. I have automation triggered by transition from False to Start that dims my lights and after 5 minutes starts fan at 60 %. So if I change fan speed manually, which I do often, it slows down after couple of minutes.

Hey all, not sure if this is some new throttling mechanism on the Zwift server side, but I’ll increase the delay to 2 seconds while online to see if that helps. Will post an updated version later today!

Fixed in 3.2.4, please update in HACS or from the repository.

For anyone still having issues, please report here:

Great Snicker. Thanks for your work. I’ll update and check it out on tomorrow’s ride.

(Works perfectly now btw :slight_smile: Thanks!)

I’m working on a DIY climb setup using a linear actuator and need a source for gradient.

Currently using your component through HACS then node red to put the data into an MQTT queue that my esp32 reads to control the actuator. So far this is responsive enough for my needs.

I have a working prototype but the data that I get from grade seems to be roughly half that shown on screen and the Zwift logs. Much higher up in this thread you mentioned you are using metric and I am using imperial units but I would still think delta altitude over delta distance should cancel out the units. I may swap to metric to see if it changes to the correct grade. Another option is I may just put a “fun factor” variable in my code and use that as a multiplier depending on how much movement I’m in the mood for.

I have seen similar projects but none fully documented. I tried using python to scrape the grade from the screen with mixed results because the gradient on screen changes font size and color. I’ve made some improvements but needed a lot of filtering to reject incorrect reads.

Zwift logs is another option but I still feel your tool is more responsive than reading the txt files.

I do believe gradient is being reported incorrectly for some reason, but I’ve never been able to spend the time to troubleshoot why. It seems like it should be a fairly simple calculation, but it might need to be a rolling average or something to match the accuracy of the gradient displayed on screen in game.

1 Like