Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Stream data from Tesla's API to TempoDB
class TeslaStreamReader
def initialize(email, password)
@tesla_api = TeslaApi.new(email, password)
end
def stream_to_tempodb
loop do
@tesla_api.vehicles.first.wake_up
car = @tesla_api.vehicles.first
car.stream do |state|
data = []
state.except(:time).each do |key, value|
data << { key: key, v: value.to_f }
end
$tempodb.write_bulk(state[:time], data)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment