UselessMnemonic/OpenWiz

Obtain HomeID

Closed this issue · 1 comments

Hey there, I am the creator or PresenceLight, tool to sync your Microsoft Teams presence with smart lights

https://github.com/isaacrlevin/PresenceLight

I am looking to add support for Wiz to my app and was wondering if you are aware of a way to get the Home ID of a user. It seems Wiz has no api at all

Hello friend! Thank you for your interest in my meager code.

As a point of privacy, although there is demonstrably not much privacy to be had with these lights, I advise against commanding devices without explicitly obtaining a Home ID. I assume you are asking users for permission to auto-discover lights anyhow.

That being said, it is possible using a getSystemConfig request. You can do this in a roundabout way by modifying the WizSocket's underlying socket. Simply set it to broadcast mode, and create a WizHandle targeting the broadcast address:

WizSocket socket = new WizSocket();
socket.GetSocket().EnableBroadcast = true; // This will enable sending to the broadcast address

WizHandle handle = new WizHandle("000000000000", IPAddress.Broadcast); // MAC doesn't matter here
WizState state = WizState.MakeGetSystemConfig();

socket.GetSocket().ReceiveTimeout = 1000; // This will prevent the demo from running indefinitely
socket.SendTo(state, handle);

// You won't easily get an IP address here, but this will list all Home IDs on the network.
while(true) {
    state = socket.ReceiveFrom(handle);
    Console.WriteLine($"Home ID for light {state.Result.Mac} = {state.Result.HomeId}");
}

Let me know if this helps!
Edit: some words