# \[APP\] Shelly - Smart solutions for every home and office

**URL:** <https://community.homey.app/t/app-shelly-smart-solutions-for-every-home-and-office/765>\
**Category:** Apps\
**Tags:** app, official, homey, homey-pro, homey-cloud\
**Created:** [August 28, 2018, 8:54pm UTC](https://community.homey.app/t/app-shelly-smart-solutions-for-every-home-and-office/765 "2018-08-28T20:54:43Z")\
**Posts on this page:** 1\
**Showing post:** 6351

<div class="post-metadata">

**Author:** ![gzeel](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/gzeel/32/78901_2.png) [@gzeel](https://community.homey.app/u/gzeel)\
**Post date:** [December 29, 2025, 10:41pm UTC](https://community.homey.app/t/app-shelly-smart-solutions-for-every-home-and-office/765/6351 "2025-12-29T22:41:19Z")

</div>

self hosted.

I’ve e-mailed the developer of the app, but haven’t got a reply.

Update:  
I’ve checked the code and I think I’ve found it.

Root cause:  
In lib/helper/LocalIp.ts:11-14:

`ip = await homey.cloud.getLocalAddress();`  
`// Homey adds a port, so remove that`  
`// Old implement was always removing the last three characters, so keep using that for now`  
`ip = ip.slice(0, -3);`

The code assumes getLocalAddress() returns an IP with a 2-digit port (like :80), so it removes the last 3 characters. However, Homey self-hosted uses port 4860 (and 4859), so getLocalAddress() returns 192.168.2.170:4860. Removing 3 characters leaves 192.168.2.170:4 instead of 192.168.2.170.

This corrupted IP is then used in:

- lib/util.js:4044 for Gen2+ websocket config: ws://${homey\_ip}:6113/
- lib/util.js:4018 for Gen1 CoIoT config: coiot\_peer=${homey\_ip} (which should append :5683)

Additionally, the check in drivers/device.js:160 keeps re-corrupting manually fixed URLs. It checks if the current server URL contains homey\_ip (the corrupted 192.168.2.170:4). Since a correct URL like ws://192.168.2.170:6113/ doesn’t contain :4, the code thinks the URL is wrong and “fixes” it back to the malformed version.

Suggested fix:  
Replace the naive slice(0, -3) with proper port removal:

`ip = await homey.cloud.getLocalAddress();`  
`// Homey adds a port, so remove that`  
`const lastColon = ip.lastIndexOf(‘:’);`  
`if (lastColon !== -1) {`  
`ip = ip.substring(0, lastColon);`  
`}`

This correctly handles any port length.

I will mail this info again to the developer, maybe he reads this forum.

---

_[View the full topic](https://community.homey.app/t/app-shelly-smart-solutions-for-every-home-and-office/765)._
