plasticrake / tplink-smarthome-simulator

TP-Link Smarthome Device Simulator
MIT License
67 stars 18 forks source link

does this devices show in app? #3

Closed xhan0o closed 5 years ago

xhan0o commented 5 years ago

what will be the procedure to add? I see the screenshot where you have added, but in my case I cant find that in kasa app.

mjoyce91 commented 5 years ago

Same issue, even after disabling firewall. @xhan0o did you find a solution to this?

xhan0o commented 5 years ago

Keep connected to the same wifi. They will show up after some time. If not, try restarting phone and scripts. There isn't any known procedure, I believe they just show up after network discovery.

MatthewCash commented 5 years ago

@xhan0o Would you mind helping with the procedure? I can't get mine to appear in the Kasa app. What exactly did you do? As far as I know, you must have some sort of WiFi network created by the smart device for the App to recognize it.

plasticrake commented 5 years ago

Make sure that you are using the default port and if you have multiple devices in the program that they have separate IP addresses. The App should send out a few broadcast pings and find the devices eventually as long as you aren't doing anything too weird with the data. If you can share your actual code that may help. Note that UDP broadcast must be enabled on your router. Some block that or have issues with it.

MatthewCash commented 5 years ago

I have

const UdpServer = require("..").UdpServer;
let device = new Device({
    model: "hs200",
    port: 9999,
    responseDelay: 100
});

device.start();

UdpServer.start(); 

running on a raspberry pi connected to my network via wifi. Do I need to do anything special with the network interface?

MatthewCash commented 5 years ago

The tplink-smarthome-api can only find the device if I set broadcast = "192.168.1.255", in startDiscovery

MatthewCash commented 5 years ago

@plasticrake I only have one network adapter, on my pi, would that be causing the issue?

mjoyce91 commented 5 years ago

@plasticrake The interesting thing is that after I start up the server and open the Kasa app on my phone, I can see the server logging the broadcast pings you mentioned. This was also done aliasing an IP and using that in the config.

192.168.1.153 is my Android's IP.

device:udp [lb100] UDP receiving 57815 192.168.1.153 +3s
device:udp { system: { get_sysinfo: {} } } +0ms
device:udp [lb100] UDP responding, delay:0, 57815 192.168.1.153 +2ms
device:udp {"system":{"get_sysinfo":{"sw_ver":"1.4.3 Build 170504 Rel.144921","hw_ver":"1.0","mic_type":"IOT.SMARTBULB","model":"LB100(US)","description":"Smart Wi-Fi LED Bulb with Dimmable Light","active_mode":"none","rssi":-65,"dev_state":"normal","heapsize":302452,"is_factory":false,"disco_ver":"1.0","is_dimmable":1,"is_color":0,"is_variable_color_temp":0,"ctrl_protocols":{"name":"Linkie","version":"1.0"},"light_state":{"on_off":0,"dft_on_state":{"mode":"normal","hue":0,"saturation":0,"color_temp":2700,"brightness":100}},"preferred_state":[{"index":0,"hue":0,"saturation":0,"color_temp":2700,"brightness":100},{"index":1,"hue":0,"saturation":0,"color_temp":2700,"brightness":75},{"index":2,"hue":0,"saturation":0,"color_temp":2700,"brightness":25},{"index":3,"hue":0,"saturation":0,"color_temp":2700,"brightness":1}],"alias":"Mock LB100","deviceId":"BB100","mac":"50:c7:bf:49:ca:42","hwId":"A2251BE4CC5F4477B6507AF8BD4236E2","oemId":"D978F09CFCD6D7207A199598EDEEEE4E","latitude":"-29.5440","latitude_i":-295440,"longitude":"-175.0211","longitude_i":-1750211,"on_time":0,"err_code":0}}} +0ms

192.168.1.153 being the IP of my Android phone

Server code:

'use strict';

const Device = require('tplink-smarthome-simulator').Device;
const UdpServer = require('tplink-smarthome-simulator').UdpServer;

let devices = [];

// If you setup virtual interfaces or aliases you can have unique ips to work with Kasa app.
// On a mac you can run `sudo ifconfig en0 alias 10.0.0.200`
devices.push(new Device({ port: 9999, address: '192.168.1.255', model: 'lb100', data: { alias: 'Mock LB100', mac: '50:c7:bf:49:ca:42', deviceId: 'BB100' } }));

devices.forEach((d) => {
  d.start();
});

UdpServer.start();

Edit: I don't know what I did, but I used the HS105 mock and now it works.

plasticrake commented 5 years ago

I have noticed that with never versions of the kasa app it seems to only like some MAC addresses. Either a whitelist or a pattern. I’ve had to sometimes use a known good MAC to get it to appear.

MatthewCash commented 5 years ago

Are the ones on the readme good ones?