Dette homeyscriptet vil bruke sbankens API for å hente ut kontostatus.
Det du må gjøre er å registrere en klient i sbanken beta utvikler portal. Sette fødselsnummer i koden under som customerID. Så må du bruke API-et for å hente ut en account ID for den kontoen du vil ha status for.
sbanken.jslet customerId = 'xxxfødselsnummerxxx'let b = xxx base64encoded clientid : secret ....'let tokenEndpoint = 'https://auth.sbanken.no/identityserver/connect/token'// var basicAuth = btoa(encodeURIComponent(clientid) + ":" + encodeURIComponent(secret));// console.log("basic ", basicAuth)const response = await fetch(tokenEndpoint, {"headers": {"accept": "application/json","authorization": "Basic " + b,"content-type": "application/x-www-form-urlencoded; charset=utf-8"},"body": 'grant_type=client_credentials',"method": "POST"});let data = await response.json()var token = data['access_token']async function getAPI(path) {const baseURL = 'https://api.sbanken.no/exec.bank/api/v1'let resp = await fetch(baseURL + path, {"headers": {"accept": "application/json","authorization": "Bearer " + token,"content-type": "application/json","customerId": customerId},"method": "GET"});let data = await resp.json()return data}// Note.. You have to play with the API in postman to get the account ID that you would like to get status fromlet r = await getAPI('/Accounts/xxx_accountid_xxx')console.log("=== Results ===")console.log(r)await setTagValue("sbanken_linnea", {type: 'number', title:'Linnea konto'}, r.item.available)//console.log("response", data)