SQL Error for received Sensor data

Hello. Thanks for reading.
I am stumped. I am posting data from my weather station (using EasyWeather) and a “custom” endpoint. From what I can see, everything is fine and farmOS is receiving my POST/JSON data into the data streams fields I created. However, I cannot see any data, anywhere.

I checked in the Sensor’s own LOG tab, and it’s empty. Then I looked into the FarmOS Error Logs (recent log messages) and found this message:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column ‘value_denominator’ at row 1: INSERT INTO “data_stream_basic” (“id”, “timestamp”, “value_numerator”, “value_denominator”) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array ( [:db_insert_placeholder_0] => 8 [:db_insert_placeholder_1] => 1686052596 [:db_insert_placeholder_2] => 9978293341116 [:db_insert_placeholder_3] => 10000000000 ) in Drupal\data_stream\Plugin\DataStream\DataStreamType\Basic->storageSave() (line 487 of /home/farmos/public_html/web/profiles/farm/modules/core/data_stream/src/Plugin/DataStream/DataStreamType/Basic.php).

I’m not sure how to solve this, or if it is a bug. The data is reaching the site, but those are not the data streams I have set up. What is this?

1 Like

I hope my idiot mistakes can help someone else one day.
The values in JSON were not rounded, and blowing out the fields.
A simple round(x,2) did the trick

no good:
{"temp":18.61111111111111,

better:

{"temp":19.11,
2 Likes

Ah glad you figured it out @marlonv ! I was just about to reply. :slight_smile:

We should probably handle that case better in farmOS code so it’s more obvious.

1 Like