Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AS-3125 Map current set of Tesla fields #94

Merged
merged 18 commits into from
Nov 13, 2024

Conversation

elffjs
Copy link
Member

@elffjs elffjs commented Nov 4, 2024

Introduce raw Tesla payload translation. We assume that we are given a CloudEvent

{
  "subject": "did:nft:137:0xbA5738a18d83D41847dfFbDC6101d37C69c9B0cF_37", // DID for vehicle NFT.
  "source": "0x983110309620D911731Ac0932219af06091b6744", // Tesla connection address.
  "data": { // Untouched "response" field from Tesla's /vehicle_data endpoint
            // https://developer.tesla.com/docs/fleet-api/endpoints/vehicle-endpoints#vehicle-data
    "charge_state": {
      "battery_level": 23,
      "timestamp": 1730728800, // Row timestamps come from the section timestamps like this one.
      

Here we only add the signals that we presently parse out from Tesla, along with one more: the amount of energy added to the battery during an active charging session.

Following Ruptela, there's a new pkg/tesla/schema/tesla-definitions.yaml and a new make target generate-tesla.

Conversion oddities:

  • Tesla pressure measurements are in bars
  • Distances and speeds are always in miles and miles per hour

Copy link

linear bot commented Nov 4, 2024

@elffjs elffjs changed the title As 3125 first set of tesla mappings AS-3125 Map current set of Tesla fields Nov 4, 2024
@elffjs elffjs marked this pull request as ready for review November 13, 2024 19:18
@elffjs elffjs requested a review from KevinJoiner as a code owner November 13, 2024 19:18

func Decode(msgBytes []byte) ([]vss.Signal, error) {
// Only interested in the top-level CloudEvent fields.
var ce cloudevent.CloudEvent[struct{}]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var ce cloudevent.CloudEvent[struct{}]
var ce cloudevent.CloudEventHeader

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Let's do that.

In truth, we care about two fields and we could probably just select those.
@elffjs elffjs merged commit 3932802 into main Nov 13, 2024
3 checks passed
@elffjs elffjs deleted the as-3125-first-set-of-tesla-mappings branch November 13, 2024 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants