Zwift Sensor Component - Feedback and Testers Needed

Yay! Now I can decommission my own sensor!

Nice work again! I thought that gradient would be easier but I did some tests here and found that it’s not :-(. The gradient had to be calculated like you did. I tried it with a polling interval of 5 seconds and found the result kind skewed but it was not Wattopia either. Another approach should be to use the x, y position to look on a altitude/gradient table but this should be too much and probably too cpu/memory intensive.

Never thought I would have seen something like this but thank you it is working great!!

This is more of an HA and stats question instead of the component itself:
Any idea how to get a graph specifically of the section where its active?

I have these two sensors and automations that give the times needed but not sure if there’s a chart that can be done without delving into graphana?

sensor:

- platform: mqtt
  name: "Zwift Last Online"
  state_topic: "hass/binary/zwift/online"
- platform: mqtt
  name: "Zwift Last Offline"
  state_topic: "hass/binary/zwift/offline"

automations:

- id: '1549017137487'
  alias: Last time Zwift Online
  trigger:
  - entity_id: sensor.zwift_online_[id]
    platform: state
    to: 'True'
  condition: []
  action:
  - data:
      payload_template: '{{as_timestamp(states.sensor.zwift_online_[id].last_changed)
        | timestamp_custom("%d-%m-%y %H:%M:%S")}}'
      topic: hass/binary/zwift/online
    service: mqtt.publish
- id: '1549017137488'
  alias: Last time Zwift Offline
  trigger:
  - entity_id: sensor.zwift_online_[id]
    platform: state
    to: 'False'
  condition: []
  action:
  - data:
      payload_template: '{{as_timestamp(states.sensor.zwift_online_[id].last_changed)
        | timestamp_custom("%d-%m-%y %H:%M:%S")}}'
      topic: hass/binary/zwift/offline
    service: mqtt.publish

Hi, I’ve been using your component for a couple of months and I love it. Unfortunately since upgrading to Home Assistant 89.2 its stopped working. Am I missing something or are others experiencing issues with the component. Thanks

Hi,

Mine setup works just fine. Most probably the issue due to HA changed file structure of custom component. Just create a folder in the custom_component folder lets say “Zwift”, rename the zwift.py to sensor.py, move sensor.py to the “Zwift” folder. Restart HA.

That worked a treat. Thanks so much for your help. I absolutely love this component. Keep up the good work!

thanks all! Updated the instructions and my repository to be compatible with 0.89 (I just finally updated today, I’m so far behind)

@snicker Thanks for the effort.

Hey I spotted this in my log tonight…

Error executing query: (MySQLdb._exceptions.DataError) (1406, "Data too long for column 'event_data' at row 1")
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id) VALUES (%s, %s, %s, %s, %s, %s, %s)]
[parameters: ('state_changed', '{"entity_id": "sensor.zwift_online_753598", "old_state": {"entity_id": "sensor.zwift_online_753598", "state": "True", "attributes": {"playerId": 7535 ... (132714 characters truncated) ... :00", "last_updated": "2019-04-17T19:11:42.393107+00:00", "context": {"id": "173d1dd7c94a46f780bda8613d729c06", "parent_id": null, "user_id": null}}}', 'LOCAL', datetime.datetime(2019, 4, 17, 19, 11, 42, 393341, tzinfo=<UTC>), datetime.datetime(2019, 4, 17, 19, 11, 42, 647488), '173d1dd7c94a46f780bda8613d729c06', None)]
(Background on this error at: http://sqlalche.me/e/9h9h)

132714 character truncated - I think its trying to add workout data that can by removed from the payload really.

something went major wrong while updating zwift sensor for player 12345
Traceback (most recent call last):
  File "/config/custom_components/zwift/sensor.py", line 293, in _update
    player_state = world.player_status(player_id)
  File "/config/deps/lib/python3.7/site-packages/zwift/world.py", line 25, in player_status
    '/relay/worlds/{}/players/{}'.format(self.world_id, player_id))
  File "/config/deps/lib/python3.7/site-packages/zwift/request.py", line 45, in protobuf
    resp.status_code, resp.reason))
zwift.error.RequestException: 404 - Not Found

hi all,

Maybe I’m not the only one, but I also started to run in zwift so I found useful to have a “sport” sensor too. Zwift in “Run” mode doesnt have power so you have to use speed on your automations. player_status.sport = 0 means cycling and = 1 means running :-).

Hi… just starting looking into this component… but i’m already stuck at loading the component.
Error:
2019-06-16 17:03:35 ERROR (MainThread) [custom_components.zwift.sensor] Could not create Zwift sensor named ‘Zwift’!
Traceback (most recent call last):
File “/config/custom_components/zwift/sensor.py”, line 88, in async_setup_platform
zwift_data._connect()
File “/config/custom_components/zwift/sensor.py”, line 273, in _connect
from zwift import Client as ZwiftClient

I’m running HA v 0.94.3 (Hassio) and have setup the config like posted above. While looking into other possible solutions i see the one is talking about having your account changed to a developers status. Could this be the issue?
Thanks!

Due to weather I am returning to Zwifting and I see same issue as you have. So I wondering have you managed to solve the issue?

hey all, i’ll check this out this week sometime. Bach also requested integrating this with HACS which i will see about doing as well!

Awesome. Just dropped these issues on your git. Thanks @snicker.

@bachulator and @Ernieb44 more recent versions of HomeAssistant have mandated something called manifest.json which indicates what dependencies should be installed. The file structure has also changed, so the Zwift integration needs to be in its own subfolder under custom_components.The error you guys are experiencing seems to be related to this.

Good news though, I haven’t tested this yet, but I think this repository can be used with HACS:

Give it a shot and let me know!

Hi @snicker,

I have added the HACS repo as custom repository and have successfully populated the component to my setup. The sensors seems to be available will test tonight.
Do you plan to add the repo to HACS store?

Thank you very much for your support!

great news! I will be putting the repo into the HACS store.

1 Like

This integration is now in the HACS default store!

I will test it extensively later. Ride on!