OpenWiz icon indicating copy to clipboard operation
OpenWiz copied to clipboard

Does this still work?

Open isaacrlevin opened this issue 1 year ago • 7 comments

@UselessMnemonic started seeing socket timeouts recently. Are you able to still communicate with lights on your network?

isaacrlevin avatar May 30 '23 20:05 isaacrlevin

Still works for me, yep! I recently forked the repo to update it to support .NET 7 (recently = about 30 minutes ago), as this is going to be my standard library for handling the few Wiz lights I own.

WhoDunDidIt avatar Dec 10 '23 02:12 WhoDunDidIt

@WhoDunDidIt do you have a repo I can take a look at?

isaacrlevin avatar Jan 17 '24 21:01 isaacrlevin

@WhoDunDidIt do you have a repo I can take a look at?

Sure thing! https://github.com/WhoDunDidIt/OpenWiz

Note: I've since moved to use Home Assistant for all my lights, so I likely will not be doing much with this project any more.

WhoDunDidIt avatar Jan 17 '24 21:01 WhoDunDidIt

Wow that was fast! I just cloned your code and am still getting a timeout receiving from the socket. Do you have some sample that works getting HomeIds?

isaacrlevin avatar Jan 17 '24 21:01 isaacrlevin

HomeIds

Not sure what this is, as the library was only intended to work with Wiz compatible bulbs (typically from Walmart or Home Depot). However I stripped this out of the app I wrote that let me control my lights using a keyboard shortcut. I no longer use it, as I now have become addicted to Home Assistant and control my office lights via a motion sensor now.

However, the code should work just fine, as nothing would have changed with the bulb. I'd double check firewall settings, and ensure that the device you're running it on can talk to the bulb on whatever network it is on. If you have your bulbs in a different VLAN for example, that could cause issues.

private WizHandle _wiz;
private WizSocket _sock;
private readonly WizState _oldWizState;
public bool IsLightOn = false;

// Configure the connection to the bulb
_wiz = new("macaddress", IPAddress.Parse("ipaddress"));
_sock = new WizSocket();

// Capture and save current bulb state
_sock.SendTo(WizState.MakeGetPilot(), _wiz);
_oldWizState = _sock.ReceiveFrom(_wiz);

// Set the flag to the state of the light
IsLightOn = _oldWizState.Result.State.Value;

// <...>
// <...>
// <...>

// Set the state of the light based on the state of the flag (bool)
_sock.SendTo(new WizState()
{
	Method = WizMethod.setPilot,
	Params = new WizParams() { State = Settings.IsLightOn }
}, _wiz); ;

WhoDunDidIt avatar Jan 17 '24 22:01 WhoDunDidIt

Ah so you know the Mac and Ip of the light.... I want to be able to detect the light on the network

isaacrlevin avatar Jan 17 '24 22:01 isaacrlevin

I never played around with discovery, sorry :(

WhoDunDidIt avatar Jan 17 '24 22:01 WhoDunDidIt