# I need to set a variable in BetterLogic from a HomeyScript

**URL:** <https://community.homey.app/t/i-need-to-set-a-variable-in-betterlogic-from-a-homeyscript/112724>\
**Category:** Developers\
**Created:** [July 11, 2024, 10:04am UTC](https://community.homey.app/t/i-need-to-set-a-variable-in-betterlogic-from-a-homeyscript/112724 "2024-07-11T10:04:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Weller](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/michael_weller/32/81907_2.png) [@Michael\_Weller](https://community.homey.app/u/Michael_Weller)\
**Post date:** [July 11, 2024, 10:04am UTC](https://community.homey.app/t/i-need-to-set-a-variable-in-betterlogic-from-a-homeyscript/112724/1 "2024-07-11T10:04:02Z")

</div>

I just need to set a variable in BetterLogic from a Homey-Script.  
But it look as if all examples in the net are outdated and I need to use a http fetch request.

But I can’t get it working.  
Are there any actual working examples?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [July 11, 2024, 2:03pm UTC](https://community.homey.app/t/i-need-to-set-a-variable-in-betterlogic-from-a-homeyscript/112724/2 "2024-07-11T14:03:48Z")

</div>

Start by asking this in the dedicated Better Logic topic please.

> [@Michael\_Weller](#):
>
> it look as if all examples in the net are outdated

You mean the instructions on the BLL app store page don’t function?

> ![Screenshot_20240711-160601_Chrome](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/3/7/379a032f8a3de1632ddad33ea6f5bb87780c1dfc.jpeg)

Recent changes for Homeyscript  
[https://athombv.github.io/com.athom.homeyscript/tutorial-migrate.html](https://athombv.github.io/com.athom.homeyscript/tutorial-migrate.html)

---

<div class="post-metadata">

**Author:** ![Michael\_Weller](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/michael_weller/32/81907_2.png) [@Michael\_Weller](https://community.homey.app/u/Michael_Weller)\
**Post date:** [July 12, 2024, 12:10pm UTC](https://community.homey.app/t/i-need-to-set-a-variable-in-betterlogic-from-a-homeyscript/112724/3 "2024-07-12T12:10:40Z")

</div>

Finanly I managed it…  
Not much useable docu out there ☹

If anyone is searching for the same,  
here a working extract from me code:

```auto
let BLApp = await Homey.apps.getApp({id:"net.i-dev.betterlogic" });
const resBLput = await BLApp.put({path: '/BatteryLoadState/' + "100"});
console.log ("setVar", resBLput)

let check = await BLApp.get({path: '/BatteryLoadState'});
console.log("getVar", check);

```

---

<div class="post-metadata">

**Author:** ![lukenukemmp3](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/lukenukemmp3/32/91808_2.png) [@lukenukemmp3](https://community.homey.app/u/lukenukemmp3)\
**Post date:** [December 12, 2024, 3:17pm UTC](https://community.homey.app/t/i-need-to-set-a-variable-in-betterlogic-from-a-homeyscript/112724/5 "2024-12-12T15:17:13Z")

</div>

You are just awesome! This works like a charm for me!

---

<div class="post-metadata">

**Author:** ![Bert\_Wissink](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bert_wissink/32/30075_2.png) [@Bert\_Wissink](https://community.homey.app/u/Bert_Wissink)\
**Post date:** [June 1, 2025, 11:11am UTC](https://community.homey.app/t/i-need-to-set-a-variable-in-betterlogic-from-a-homeyscript/112724/6 "2025-06-01T11:11:16Z")

</div>

This was also what I have been looking for and indeed hard to find any documentation. Thanks a lot for sharing this!

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [January 12, 2026, 6:16pm UTC](https://community.homey.app/t/i-need-to-set-a-variable-in-betterlogic-from-a-homeyscript/112724/7 "2026-01-12T18:16:32Z")

</div>

Hi @Arie_J_Godschalk ,

To get a listing of all variables, there’s a URL mentioned on the app page in the app store:

`http://192.168.12.34/api/app/net.i-dev.betterlogic/ALL`  
(192.169.12.34 is my Homey 2026 IP)

I’d like to use this URL in a HTTP GET request flow card, but it returns “401 Unauthorized”

This Hscript returns 401 as well

```auto
const url = `http://192.168.12.34/api/app/net.i-dev.betterlogic/all`;

fetch(url)
  .then(response => response.json())
    .then(data => {
      console.log(data);
      })
    .catch(error => {
      console.error('Error fetching data:', error);
      });

```

When I change `api` to `getapi` both return ‘404 not found’

However:  
When I adjust [the script](https://community.homey.app/t/i-need-to-set-a-variable-in-betterlogic-from-a-homeyscript/112724/3) by Michael a bit, it returns my vars correctly:

```auto
let BLApp = await Homey.apps.getApp({id:"net.i-dev.betterlogic" });
const resBLget = await BLApp.get({path: '/all/'});
console.log ("AllVars", resBLget)

```
