# Socket client in Homey script

**URL:** <https://community.homey.app/t/socket-client-in-homey-script/128433>\
**Category:** Questions & Help\
**Tags:** homey-pro\
**Created:** [January 21, 2025, 7:32am UTC](https://community.homey.app/t/socket-client-in-homey-script/128433 "2025-01-21T07:32:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rob\_G](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rob_g/32/79108_2.png) [@Rob\_G](https://community.homey.app/u/Rob_G)\
**Post date:** [January 21, 2025, 7:32am UTC](https://community.homey.app/t/socket-client-in-homey-script/128433/1 "2025-01-21T07:32:42Z")

</div>

I’m trying to write some JS code in HomeyScript, that can access my solar power ECU.  
Basically, I want to open a socket, write something to it and wait for the response.

I have a small Python script that is working, but I can’t get it to work in JS on HomeyScript.

The problem is with the socket: I can’t figure out what Homey supports or how to write the right code. Could anyone help me out?

The Python code that works(outside of Homey) is this:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/0/80d6e35c2dc7f523b599462383a8d2fcf7e78bed.png)

Thanks,  
Rob

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [January 21, 2025, 8:05am UTC](https://community.homey.app/t/socket-client-in-homey-script/128433/2 "2025-01-21T08:05:13Z")

</div>

HomeyScript doesn’t support any networking protocols other than HTTP (using `fetch`).

---

<div class="post-metadata">

**Author:** ![Rob\_G](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rob_g/32/79108_2.png) [@Rob\_G](https://community.homey.app/u/Rob_G)\
**Post date:** [January 21, 2025, 9:19am UTC](https://community.homey.app/t/socket-client-in-homey-script/128433/3 "2025-01-21T09:19:51Z")

</div>

Thanks @robertklep

I’m not an expert on this, but could fetch be “misused” to do what the Python script does?  
I noticed that using fetch in HomeyScript, the code seems to open a socket, but I don’t know how I could then “write” something to that socket. After a while HomeyScript output shows that the socket was closed again.

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [January 21, 2025, 9:23am UTC](https://community.homey.app/t/socket-client-in-homey-script/128433/4 "2025-01-21T09:23:27Z")

</div>

> [@Rob\_G](#):
>
> I’m not an expert on this, but could fetch be “misused” to do what the Python script does?

I doubt it, it’s fully geared towards the HTTP protocol. It uses standard TCP communication under the hood, but I don’t see how you can tap into that to “abuse” it.

---

<div class="post-metadata">

**Author:** ![Rob\_G](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rob_g/32/79108_2.png) [@Rob\_G](https://community.homey.app/u/Rob_G)\
**Post date:** [January 21, 2025, 9:49am UTC](https://community.homey.app/t/socket-client-in-homey-script/128433/5 "2025-01-21T09:49:08Z")

</div>

Thanks @robertklep  
I guess then I would need to find someone who could create a app for that.
