Open guyluz11 opened 3 years ago
Why discover method does not find the devices IP at home?. I have managed to find the device IP and was surprised to find out that the discover command only verifies that the IP that you gave it is indeed a Xiaomi device (and return the Token).
I have expected that it will not take any arguments and will return a list of devices at home. I can try to create pull request for that if you like.
Found 2 resources for discovering MiIO devices in the local network that I would like to share here
python-miio discovery documentation
Device discovery
Devices already connected to the same network where the command-line tool is run are automatically detected when miiocli discover is invoked. This command will execute two types of discovery: discovery by handshake and discovery by mDNS. mDNS discovery returns information that can be used to detect the device type which does not work with all devices. The handshake method works on all MiIO devices and may expose the token needed to communicate with the device, but does not provide device type information.
And the search function in MiIO javascript project
@guyluz11 The discover function sends a handshake packet to the broadcast IP of your local network. If the device supports MIIO protocol, it will send back. This can be used to discover all MIIO device in your local network.
You have to use the broadcast IP address of your local network for --ip
argument and the command line interface also has a flag --table
to list all supported devices.
Ho ok didn't know about the --table
, so in that case I might have a different error.
When using my broadcast IP .255
I get an Exception (even as root)
# dart bin/main.dart discover --ip 192.168.31.255 --table
Woah! You appear to be trying to run flutter as root.
We strongly recommend running the flutter tool without superuser privileges.
/
📎
subnet IP 192.168.31
Address ID Stamp Token
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ 02:43:47.591 (+0:00:00.002702)
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ ⛔ Command failed with exception:
│ ⛔ SocketException: Send failed (OS Error: Permission denied, errno = 13), address = 0.0.0.0, port = 0
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I think this is caused by your runtime. The address and port cannot be 0.
Here is my code, can you test it to check if it is working?. I am wary that this is happening because I don't use it from the CLI.
import 'dart:io';
import 'package:miio/miio.dart';
void main(List<String> arguments) async {
final InternetAddress internetAddress = InternetAddress('Enter.your.ip.here');
await for (var miDevice in MiIo.instance.discover(internetAddress)) {
print('miDevice devices $miDevice');
// MiIo.instance.send(address, packet);
}
}
Running from the CLI does not work, I get miio: command not found
even after using pub global activate miio
.
Also what branch of dart do you use?
$ dart --version
Dart SDK version: 2.14.0 (stable) (Mon Sep 6 13:47:59 2021 +0200) on "linux_x64"
Wait
I think this is caused by your runtime. The address and port cannot be 0.
But they are zero in the code.
Tested it both on Linux Kubuntu
, Linux Ubuntu
(with different computer), even after formating reinstalling Kubuntu again it did not work.
Tested on Windows
and it is working!.
So it seems that it does not work only on Linux. Any idea what can cause this?.
Actually this package is developed under windows. I will try it on different os later XD
Hi @ctrysbita Did you find time to test it on Linux?
Discover does not list my light bulb and I don't know if this is because it does not support or I am doing something wrong while using this package.
This is my light bulb
GPX4021GL
, a quick search will say that this isXIAOMI - Mi Smart LED Bulb Essential
so it is mi product.To run the program I have cloned the project and run it with the program arguments
discover --ip=192.168.31.154
while192.168.31.154
is my computer IP. The program exit fast without any errors.I have tested it with
192.168.31.255
but I am getting