# Direct TCP Connection for Home Automation

**URL:** <https://discourse.mopidy.com/t/direct-tcp-connection-for-home-automation/1267>\
**Category:** Misc\
**Created:** [June 30, 2016, 4:54am UTC](https://discourse.mopidy.com/t/direct-tcp-connection-for-home-automation/1267 "2016-06-30T04:54:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AMX\_Guy](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/amx_guy/32/419_2.png) [@AMX\_Guy](https://discourse.mopidy.com/u/AMX_Guy)\
**Post date:** [June 30, 2016, 4:54am UTC](https://discourse.mopidy.com/t/direct-tcp-connection-for-home-automation/1267/1 "2016-06-30T04:54:51Z")

</div>

I’m new to Mopidy and just started screwing around with it. I’m trying to write a module for an AMX control system (similar to Crestron or Control 4 if you are familiar with Home Automation). I’m not sure I’ll be able to negotiate websockets with the automation controller properly using native AMX or Crestron code. I can use HTTP POST RPC and it works fine but has it obvious limits without a persistent connection. Is there any way to connect directly to Mopidy similar to MPD but using the native API without the HTTP overhead? I wrote an MPD module a long, long time ago but it doesn’t seem to work because it relied on the list command which seems to have been replaced with find (I’m using GMusic). I also would prefer to simply use the native API anyway. Thanks much.

---

<div class="post-metadata">

**Author:** ![AMX\_Guy](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.mopidy.com/amx_guy/32/419_2.png) [@AMX\_Guy](https://discourse.mopidy.com/u/AMX_Guy)\
**Post date:** [July 7, 2016, 11:11pm UTC](https://discourse.mopidy.com/t/direct-tcp-connection-for-home-automation/1267/2 "2016-07-07T23:11:42Z")

</div>

Actually, I just figured out how to format websockets traffic. I successfully created an HTTP upgrade header and then used the framing format which is simply $81 followed by the length of the message unless longer than 125. Am I missing anything else or is that it for the header? Pretty cool so far. Now to start making it do something!
