Récupération valeur avec un API

Bonjour, je souhaite récupérer les valeurs de mon poollab(analyse piscine chlore ect…)pour les renvoyer sur mon jeedom

J ai récupéré l api sur le site labcom.cloud, seulement je ne sais pas comment l exploiter , j ai tenter via le plugin script en format Json

je mets en en fichier l api avec la procédure a suivre

Bonjour,
Voici le script fourni par le fabricant et modifié pour fonctionner sur jeedom :

#!/bin/bash

# Requirements:
# This script uses jq for JSON parsing.
# apt install jq

# Description:
# This script fetches measurement data from the LabCom GraphQL API and displays it in a formatted table.
# The measurement records will be grouped by parameter and prints only the latest result each.

# Usage:
# ./labcom_api.sh

# --------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------

#Langue
export LANG=C.UTF-8

# Ensure to replace YOUR-API-TOKEN with your actual API token before use
API_TOKEN="VOTRE TOKEN EN LAISSANT LES GUILLEMETS"

# Date range setup for fetching only required measurement records instead of all
AMOUNT_OF_DAYS=7

# Set a static timezone for date/time conversion
TIMEZONE="Europe/Berlin"
# --------------------------------------------------------------------------------------------------------
# --------------------------------------------------------------------------------------------------------

# API Configuration
API_ENDPOINT="https://backend.labcom.cloud/graphql"

now=$(date +%s)
date_filter=$((now - AMOUNT_OF_DAYS * 86400))

# Perform API call to fetch data
response=$(curl -s \
    -X POST \
    -H "Content-Type: application/json" \
    -H "Authorization: $API_TOKEN" \
    --data "{ \"query\": \"{ Accounts { forename surname Measurements (from: $date_filter) { scenario parameter unit value timestamp } } }\" }" \
    $API_ENDPOINT)


convert_timestamp() {
    TZ=$TIMEZONE date -d "@$1" +"%Y-%m-%d %H:%M"
}

# Define headers for the output table
#headers=$(echo -e "\033[1mSampling Point,Scenario,Parameter,Value,Unit,Timestamp\033[0m")
#headers=$(echo -e "\033[SScenario,Parameter,Value,Unit,Date\033[0m")

# Process the response and format it as a table
{
echo "$headers"
    echo "$response" | jq -r '
        .data.Accounts[]
        | select(.Measurements | length > 0)
        | {
            name: (.forename + " " + .surname),
            measurements: (.Measurements
                | group_by(.parameter)
                | map(max_by(.timestamp))
                | sort_by(.timestamp))
        }
        | .name as $name
        | .measurements[]
        | "\($name),\(.scenario),\(.parameter),\(.value),\(.unit),\(.timestamp | @sh)"
    ' | while IFS=, read -r name scenario parameter value unit timestamp; do
        formatted_timestamp=$(convert_timestamp "$timestamp")
        echo -e "$scenario,$parameter,$(echo "scale=2; $value/1"| bc),$unit,$formatted_timestamp"
    done
} | column -t -s,

#Fin du script

super merci !
Désolé de la réponse tardive

Ce sujet a été automatiquement fermé après 24 heures suivant le dernier commentaire. Aucune réponse n’est permise dorénavant.