-
Notifications
You must be signed in to change notification settings - Fork 1
Add API endpoint for receiving sensor logs #314
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
Conversation
Separated UI and Sensor log models into distinct API and DB modules. Added new functions to handle sensor log POST requests and save to the database. Updated existing UI log handling for consistency and renamed related files to better reflect their purposes.
Updated `SensorData` and related models to use `RootModel` for improved structure and clarity. Adjusted data serialization in `__init__.py` to use `model_dump()` for compatibility with the new structure.
|
@sam57719 There are no documentation updates. Where does this data go, how can it be accessed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
|
@sjefferson99 there is an open issue, #53, that deals with the DB documentation. It's changing for SMIB 2.0 anyway. It will be in the |
|
@sjefferson99 your issue with the curl command was due to the fact that the device-hostname heading is missing... On windows: |
|
OK, I shall test again after putting my Wang in it. |
Refactored the extraction of `device_hostname` from request headers into the new `extract_device_hostname` function for better code reuse and readability. Updated related event handlers to use this function.
…d-to-smib' into 278-push-sensor-data-from-smibhid-to-smib
|
@sam57719 This now works fine. Will approve when you stick a commit in with the above CURL example in the readme being clear about the required header parameters until we get better smib 2 slack. For me in X weeks time when I go to build the smibhid side and get stuck again. |
|
In my latest commit I made the header optional - for ease of testing, and so that the request handler doesn't just crap out with an unhandled exception |
…d-to-smib' into 278-push-sensor-data-from-smibhid-to-smib
sjefferson99
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally approved after asking a dev to add some documentation... for a month.
New API endpoint
/smib/event/smibhid_sensor_loghas been added and will accept POST requests with data in the following JSON format:[ { "human_timestamp": "2025-04-03T21:42:58Z", "data": { "SCD30": { "relative_humidity": 0, "temperature": 0, "co2": 0 }, "BME280": { "pressure": 1019.3, "humidity": 48.7, "temperature": 20.03 } }, "timestamp": 1743716578 }, { "timestamp": 1743791084, "data": { "SCD30": { "co2": 1548.1, "temperature": 26.3, "relative_humidity": 52.9 }, "BME280": { "pressure": 632, "humidity": 57.64, "temperature": 23.05 } }, "human_timestamp": "2025-04-04T18:24:44Z" } ]The
datasub-object can accept any name of "module" and any name of "sensor". Reading values must be INT or FLOAT.JSON object must be an array (@sjefferson99 let me know if you want this changed)