mirror of
https://github.com/He4eT/simple-spaceapi.git
synced 2026-05-05 01:47:24 +00:00
SpaceAPI: wind sensor
This commit is contained in:
parent
3323a3eb38
commit
ac9dcd9753
1 changed files with 29 additions and 3 deletions
|
|
@ -285,17 +285,43 @@ export default ({ strapi }: { strapi: Core.Strapi }) => ({
|
|||
],
|
||||
);
|
||||
|
||||
const windSensors = await getSensors(
|
||||
const windSensors = (await getSensors(
|
||||
'api::wind-sensor.wind-sensor',
|
||||
[
|
||||
'TODO',
|
||||
'properties',
|
||||
'location',
|
||||
'name',
|
||||
'description',
|
||||
'lastchange',
|
||||
],
|
||||
);
|
||||
[
|
||||
'properties.speed',
|
||||
'properties.gust',
|
||||
'properties.direction',
|
||||
'properties.elevation',
|
||||
],
|
||||
)).map((sensor: {properties: {bits_per_second: number, packets_per_second: number}}) => {
|
||||
const { properties, ...rest } = sensor;
|
||||
|
||||
const propertiesEntries = Object.entries(pickFields([
|
||||
'speed',
|
||||
'gust',
|
||||
'direction',
|
||||
'elevation',
|
||||
])(properties))
|
||||
.map(([k, {value, unit}]) => [k, {
|
||||
value,
|
||||
unit: unit === 'Degree' ? '°' : unit,
|
||||
}]);
|
||||
|
||||
return {
|
||||
...rest,
|
||||
...(isEmpty(propertiesEntries)
|
||||
? {}
|
||||
: { properties: Object.fromEntries(propertiesEntries) }
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
const networkConnectionsSensors = (await getSensors(
|
||||
'api::network-connections-sensor.network-connections-sensor',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue