SpaceAPI: wind sensor

This commit is contained in:
He4eT 2025-04-05 01:00:52 +02:00
commit ac9dcd9753

View file

@ -285,17 +285,43 @@ export default ({ strapi }: { strapi: Core.Strapi }) => ({
], ],
); );
const windSensors = await getSensors( const windSensors = (await getSensors(
'api::wind-sensor.wind-sensor', 'api::wind-sensor.wind-sensor',
[ [
'TODO',
'properties', 'properties',
'location', 'location',
'name', 'name',
'description', 'description',
'lastchange', '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( const networkConnectionsSensors = (await getSensors(
'api::network-connections-sensor.network-connections-sensor', 'api::network-connections-sensor.network-connections-sensor',