Badetemperatur

Using Altibox Badetassen APIs to get current temperature

Using data from https://badetassen.no

badetassen.js
// Fetching temperature from Altibox API. Badetassen.
// For use with Athom Homey as a homeyscript.

const apiurl = 'https://prdl-apimgmt.lyse.no/apis/t/prod.altibox.lyse.no/temp/1.0/api/location/'

async function getData() {
    let resp = await fetch(apiurl, {
        "headers": {
            "accept": "application/json",
            "content-type": "application/json",
            "Authorization": "Bearer 9df43895-3d09-30d5-afe4-db2bf92a86f0",
        },
        "method": "GET"
    });
    let data = await resp.json()

    let el = null
    for (let i = 0; i < data.length; i++) {
        if (data[i].Name === 'Sjøbadet') {
            el = data[i]
        }
    }

    return el
}

let r = await getData()
console.log("=== Results ===")
console.log(r)

if (r === null) return;

console.log("Tag " + "badetassen_" + r.id)
console.log({type: 'number', title:'Badetemp [' + r.Name + ']'})
console.log("Temperature: ", r.lastTemperature)

await setTagValue("badetemp_" + r.id, {type: 'number', title:'Badetemp [' + r.Name + ']'}, parseFloat(r.lastTemperature))

Last updated