# Solar system from APsystems

**URL:** <https://community.homey.app/t/solar-system-from-apsystems/74759>\
**Category:** Questions & Help\
**Created:** [January 8, 2023, 1:12pm UTC](https://community.homey.app/t/solar-system-from-apsystems/74759 "2023-01-08T13:12:33Z")\
**Posts on this page:** 1\
**Showing post:** 74

<div class="post-metadata">

**Author:** ![Dick\_J](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dick_j/32/79161_2.png) [@Dick\_J](https://community.homey.app/u/Dick_J)\
**Post date:** [April 22, 2025, 7:10pm UTC](https://community.homey.app/t/solar-system-from-apsystems/74759/74 "2025-04-22T19:10:30Z")

</div>

Hi Rob, unfortunately not. There must be something going wrong with calculating the signature. I moved over to the app development environment, and there it worked, but of course it uses JavaScript. Crypto is not supported in Homey script, so this doesn’t work there.  
I called out to Diederik (see reply from Patrick), because there’s already something that works.

> // Requirements  
> const Homey = require(“homey”);  
> const crypto = require(“crypto”);  
> const { v4: uuidv4 } = require(“uuid”);  
> const fetch = require(“node-fetch”); // Voor Node.js, anders browser fetch
> 
> // Signature data  
> const api\_key = Homey.env.CLIENT\_ID;  
> const api\_secret = Homey.env.CLIENT\_SECRET;  
> const sid = Homey.env.CLIENT\_SID;  
> const signature\_method = “HmacSHA256”;  
> const nonce = uuidv4().replace(/-/g, “”);  
> const ts = Date.now();  
> const timestamp = ts.toString();
> 
> // Request data  
> const base\_url = “[https://api.apsystemsema.com:9282](https://api.apsystemsema.com:9282)”;  
> const request\_path = “/user/api/v2/systems/details/” + sid;  
> const http\_method = “GET”;
> 
> // Create string to sign  
> var urlSegments = request\_path.split(“/”);  
> var lastSegment = urlSegments[urlSegments.length - 1];  
> const stringToSign = `${timestamp}/${nonce}/${api_key}/${lastSegment}/${http_method}/${signature_method}`;
> 
> // Calculate signature  
> const hmacSha256 = crypto.createHmac(“sha256”, api\_secret);  
> hmacSha256.update(stringToSign);  
> const signature = hmacSha256.digest(“base64”);
> 
> //Create headers  
> const header = {  
> “X-CA-AppId”: api\_key,  
> “X-CA-Timestamp”: timestamp,  
> “X-CA-Nonce”: nonce,  
> “X-CA-Signature-Method”: “HmacSHA256”,  
> “X-CA-Signature”: signature,  
> };
> 
> // Create the full url  
> const url = base\_url + request\_path;  
> console.log(getpower);
> 
> // Make a GET request  
> fetch(url, { headers: header })  
> .then((response) =\> {  
> if (!response.ok) {  
> throw new Error(“Network response was not ok”);  
> }  
> return response.json();  
> })  
> .then((data) =\> {  
> console.log(data);  
> })  
> .catch((error) =\> {  
> console.error(“Error:”, error);  
> });
> 
> class Driver extends Homey.Driver {  
> async onPair(session) {  
> const devices = “AP Systems”
> 
> }  
> }
> 
> module.exports = Driver;

---

_[View the full topic](https://community.homey.app/t/solar-system-from-apsystems/74759)._
