| 46 | |
| 47 | == TellStickNet == |
| 48 | |
| 49 | Telldus TellStickNet is designed to use Telldus online servers and telldus live API, but it is possible to use TellStickNet as listening device using TCP/IP locally. |
| 50 | |
| 51 | The first approach is described here |
| 52 | http://developer.telldus.se/blog/2012/03/02/help-us-develop-local-access-using-tellstick-net-build-your-own-firmware is |
| 53 | |
| 54 | The second approach is to make changes to the local network DNS and "emulate" telldus live. |
| 55 | |
| 56 | === Network configuration === |
| 57 | The TellStickNet is performing the folowing operations at boot: |
| 58 | 1 - request ip address using dhcp |
| 59 | 2 - resolve api.telldus.com using dns |
| 60 | 3 - HTTP request to api.telldus.com to get url to telldus live server |
| 61 | 4 - connect to telldus live server, register and exchange data. |
| 62 | |
| 63 | In order to make TellStickNet connect to you own software, you will have to setup and configure a local dns server and override the dns entries for telldus.com and telldus.se. |
| 64 | |
| 65 | My dns entries looks like this: |
| 66 | {{{ |
| 67 | telldus.com |
| 68 | api 10.0.1.5 |
| 69 | developer 62.20.121.252 |
| 70 | download 194.30.169.113 |
| 71 | local 10.0.1.5 |
| 72 | login 79.99.3.85 |
| 73 | www 194.30.169.113 |
| 74 | telldus.se |
| 75 | developer 62.20.121.252 |
| 76 | }}} |
| 77 | |
| 78 | 10.0.1.5 is my local computer running http server and the software to emulate telldus live. |
| 79 | |
| 80 | === HTTP configuration === |
| 81 | The TellStickNet is getting the address of the telldus live by asking api.telldus.com using a HTTP get. |
| 82 | |
| 83 | Simply setup a HTTP server somewhere and put a file named assign in a directory called server in the webroot. |
| 84 | |
| 85 | The assign file should contain: |
| 86 | {{{ |
| 87 | 11:local.telldus.comiAFCAs |
| 88 | }}} |
| 89 | OBS the address must have 5 letters as computer name. |
| 90 | |
| 91 | === Software === |
| 92 | The zip file JavaTellStickNet_20120804 contains a java application witch communicate with tellstick net. |
| 93 | This first beta version can only listen and parse nexa protocol (not self learning). |
| 94 | |
| 95 | If you are in a hurry, just use include the lib JavaTellStickNet.jar and toel.jar in your project and use the code: |
| 96 | {{{ |
| 97 | public void Start() { |
| 98 | |
| 99 | boolean proxyMode = false; // Set to true if you want the software to proxy data to Telldus Live real server |
| 100 | |
| 101 | Server server = new Server(proxyMode); |
| 102 | //server.setLiveIp("79.99.3.85"); // Uncomment to change the default ip |
| 103 | //server.setLivePort(45002"); // Uncomment to cahnge the default port |
| 104 | |
| 105 | // Start the server |
| 106 | server.start(); |
| 107 | |
| 108 | // Register event listener |
| 109 | EventHandler.getInstance().subscribe(Event.TELLSTICK_EVENT, this); |
| 110 | |
| 111 | // EXAMPLE CODE: Run for 1 minute |
| 112 | long start = System.currentTimeMillis(); |
| 113 | while (server.isRunning()) { |
| 114 | Dev.sleep(100); |
| 115 | if ((System.currentTimeMillis()-start)>60000) break; |
| 116 | } |
| 117 | |
| 118 | // Shutdown everything |
| 119 | server.shutdown(); |
| 120 | |
| 121 | } |
| 122 | |
| 123 | @Override |
| 124 | public void eventTriggered(EventIF event) { |
| 125 | System.out.println(event.getMessage()); |
| 126 | // Your code here... |
| 127 | } |
| 128 | }}} |
| 129 | |