title: Trying to communicate with Heatmiser neoHub using provided API, JSON over TCP and C#
body: <p>I'm trying to write a simple program to communicate with a Heatmiser neoHub which should enable fetching and setting of a variety of information regarding my heating system.</p>
  
  <p>According to Heatmiser API documentation I should use JSON over TCP to the neoHub's port 4242, I think my sending code is working but I'm getting no response.</p>
  
  <p>At the moment I have a small .Net Core 2.2 console app which encodes a JSON command to an array of bytes and sends this to the TCP socket connected to the neoHub, I then wait for a response from the neoHub.</p>
  
  <p>My first attempts would have parsed the return JSON and had no timeout on the connection and waited for several minutes before I would kill the app with no response.  The current version has been simplified further to just output any response unparsed JSON to the console and only waits 10 seconds but I still get no response.</p>
  
  <pre><code>using System.Net.Sockets;
  using System.Text;
  
  namespace NeoHub
  {
      class Program
      {
          static void Main(string[] args)
          {
              Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
              socket.Connect("192.168.0.204", 4242);
              socket.ReceiveTimeout = 10000;
  
              Console.WriteLine("connected...");
              string jsonData = "{\"GET_LIVE_DATA\":0}";
  
              byte[] sendData = Encoding.UTF8.GetBytes(jsonData);
              byte[] readData = new byte[1024 * 4];
  
              try
              {
                  int sendBytes = socket.Send(sendData);
                  Console.WriteLine("sent {0}...", sendBytes);
  
                  int readBytes = socket.Receive(readData);
                  Console.WriteLine("receive {0}...", readBytes);
                  Console.WriteLine(Encoding.UTF8.GetString(readData));
              }
              catch (Exception ex)
              {
                  Console.WriteLine(ex.Message);
              }
              Console.ReadKey();
          }
      }
  }
  </code></pre>
  
  <p>The result of a {"GET_LIVE_DATA":0} should be a JSON file similar to below  (I've truncated the example output).</p>
  
  <pre><code>{
  "CLOSE_DELAY": 0,
  "COOL_INPUT": false,
  "GLOBAL_SYSTEM_TYPE": "HeatOnly",
  "HOLIDAY_END": 0,
  "HUB_AWAY": false,
  "HUB_HOLIDAY": false,
  "HUB_TIME": 1518613752,
  "OPEN_DELAY": 0,
  "TIMESTAMP_DEVICE_LISTS": 1518607836,
  "TIMESTAMP_ENGINEERS": 1518607837,
  "TIMESTAMP_PROFILE_0": 1518607836,
  "TIMESTAMP_PROFILE_COMFORT_LEVELS": 1518604883,
  "TIMESTAMP_PROFILE_TIMERS": 1518600089,
  "TIMESTAMP_PROFILE_TIMERS_0": 1518607918,
  "TIMESTAMP_SYSTEM": 1518607836
  }
  </code></pre>