Sensors: Humidity: units

This commit is contained in:
He4eT 2025-06-03 16:49:16 +02:00
commit b72e9214d5
4 changed files with 4 additions and 5 deletions

View file

@ -127,7 +127,7 @@ Always validate your endpoint using the
Due to some Strapi limitations, Due to some Strapi limitations,
certain sensor units must be replaced with aliases in API requests: certain sensor units must be replaced with aliases in API requests:
- Humidity Sensor: use `percents` instead of `%` - Humidity Sensor: use `percent` instead of `%`
- Wind Sensor: use `degree` instead of `°` - Wind Sensor: use `degree` instead of `°`
The main SpaceAPI endpoint will display the correct units. The main SpaceAPI endpoint will display the correct units.

View file

@ -17,7 +17,7 @@
}, },
"unit": { "unit": {
"type": "enumeration", "type": "enumeration",
"enum": ["percents"], "enum": ["percent"],
"required": true "required": true
}, },
"location": { "location": {

View file

@ -290,7 +290,7 @@ export default ({ strapi }: { strapi: Core.Strapi }) => ({
const { unit, ...rest } = sensor; const { unit, ...rest } = sensor;
return { return {
...rest, ...rest,
unit: unit === 'percents' ? '%' : unit, unit: unit === 'percent' ? '%' : unit,
}; };
}), }),
beverage_supply: await getSensors( beverage_supply: await getSensors(

View file

@ -639,8 +639,7 @@ export interface ApiHumiditySensorHumiditySensor
location: Schema.Attribute.String & Schema.Attribute.Required; location: Schema.Attribute.String & Schema.Attribute.Required;
name: Schema.Attribute.String; name: Schema.Attribute.String;
publishedAt: Schema.Attribute.DateTime; publishedAt: Schema.Attribute.DateTime;
unit: Schema.Attribute.Enumeration<['percents']> & unit: Schema.Attribute.Enumeration<['percent']> & Schema.Attribute.Required;
Schema.Attribute.Required;
updatedAt: Schema.Attribute.DateTime; updatedAt: Schema.Attribute.DateTime;
updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> & updatedBy: Schema.Attribute.Relation<'oneToOne', 'admin::user'> &
Schema.Attribute.Private; Schema.Attribute.Private;