Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
How to force AWS Timestream to always interpret a number as double in an IoTCore rule?

Sensor payload decoders are mostly provided as javascript code by the sensor manufacturers. As I'm using different sensor types, I want to use the original decoders without rewriting them in other languages. So I'm using an AWS Lambda (NodeJS) within AWS IoTCore rules for decoding the different sensor payloads, which works fine.

In a succeeding IoTCore rule, I want to send the decoded sensor payload to an AWS Timestream database. AWS Timestream data types are fixed during the first write. So, if the first measurement value "temperature" was a float number like 23.14 degree, the measurement type is fixed to a Timestream::Double type, which is what I want.

However, if the sensor measures a value of a flat 23.0 degrees the next time, then the Timestream write operation leads to the error "Measure name already has an assigned measure value type. Each measure name can have only one measure value type and cannot be changed."

The reason lies in the AWS Timestream parser, which works like so: A numeric value without a decimal point is interpreted as a BigInt type. So,...

> const f1 = 23.4
> const f2 = 23.0
> console.log(f1, typeof f1, f2, typeof f2)
 23.4 'number' 23 'number'
parseFloat(23.14) // becomes Javascript::Number 23.14 Timestream::Double. ==> ok!
parseFloat(23.00) // becomes Javascript::Number 23    Timestream::BigInt  ==> Error! 

I don't want to use parseFloat(23.00).toFixed(2) as it becomes a string value, nor parseFloat(23.00) + 0.001 as it is changing the value and requires always converting/rounding values when processing the AWS Timestream values later on.

How to solve that?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Solved by skipping the IoTCore rule framework and writing in Lambda directly to Timestream, there I can explicitly set the measureValueType = "DOUBLE" , which avoids that kind of problem.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!