Add --joinwifi option to configure the device with Wifi details (#296)

This commit is contained in:
Daniel Høyer Iversen 2020-03-04 22:27:55 +01:00 committed by GitHub
parent e151a14a7b
commit af95fa2446
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View file

@ -78,3 +78,8 @@ Get Energy Consumption (For a SmartPlug) :
```
broadlink_cli --device @BEDROOM.device --energy
```
Once joined to the Broadlink provisioning Wi-Fi, configure it with your Wi-Fi details:
```
broadlink_cli --joinwifi MySSID MyWifiPassword
```

View file

@ -85,6 +85,7 @@ parser.add_argument("--learnfile", help="save learned command to a specified fil
parser.add_argument("--durations", action="store_true",
help="use durations in micro seconds instead of the Broadlink format")
parser.add_argument("--convert", action="store_true", help="convert input data to durations")
parser.add_argument("--joinwifi", nargs=2, help="Args are SSID PASSPHRASE to configure Broadlink device with");
parser.add_argument("data", nargs='*', help="Data to send or convert")
args = parser.parse_args()
@ -102,6 +103,9 @@ if args.host or args.device:
dev = broadlink.gendevice(type, (host, 80), mac)
dev.auth()
if args.joinwifi:
broadlink.setup(args.joinwifi[0], args.joinwifi[1], 4)
if args.convert:
data = bytearray.fromhex(''.join(args.data))
durations = to_microseconds(data)