feat: add weather sensor support and fix device status mapping
This commit introduces support for provisioning weather sensors with geo-coordinates
via user macros and fixes a critical mapping bug in device status.
Changes:
- fix: Corrected DeviceStatus enum mapping (0=ENABLED, 1=DISABLED).
- feat: Added 'status' field to CreateTemplateItem input in GraphQL schema.
- feat: Enabled user macro assignment during host and template creation/import.
- feat: Added regression tests for user macro assignment and HTTP agent URL support.
- docs: Updated cookbook and sample queries to use {$LAT} and {$LON} macros.
- test: Added unit tests for macro assignment in HostImporter and TemplateImporter.
- chore: Regenerated GraphQL types.
This commit is contained in:
parent
5da4a17e36
commit
41e4c4da1f
12 changed files with 251 additions and 60 deletions
|
|
@ -16,7 +16,7 @@ mutation ImportWeatherSensorTemplate($templates: [CreateTemplate!]!) {
|
|||
```
|
||||
|
||||
### Variables
|
||||
The following variables define the `WEATHER_SENSOR` template. It uses the host's inventory coordinates (`{INVENTORY.LOCATION_LAT}` and `{INVENTORY.LOCATION_LON}`) to fetch localized weather data.
|
||||
The following variables define the `WEATHER_SENSOR` template. It uses the host's user macros (`{$LAT}` and `{$LON}`) to fetch localized weather data.
|
||||
|
||||
```json
|
||||
{
|
||||
|
|
@ -28,6 +28,10 @@ The following variables define the `WEATHER_SENSOR` template. It uses the host's
|
|||
"tags": [
|
||||
{ "tag": "deviceType", "value": "WeatherSensorDevice" }
|
||||
],
|
||||
"macros": [
|
||||
{ "macro": "{$LAT}", "value": "52.52" },
|
||||
{ "macro": "{$LON}", "value": "13.41" }
|
||||
],
|
||||
"items": [
|
||||
{
|
||||
"name": "Open-Meteo API Fetch",
|
||||
|
|
@ -36,7 +40,7 @@ The following variables define the `WEATHER_SENSOR` template. It uses the host's
|
|||
"value_type": 4,
|
||||
"history": "0",
|
||||
"delay": "1m",
|
||||
"url": "https://api.open-meteo.com/v1/forecast?latitude={INVENTORY.LOCATION.LAT}&longitude={INVENTORY.LOCATION.LON}¤t=temperature_2m,weather_code",
|
||||
"url": "https://api.open-meteo.com/v1/forecast?latitude={$LAT}&longitude={$LON}¤t=temperature_2m,weather_code",
|
||||
"description": "Master item fetching weather data from Open-Meteo based on host coordinates."
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue